mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-01-27 02:41:10 +00:00
always select a new address when sending multiple payments to the same open wallet
This commit is contained in:
parent
db1b55cfa0
commit
218c2720e0
1 changed files with 21 additions and 0 deletions
|
@ -174,8 +174,13 @@ public class PaymentController extends WalletFormController implements Initializ
|
||||||
label.requestFocus();
|
label.requestFocus();
|
||||||
}
|
}
|
||||||
} else if(newValue != null) {
|
} else if(newValue != null) {
|
||||||
|
List<Address> existingAddresses = getOtherAddresses();
|
||||||
WalletNode freshNode = newValue.getFreshNode(KeyPurpose.RECEIVE);
|
WalletNode freshNode = newValue.getFreshNode(KeyPurpose.RECEIVE);
|
||||||
Address freshAddress = freshNode.getAddress();
|
Address freshAddress = freshNode.getAddress();
|
||||||
|
while(existingAddresses.contains(freshAddress)) {
|
||||||
|
freshNode = newValue.getFreshNode(KeyPurpose.RECEIVE, freshNode);
|
||||||
|
freshAddress = freshNode.getAddress();
|
||||||
|
}
|
||||||
address.setText(freshAddress.toString());
|
address.setText(freshAddress.toString());
|
||||||
label.requestFocus();
|
label.requestFocus();
|
||||||
}
|
}
|
||||||
|
@ -626,6 +631,22 @@ public class PaymentController extends WalletFormController implements Initializ
|
||||||
sendController.updateTransaction();
|
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) {
|
public void addPayment(ActionEvent event) {
|
||||||
sendController.addPaymentTab();
|
sendController.addPaymentTab();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue