diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java index c8de3a5d..9db6fe33 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java @@ -744,6 +744,7 @@ public class ElectrumServer { if(!transactionOutputs.equals(node.getTransactionOutputs())) { node.updateTransactionOutputs(wallet, transactionOutputs); copyPostmixLabels(wallet, transactionOutputs); + copyBadbankLabels(wallet, transactionOutputs); } } @@ -761,6 +762,21 @@ public class ElectrumServer { } } + public void copyBadbankLabels(Wallet wallet, Set newTransactionOutputs) { + if(wallet.getStandardAccountType() == StandardAccount.WHIRLPOOL_BADBANK && wallet.getMasterWallet() != null) { + Map masterWalletTxos = wallet.getMasterWallet().getWalletTxos(); + for(BlockTransactionHashIndex newRef : newTransactionOutputs) { + BlockTransactionHashIndex prevRef = masterWalletTxos.keySet().stream() + .filter(txo -> txo.isSpent() && txo.getSpentBy().getHash().equals(newRef.getHash()) && txo.getLabel() != null).findFirst().orElse(null); + if(prevRef != null) { + if(newRef.getLabel() == null && prevRef.getLabel() != null) { + newRef.setLabel("From " + prevRef.getLabel()); + } + } + } + } + } + public Map getReferencedTransactions(Set references, String scriptHash) throws ServerException { Set txids = new LinkedHashSet<>(references.size()); for(Sha256Hash reference : references) {