From 518ca6e0c3b35daabd4629527cb928bb1aa67e9f Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Fri, 11 Feb 2022 11:15:27 -0600 Subject: [PATCH] Fix issue selecting specific BSQ UTX for send. The BisqDefaultCoinSelector is invoked multiple times when a transaction is being built. Problem was that the coin selection was being reset within, ultimately leading to coin selection being completely ignored. Solution is to reset the selection after the transaction has been built. The UI for selecting UTXO inputs was being resized to the number of UTXO available, which caused problems when there is a large UTXO set. Solution is to size the UI to accomodate 3 to 15 rows, which provides a reasonable screen display and a scrollbar is provided for the case of a large UTXO set. --- .../java/bisq/core/btc/wallet/BisqDefaultCoinSelector.java | 4 +--- core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java | 2 +- .../desktop/main/overlays/windows/TxInputSelectionWindow.java | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/bisq/core/btc/wallet/BisqDefaultCoinSelector.java b/core/src/main/java/bisq/core/btc/wallet/BisqDefaultCoinSelector.java index c540cc51126..f92e4970868 100644 --- a/core/src/main/java/bisq/core/btc/wallet/BisqDefaultCoinSelector.java +++ b/core/src/main/java/bisq/core/btc/wallet/BisqDefaultCoinSelector.java @@ -56,7 +56,7 @@ public abstract class BisqDefaultCoinSelector implements CoinSelector { // We reset the value to null just after we have applied it inside the select method. @Nullable @Setter - protected Set utxoCandidates; + private Set utxoCandidates; public CoinSelection select(Coin target, Set candidates) { return select(target, new ArrayList<>(candidates)); @@ -78,8 +78,6 @@ public CoinSelection select(Coin target, List candidates) { ArrayList sortedOutputs; if (utxoCandidates != null) { sortedOutputs = new ArrayList<>(utxoCandidates); - // We reuse the selectors. Reset the transactionOutputCandidates field - utxoCandidates = null; } else { sortedOutputs = new ArrayList<>(candidates); } diff --git a/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java b/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java index ad28df8be50..273def00b0b 100644 --- a/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java +++ b/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java @@ -588,7 +588,7 @@ private Transaction getPreparedSendTx(String receiverAddress, wallet.completeTx(sendRequest); checkWalletConsistency(wallet); verifyTransaction(tx); - + coinSelector.setUtxoCandidates(null); // We reuse the selectors. Reset the transactionOutputCandidates field return tx; } catch (InsufficientMoneyException e) { log.error("getPreparedSendTx: tx={}", tx.toString()); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TxInputSelectionWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TxInputSelectionWindow.java index abbd34c7dc9..06a565d172e 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TxInputSelectionWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TxInputSelectionWindow.java @@ -124,7 +124,7 @@ protected void addContent() { .map(transactionOutput -> new TransactionOutputItem(transactionOutput, candidates.contains(transactionOutput))) .collect(Collectors.toList())); tableView.setItems(new SortedList<>(items)); - GUIUtil.setFitToRowsForTableView(tableView, 26, 28, 0, items.size()); + GUIUtil.setFitToRowsForTableView(tableView, 26, 28, 3, 15); balanceTextField = FormBuilder.addBalanceTextField(gridPane, rowIndex++, Res.get("inputControlWindow.balanceLabel"), Layout.FIRST_ROW_DISTANCE); balanceTextField.setFormatter(formatter);