diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 18644b8d..1eaba12e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -54,6 +54,7 @@ import tornadofx.control.Fieldset; import com.google.common.eventbus.Subscribe; import tornadofx.control.Form; +import javax.swing.text.html.Option; import java.io.*; import java.net.*; import java.nio.charset.StandardCharsets; @@ -674,7 +675,8 @@ public class HeadersController extends TransactionFormController implements Init List payments = new ArrayList<>(); for(TransactionOutput txOutput : headersForm.getTransaction().getOutputs()) { try { - payments.add(new Payment(txOutput.getScript().getToAddresses()[0], null, txOutput.getValue(), false)); + BlockTransactionHashIndex receivedTxo = getBlockTransactionOutput(txOutput); + payments.add(new Payment(txOutput.getScript().getToAddresses()[0], receivedTxo != null ? receivedTxo.getLabel() : null, txOutput.getValue(), false)); } catch(Exception e) { //ignore } @@ -708,6 +710,17 @@ public class HeadersController extends TransactionFormController implements Init return null; } + private BlockTransactionHashIndex getBlockTransactionOutput(TransactionOutput txOutput) { + for(Wallet openWallet : AppServices.get().getOpenWallets().keySet()) { + Optional output = openWallet.getWalletTxos().keySet().stream().filter(ref -> ref.getHash().equals(txOutput.getHash()) && ref.getIndex() == txOutput.getIndex()).findFirst(); + if(output.isPresent()) { + return output.get(); + } + } + + return null; + } + private void updateBlockchainForm(BlockTransaction blockTransaction, Integer currentHeight) { signaturesForm.setVisible(false); blockchainForm.setVisible(true);