always select a new address when sending multiple payments to the same open wallet

This commit is contained in:
Craig Raw 2025-01-15 08:21:48 +02:00
parent db1b55cfa0
commit 218c2720e0

View file

@ -174,8 +174,13 @@ public class PaymentController extends WalletFormController implements Initializ
label.requestFocus();
}
} else if(newValue != null) {
List<Address> existingAddresses = getOtherAddresses();
WalletNode freshNode = newValue.getFreshNode(KeyPurpose.RECEIVE);
Address freshAddress = freshNode.getAddress();
while(existingAddresses.contains(freshAddress)) {
freshNode = newValue.getFreshNode(KeyPurpose.RECEIVE, freshNode);
freshAddress = freshNode.getAddress();
}
address.setText(freshAddress.toString());
label.requestFocus();
}
@ -626,6 +631,22 @@ public class PaymentController extends WalletFormController implements Initializ
sendController.updateTransaction();
}
private List<Address> getOtherAddresses() {
List<Address> otherAddresses = new ArrayList<>();
for(Tab tab : sendController.getPaymentTabs().getTabs()) {
PaymentController controller = (PaymentController)tab.getUserData();
if(controller != this) {
try {
otherAddresses.add(controller.getRecipientAddress());
} catch(InvalidAddressException e) {
//ignore
}
}
}
return otherAddresses;
}
public void addPayment(ActionEvent event) {
sendController.addPaymentTab();
}