Merge pull request #6749 from jmacxx/fix_issue_6743

Show more available UTXOs in Send Funds screen.
This commit is contained in:
Alejandro García 2023-07-04 18:03:52 +00:00 committed by GitHub
commit 4cf54cd5e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,6 @@ import bisq.desktop.components.AutoTooltipLabel;
import bisq.desktop.components.ExternalHyperlink; import bisq.desktop.components.ExternalHyperlink;
import bisq.desktop.components.HyperlinkWithIcon; import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.components.InputTextField; import bisq.desktop.components.InputTextField;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.components.list.FilterBox; import bisq.desktop.components.list.FilterBox;
import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.TxDetails; import bisq.desktop.main.overlays.windows.TxDetails;
@ -53,6 +52,7 @@ import bisq.core.util.validation.BtcAddressValidator;
import bisq.network.p2p.P2PService; import bisq.network.p2p.P2PService;
import bisq.common.UserThread; import bisq.common.UserThread;
import bisq.common.util.Tuple2;
import bisq.common.util.Tuple3; import bisq.common.util.Tuple3;
import bisq.common.util.Tuple4; import bisq.common.util.Tuple4;
@ -130,7 +130,8 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
private RadioButton useAllInputsRadioButton, useCustomInputsRadioButton, feeExcludedRadioButton, feeIncludedRadioButton; private RadioButton useAllInputsRadioButton, useCustomInputsRadioButton, feeExcludedRadioButton, feeIncludedRadioButton;
private Label amountLabel; private Label amountLabel;
private TextField amountTextField, withdrawFromTextField, withdrawToTextField, withdrawMemoTextField, transactionFeeInputTextField; private TextField amountTextField, withdrawToTextField, withdrawMemoTextField, transactionFeeInputTextField;
private String withdrawFromAddresses = "";
private final BtcWalletService btcWalletService; private final BtcWalletService btcWalletService;
private final TradeManager tradeManager; private final TradeManager tradeManager;
@ -188,8 +189,6 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
@Override @Override
public void initialize() { public void initialize() {
filterBox.initialize(filteredList, tableView); filterBox.initialize(filteredList, tableView);
final TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, rowIndex, 4, Res.get("funds.deposit.withdrawFromWallet"));
titledGroupBg.getStyleClass().add("last");
inputsToggleGroup = new ToggleGroup(); inputsToggleGroup = new ToggleGroup();
inputsToggleGroupListener = (observable, oldValue, newValue) -> { inputsToggleGroupListener = (observable, oldValue, newValue) -> {
@ -202,7 +201,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
Res.get("funds.withdrawal.inputs"), Res.get("funds.withdrawal.inputs"),
Res.get("funds.withdrawal.useAllInputs"), Res.get("funds.withdrawal.useAllInputs"),
Res.get("funds.withdrawal.useCustomInputs"), Res.get("funds.withdrawal.useCustomInputs"),
Layout.FIRST_ROW_DISTANCE); 0);
useAllInputsRadioButton = labelRadioButtonRadioButtonTuple3.second; useAllInputsRadioButton = labelRadioButtonRadioButtonTuple3.second;
useCustomInputsRadioButton = labelRadioButtonRadioButtonTuple3.third; useCustomInputsRadioButton = labelRadioButtonRadioButtonTuple3.third;
@ -222,14 +221,13 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
feeExcludedRadioButton = feeTuple3.third; feeExcludedRadioButton = feeTuple3.third;
feeIncludedRadioButton = feeTuple3.fourth; feeIncludedRadioButton = feeTuple3.fourth;
withdrawFromTextField = addTopLabelTextField(gridPane, ++rowIndex, Tuple2<InputTextField, InputTextField> x = addInputTextFieldInputTextField(gridPane, ++rowIndex,
Res.get("funds.withdrawal.fromLabel", Res.getBaseCurrencyCode())).second; Res.get("funds.withdrawal.toLabel", Res.getBaseCurrencyCode()),
Res.get("funds.withdrawal.memoLabel", Res.getBaseCurrencyCode()));
withdrawToTextField = addTopLabelInputTextField(gridPane, ++rowIndex, withdrawToTextField = x.first;
Res.get("funds.withdrawal.toLabel", Res.getBaseCurrencyCode())).second; withdrawMemoTextField = x.second;
withdrawToTextField.setPrefWidth(Layout.MIN_WINDOW_WIDTH);
withdrawMemoTextField = addTopLabelInputTextField(gridPane, ++rowIndex, withdrawMemoTextField.setPrefWidth(Layout.MIN_WINDOW_WIDTH);
Res.get("funds.withdrawal.memoLabel", Res.getBaseCurrencyCode())).second;
Tuple3<Label, InputTextField, ToggleButton> customFeeTuple = addTopLabelInputTextFieldSlideToggleButtonRight(gridPane, ++rowIndex, Tuple3<Label, InputTextField, ToggleButton> customFeeTuple = addTopLabelInputTextFieldSlideToggleButtonRight(gridPane, ++rowIndex,
Res.get("funds.withdrawal.txFee"), Res.get("funds.withdrawal.useCustomFeeValue")); Res.get("funds.withdrawal.txFee"), Res.get("funds.withdrawal.useCustomFeeValue"));
@ -442,7 +440,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
String messageText = Res.get("shared.sendFundsDetailsWithFee", String messageText = Res.get("shared.sendFundsDetailsWithFee",
formatter.formatCoinWithCode(sendersAmount), formatter.formatCoinWithCode(sendersAmount),
withdrawFromTextField.getText(), withdrawFromAddresses,
withdrawToAddress, withdrawToAddress,
formatter.formatCoinWithCode(fee), formatter.formatCoinWithCode(fee),
(double) fee.longValue() / txVsize, // no risk of div/0 since txVsize is always positive (double) fee.longValue() / txVsize, // no risk of div/0 since txVsize is always positive
@ -522,25 +520,17 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
amountAsCoin = Coin.ZERO; amountAsCoin = Coin.ZERO;
totalAvailableAmountOfSelectedItems = Coin.ZERO; totalAvailableAmountOfSelectedItems = Coin.ZERO;
amountTextField.setText(""); amountTextField.setText("");
withdrawFromTextField.setText(""); withdrawFromAddresses = "";
} }
if (selectedItems.size() == 1) { if (selectedItems.size() == 1) {
withdrawFromTextField.setText(selectedItems.stream().findAny().get().getAddressEntry().getAddressString()); withdrawFromAddresses = selectedItems.stream().findAny().get().getAddressEntry().getAddressString();
withdrawFromTextField.setTooltip(null);
} else { } else {
int abbr = Math.max(10, 66 / selectedItems.size()); int abbr = Math.max(10, 66 / selectedItems.size());
String addressesShortened = selectedItems.stream() String addressesShortened = selectedItems.stream()
.map(e -> StringUtils.abbreviate(e.getAddressString(), abbr)) .map(e -> StringUtils.abbreviate(e.getAddressString(), abbr))
.collect(Collectors.joining(", ")); .collect(Collectors.joining(", "));
String text = Res.get("funds.withdrawal.withdrawMultipleAddresses", addressesShortened); withdrawFromAddresses = Res.get("funds.withdrawal.withdrawMultipleAddresses", addressesShortened);
withdrawFromTextField.setText(text);
String addresses = selectedItems.stream()
.map(WithdrawalListItem::getAddressString)
.collect(Collectors.joining(",\n"));
String tooltipText = Res.get("funds.withdrawal.withdrawMultipleAddresses.tooltip", addresses);
withdrawFromTextField.setTooltip(new Tooltip(tooltipText));
} }
} else { } else {
reset(); reset();
@ -605,9 +595,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
} }
private void reset() { private void reset() {
withdrawFromTextField.setText(""); withdrawFromAddresses = "";
withdrawFromTextField.setPromptText(Res.get("funds.withdrawal.selectAddress"));
withdrawFromTextField.setTooltip(null);
totalAvailableAmountOfSelectedItems = Coin.ZERO; totalAvailableAmountOfSelectedItems = Coin.ZERO;
amountAsCoin = Coin.ZERO; amountAsCoin = Coin.ZERO;
@ -752,5 +740,3 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
}); });
} }
} }