diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java index 21622a8d..ca0729ba 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java @@ -174,8 +174,13 @@ public class PaymentController extends WalletFormController implements Initializ label.requestFocus(); } } else if(newValue != null) { + List
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 getOtherAddresses() { + List 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(); }