mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +00:00
automatically label new bip47 receive addresses to identify incoming bip47 payments
This commit is contained in:
parent
04631be8c1
commit
6401761530
1 changed files with 16 additions and 5 deletions
|
@ -179,11 +179,22 @@ public class WalletNode extends Persistable implements Comparable<WalletNode> {
|
||||||
|
|
||||||
public Set<WalletNode> fillToIndex(Wallet wallet, int index) {
|
public Set<WalletNode> fillToIndex(Wallet wallet, int index) {
|
||||||
Set<WalletNode> newNodes = fillToIndex(index);
|
Set<WalletNode> newNodes = fillToIndex(index);
|
||||||
if(!wallet.getDetachedLabels().isEmpty() && wallet.isValid()) {
|
if(wallet.isValid()) {
|
||||||
for(WalletNode newNode : newNodes) {
|
if(!wallet.getDetachedLabels().isEmpty()) {
|
||||||
String label = wallet.getDetachedLabels().remove(newNode.getAddress().toString());
|
for(WalletNode newNode : newNodes) {
|
||||||
if(label != null && (newNode.getLabel() == null || newNode.getLabel().isEmpty())) {
|
String label = wallet.getDetachedLabels().remove(newNode.getAddress().toString());
|
||||||
newNode.setLabel(label);
|
if(label != null && (newNode.getLabel() == null || newNode.getLabel().isEmpty())) {
|
||||||
|
newNode.setLabel(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wallet.isBip47() && keyPurpose == KeyPurpose.RECEIVE && wallet.getLabel() != null && !newNodes.isEmpty()) {
|
||||||
|
String suffix = " " + wallet.getScriptType().getName();
|
||||||
|
for(WalletNode newNode : newNodes) {
|
||||||
|
if((newNode.getLabel() == null || newNode.getLabel().isEmpty()) && wallet.getLabel().endsWith(suffix)) {
|
||||||
|
newNode.setLabel("From " + wallet.getLabel().substring(0, wallet.getLabel().length() - suffix.length()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue