diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java index 792d7f8..2854d83 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java @@ -208,13 +208,16 @@ public class WalletNode implements Comparable { return copy; } - public void copyLabels(WalletNode pastNode) { + public boolean copyLabels(WalletNode pastNode) { if(pastNode == null) { - return; + return false; } + boolean changed = false; + if(label == null && pastNode.label != null) { label = pastNode.label; + changed = true; } for(BlockTransactionHashIndex txo : getTransactionOutputs()) { @@ -223,16 +226,22 @@ public class WalletNode implements Comparable { BlockTransactionHashIndex pastTxo = optPastTxo.get(); if(txo.getLabel() == null && pastTxo.getLabel() != null) { txo.setLabel(pastTxo.getLabel()); + changed = true; } if(txo.isSpent() && pastTxo.isSpent() && txo.getSpentBy().getLabel() == null && pastTxo.getSpentBy().getLabel() != null) { txo.getSpentBy().setLabel(pastTxo.getSpentBy().getLabel()); + changed = true; } } } for(WalletNode childNode : getChildren()) { Optional optPastChildNode = pastNode.getChildren().stream().filter(node -> node.equals(childNode)).findFirst(); - optPastChildNode.ifPresent(childNode::copyLabels); + if(optPastChildNode.isPresent()) { + changed |= childNode.copyLabels(optPastChildNode.get()); + } } + + return changed; } }