copy existing labels from deposit utxos into badbank utxos if present

This commit is contained in:
Craig Raw 2022-07-28 13:13:52 +02:00
parent 4e08334a3a
commit dab6b9663a

View file

@ -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) {