use different addresses when sending batched payments to the same paynym

This commit is contained in:
Craig Raw 2023-03-06 12:30:26 +02:00
parent dd3b980c36
commit 84978a3d5d
2 changed files with 23 additions and 0 deletions

View file

@ -413,7 +413,11 @@ public class PaymentController extends WalletFormController implements Initializ
try {
Wallet recipientBip47Wallet = getWalletForPayNym(payNym);
if(recipientBip47Wallet != null) {
int index = sendController.getPayNymSendIndex(this);
WalletNode sendNode = recipientBip47Wallet.getFreshNode(KeyPurpose.SEND);
for(int i = 0; i < index; i++) {
sendNode = recipientBip47Wallet.getFreshNode(KeyPurpose.SEND, sendNode);
}
ECKey pubKey = sendNode.getPubKey();
Address address = recipientBip47Wallet.getScriptType().getAddress(pubKey);
if(sendController.getPaymentTabs().getTabs().size() > 1 || (getRecipientValueSats() != null && getRecipientValueSats() > getRecipientDustThreshold(address)) || maxButton.isSelected()) {
@ -433,6 +437,11 @@ public class PaymentController extends WalletFormController implements Initializ
return masterWallet.getChildWallet(new PaymentCode(payNym.paymentCode().toString()), payNym.segwit() ? ScriptType.P2WPKH : ScriptType.P2PKH);
}
boolean isSentToSamePayNym(PaymentController paymentController) {
return (this != paymentController && payNymProperty.get() != null && !payNymProperty.get().isCollaborativeSend()
&& payNymProperty.get().paymentCode().equals(paymentController.payNymProperty.get().paymentCode()));
}
private Long getRecipientValueSats() {
return getRecipientValueSats(amountUnit.getSelectionModel().getSelectedItem());
}

View file

@ -542,6 +542,20 @@ public class SendController extends WalletFormController implements Initializabl
}
}
int getPayNymSendIndex(PaymentController paymentController) {
int index = 0;
for(Tab tab : paymentTabs.getTabs()) {
PaymentController controller = (PaymentController)tab.getUserData();
if(controller == paymentController) {
break;
} else if(controller.isSentToSamePayNym(paymentController)) {
index++;
}
}
return index;
}
public void updateTransaction() {
updateTransaction(null);
}