From 8865f4946ab92ae063d73f10aa255b689c81239f Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 27 Apr 2021 09:44:56 +0200 Subject: [PATCH] follow up to previous commit --- .../transaction/HeadersController.java | 2 +- .../sparrow/wallet/ReceiveController.java | 5 ++++ .../sparrow/wallet/SendController.java | 26 ++++++++++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index f214bc89..a4166fdd 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -489,7 +489,7 @@ public class HeadersController extends TransactionFormController implements Init private void updateFee(Long feeAmt) { fee.setValue(feeAmt); double feeRateAmt = feeAmt.doubleValue() / headersForm.getTransaction().getVirtualSize(); - feeRate.setText(String.format("%.2f", feeRateAmt) + " sats/vByte" + (headersForm.isTransactionFinalized() ? "" : " (non-final)")); + feeRate.setText(String.format("%.2f", feeRateAmt) + " sats/vB" + (headersForm.isTransactionFinalized() ? "" : " (non-final)")); } private void updateBlockchainForm(BlockTransaction blockTransaction, Integer currentHeight) { diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java index 3bf26f13..04e6feb7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java @@ -309,4 +309,9 @@ public class ReceiveController extends WalletFormController implements Initializ public void connection(ConnectionEvent event) { updateLastUsed(); } + + @Subscribe + public void disconnection(DisconnectionEvent event) { + updateLastUsed(); + } } \ No newline at end of file diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index a786a5af..100ebba6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -479,6 +479,7 @@ public class SendController extends WalletFormController implements Initializabl public void updateTransaction(List transactionPayments) { if(walletTransactionService != null && walletTransactionService.isRunning()) { + walletTransactionService.setIgnoreResult(true); walletTransactionService.cancel(); } @@ -495,14 +496,18 @@ public class SendController extends WalletFormController implements Initializabl walletTransactionService = new WalletTransactionService(wallet, getUtxoSelectors(), getUtxoFilters(), payments, feeRate, getMinimumFeeRate(), userFee, currentBlockHeight, groupByAddress, includeMempoolOutputs, includeSpentMempoolOutputs); walletTransactionService.setOnSucceeded(event -> { - walletTransactionProperty.setValue(walletTransactionService.getValue()); - insufficientInputsProperty.set(false); + if(!walletTransactionService.isIgnoreResult()) { + walletTransactionProperty.setValue(walletTransactionService.getValue()); + insufficientInputsProperty.set(false); + } }); walletTransactionService.setOnFailed(event -> { - transactionDiagram.clear(); - walletTransactionProperty.setValue(null); - if(event.getSource().getException() instanceof InsufficientFundsException) { - insufficientInputsProperty.set(true); + if(!walletTransactionService.isIgnoreResult()) { + transactionDiagram.clear(); + walletTransactionProperty.setValue(null); + if(event.getSource().getException() instanceof InsufficientFundsException) { + insufficientInputsProperty.set(true); + } } }); @@ -547,6 +552,7 @@ public class SendController extends WalletFormController implements Initializabl private final boolean groupByAddress; private final boolean includeMempoolOutputs; private final boolean includeSpentMempoolOutputs; + private boolean ignoreResult; public WalletTransactionService(Wallet wallet, List utxoSelectors, List utxoFilters, List payments, double feeRate, double longTermFeeRate, Long fee, Integer currentBlockHeight, boolean groupByAddress, boolean includeMempoolOutputs, boolean includeSpentMempoolOutputs) { this.wallet = wallet; @@ -570,6 +576,14 @@ public class SendController extends WalletFormController implements Initializabl } }; } + + public boolean isIgnoreResult() { + return ignoreResult; + } + + public void setIgnoreResult(boolean ignoreResult) { + this.ignoreResult = ignoreResult; + } } private List getUtxoFilters() {