mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
copy existing labels from deposit utxos into badbank utxos if present
This commit is contained in:
parent
4e08334a3a
commit
dab6b9663a
1 changed files with 16 additions and 0 deletions
|
@ -744,6 +744,7 @@ public class ElectrumServer {
|
||||||
if(!transactionOutputs.equals(node.getTransactionOutputs())) {
|
if(!transactionOutputs.equals(node.getTransactionOutputs())) {
|
||||||
node.updateTransactionOutputs(wallet, transactionOutputs);
|
node.updateTransactionOutputs(wallet, transactionOutputs);
|
||||||
copyPostmixLabels(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 {
|
public Map<Sha256Hash, BlockTransaction> getReferencedTransactions(Set<Sha256Hash> references, String scriptHash) throws ServerException {
|
||||||
Set<String> txids = new LinkedHashSet<>(references.size());
|
Set<String> txids = new LinkedHashSet<>(references.size());
|
||||||
for(Sha256Hash reference : references) {
|
for(Sha256Hash reference : references) {
|
||||||
|
|
Loading…
Reference in a new issue