/**
   * function that updates debit/credit/balance/price in fiat and Transaction History table
   *
   * @param services
   */
  private void updateWalletsSummary(List<WalletService> services) {
    Coin totalDebit = Coin.ZERO;
    Coin totalCredit = Coin.ZERO;
    Coin totalBalance = Coin.ZERO;
    double priceInFiat = 0.00d;
    String confidence = "";
    // update debit/credit/balance and price in fiat
    List<TransactionWrapper> transactions = new ArrayList<>();
    for (WalletService service : services) {
      try {
        Wallet wallet = service.getWallet();
        totalBalance = totalBalance.add(wallet.getBalance());
        for (Transaction trx : wallet.getTransactionsByTime()) {
          if (trx.getConfidence().equals(TransactionConfidence.ConfidenceType.DEAD)) continue;
          Coin amount = trx.getValue(wallet);
          if (amount.isPositive()) {
            totalCredit = totalCredit.add(amount);
          } else {
            totalDebit = totalDebit.add(amount);
          }
          transactions.add(new TransactionWrapper(trx, wallet, amount));
        }
      } catch (Exception e) {
        logger.error("Unable to update wallet details");
      }
    }
    pnlDashboardStats.setTotalBalance(MonetaryFormat.BTC.noCode().format(totalBalance).toString());
    // pnlDashboardStats.setTotalDebit(MonetaryFormat.BTC.noCode().format(totalDebit).toString());
    // pnlDashboardStats.setTotalCredit(MonetaryFormat.BTC.noCode().format(totalCredit).toString());
    priceInFiat = Double.valueOf(MonetaryFormat.BTC.noCode().format(totalBalance).toString());
    priceInFiat *= BitcoinCurrencyRateApi.get().getCurrentRateValue();
    pnlDashboardStats.setPriceInFiat(
        String.format("%.2f", priceInFiat), "", ConfigManager.config().getSelectedCurrency());
    pnlDashboardStats.setExchangeRate(
        ConfigManager.config().getSelectedCurrency(),
        String.format("%.2f", BitcoinCurrencyRateApi.get().getCurrentRateValue()));
    Collections.sort(
        transactions,
        new Comparator<TransactionWrapper>() {
          @Override
          public int compare(TransactionWrapper o1, TransactionWrapper o2) {
            return o2.getTransaction()
                .getUpdateTime()
                .compareTo(o1.getTransaction().getUpdateTime());
          }
        });
    // update Transaction History table
    DefaultTableModel model = (DefaultTableModel) tblTransactions.getModel();
    model.setRowCount(0);
    for (TransactionWrapper wrapper : transactions) {
      Transaction transaction = wrapper.getTransaction();
      if (transaction.getConfidence().getDepthInBlocks() > 6)
        confidence = "<html>6<sup>+</sup></html>";
      else confidence = transaction.getConfidence().getDepthInBlocks() + "";
      Coin amount = wrapper.getAmount();
      Coin fee = transaction.getFee();
      String amountString = MonetaryFormat.BTC.noCode().format(amount).toString();
      String feeString = fee != null ? MonetaryFormat.BTC.noCode().format(fee).toString() : "0.00";
      Address from = transaction.getInput(0).getFromAddress();
      Address to =
          transaction
              .getOutput(0)
              .getAddressFromP2PKHScript(wrapper.getWallet().getNetworkParameters());
      boolean credit = amount.isPositive();

      model.addRow(
          new Object[] {
            Utils.formatTransactionDate(transaction.getUpdateTime()),
            from,
            to,
            credit ? "Credit" : "Debit",
            amountString,
            feeString,
            "",
            confidence
          });
    }
    Coin balanceAfter = Coin.ZERO;
    for (int index = transactions.size() - 1; index >= 0; index--) {
      balanceAfter = balanceAfter.add(Coin.parseCoin((String) model.getValueAt(index, 4)));
      model.setValueAt(MonetaryFormat.BTC.noCode().format(balanceAfter).toString(), index, 6);
    }
  }