private void doTheMainTask() {

    List<WalletReference> walletReferenceList;

    try {

      walletReferenceList = dao.listWallets();

    } catch (CantListWalletsException cantListWalletsException) {

      pluginRoot.reportError(
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          cantListWalletsException);
      return;
    }

    for (WalletReference walletReference : walletReferenceList) {

      loadWalletInputTransactions(walletReference);
    }
  }
  private void loadWalletInputTransactions(final WalletReference walletReference) {

    CryptoBrokerWallet cryptoBrokerWallet;

    try {

      cryptoBrokerWallet =
          cryptoBrokerWalletManager.loadCryptoBrokerWallet(walletReference.getPublicKey());

    } catch (CryptoBrokerWalletNotFoundException cryptoBrokerWalletNotFoundException) {

      pluginRoot.reportError(
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          cryptoBrokerWalletNotFoundException);
      return;
    }

    List<CurrencyMatching> currencyMatchingList;

    try {

      currencyMatchingList = cryptoBrokerWallet.getCryptoBrokerTransactionCurrencyInputs();

    } catch (
        CantGetTransactionCryptoBrokerWalletMatchingException
            cantGetTransactionCryptoBrokerWalletMatchingException) {

      pluginRoot.reportError(
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          cantGetTransactionCryptoBrokerWalletMatchingException);
      return;
    }

    // TODO test purposes
    // currencyMatchingList = testDataCurrencyMatching();

    Map<MatchingEngineMiddlewareCurrencyPair, UUID> linkedEarningPairs = new HashMap<>();

    try {

      List<EarningsPair> earningPairs = dao.listEarningPairs(walletReference);

      for (EarningsPair earningsPair : earningPairs)
        linkedEarningPairs.put(
            new MatchingEngineMiddlewareCurrencyPair(
                earningsPair.getEarningCurrency(), earningsPair.getLinkedCurrency()),
            earningsPair.getId());

    } catch (CantListEarningsPairsException cantListEarningsPairsException) {

      pluginRoot.reportError(
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          cantListEarningsPairsException);
      return;
    }

    MatchingEngineMiddlewareCurrencyPair currencyPair;

    List<String> transactionsToMarkAsSeen = new ArrayList<>();

    for (CurrencyMatching currencyMatching : currencyMatchingList) {

      try {

        currencyPair =
            new MatchingEngineMiddlewareCurrencyPair(
                currencyMatching.getCurrencyGiving(), currencyMatching.getCurrencyReceiving());

        UUID earningPairId = linkedEarningPairs.get(currencyPair);

        if (earningPairId == null) {

          pluginRoot.reportError(
              UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
              new CantCreateInputTransactionException(
                  "currencyMatching: " + currencyMatching,
                  "There's no earnings pair set for this currency matching."));

        } else {

          if (!dao.existsInputTransaction(currencyMatching.getOriginTransactionId()))
            dao.createInputTransaction(currencyMatching, earningPairId);

          transactionsToMarkAsSeen.add(currencyMatching.getOriginTransactionId());
        }
      } catch (CantCreateInputTransactionException
          | CantGetInputTransactionException daoException) {

        pluginRoot.reportError(
            UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
            daoException);
        return;
      }
    }

    try {

      cryptoBrokerWallet.markAsSeen(transactionsToMarkAsSeen);

    } catch (CantMarkAsSeenException cantMarkAsSeenException) {

      pluginRoot.reportError(
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          cantMarkAsSeenException);
    }
  }