From dd146210bae69a4d668c76b81aef6229237318cb Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 21 May 2021 09:53:00 +0200 Subject: [PATCH] set send amount to total utxo value when sending selected utxos before an address or label is added --- .../com/sparrowwallet/sparrow/wallet/PaymentController.java | 4 +++- .../java/com/sparrowwallet/sparrow/wallet/SendController.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java index 4ca6c8b2..7365607c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java @@ -278,7 +278,9 @@ public class PaymentController extends WalletFormController implements Initializ public void setPayment(Payment payment) { if(getRecipientValueSats() == null || payment.getAmount() != getRecipientValueSats()) { - address.setText(payment.getAddress().toString()); + if(payment.getAddress() != null) { + address.setText(payment.getAddress().toString()); + } if(payment.getLabel() != null && !label.getText().equals(payment.getLabel())) { label.setText(payment.getLabel()); } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index 45389a1d..01370345 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -1063,6 +1063,9 @@ public class SendController extends WalletFormController implements Initializabl if(event.getPayments() != null) { clear(null); setPayments(event.getPayments()); + } else if(paymentTabs.getTabs().size() == 1) { + Payment payment = new Payment(null, null, event.getUtxos().stream().mapToLong(BlockTransactionHashIndex::getValue).sum(), true); + setPayments(List.of(payment)); } if(event.getFee() != null) {