@CheckForNull private static List<Address> getToAddresses( @Nonnull final Transaction tx, @Nonnull final AbstractWallet pocket, boolean toMe) { List<Address> addresses = new ArrayList<Address>(); for (final TransactionOutput output : tx.getOutputs()) { try { if (output.isMine(pocket) == toMe) { addresses.add(output.getScriptPubKey().getToAddress(pocket.getCoinType())); } } catch (final ScriptException x) { /* ignore this output */ } } return addresses; }
private void tryOpenDispute(boolean isSupportTicket) { if (trade != null) { Transaction depositTx = trade.getDepositTx(); if (depositTx != null) { doOpenDispute(isSupportTicket, trade.getDepositTx()); } else { log.warn("Trade.depositTx is null. We try to find the tx in our wallet."); List<Transaction> candidates = new ArrayList<>(); List<Transaction> transactions = walletService.getWallet().getRecentTransactions(100, true); transactions .stream() .forEach( transaction -> { Coin valueSentFromMe = transaction.getValueSentFromMe(walletService.getWallet()); if (!valueSentFromMe.isZero()) { // spending tx for (TransactionOutput transactionOutput : transaction.getOutputs()) { if (!transactionOutput.isMine(walletService.getWallet())) { if (transactionOutput.getScriptPubKey().isPayToScriptHash()) { // MS tx candidates.add(transaction); } } } } }); if (candidates.size() == 1) doOpenDispute(isSupportTicket, candidates.get(0)); else if (candidates.size() > 1) new SelectDepositTxPopup() .transactions(candidates) .onSelect( transaction -> { doOpenDispute(isSupportTicket, transaction); }) .closeButtonText("Cancel") .show(); else log.error("Trade.depositTx is null and we did not find any MultiSig transaction."); } } else { log.error("Trade is null"); } }