Browse Source

copy existing labels from deposit utxos into badbank utxos if present

terminal
Craig Raw 2 years ago
parent
commit
dab6b9663a
  1. 16
      src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java

16
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<BlockTransactionHashIndex> newTransactionOutputs) {
if(wallet.getStandardAccountType() == StandardAccount.WHIRLPOOL_BADBANK && wallet.getMasterWallet() != null) {
Map<BlockTransactionHashIndex, WalletNode> 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<Sha256Hash, BlockTransaction> getReferencedTransactions(Set<Sha256Hash> references, String scriptHash) throws ServerException {
Set<String> txids = new LinkedHashSet<>(references.size());
for(Sha256Hash reference : references) {

Loading…
Cancel
Save