mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-25 07:27:18 +01:00
Fix bug with wrong fee calculation
This commit is contained in:
parent
bcf1b61850
commit
d430442860
1 changed files with 16 additions and 7 deletions
|
@ -87,6 +87,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
private Set<WithdrawalListItem> selectedItems = new HashSet<>();
|
private Set<WithdrawalListItem> selectedItems = new HashSet<>();
|
||||||
private BalanceListener balanceListener;
|
private BalanceListener balanceListener;
|
||||||
private Set<String> fromAddresses;
|
private Set<String> fromAddresses;
|
||||||
|
private Coin amountOfSelectedItems;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -186,8 +187,11 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
// We need to use the max. amount (amountOfSelectedItems) as the senderAmount might be less then
|
||||||
|
// we have available and then the fee calculation would return 0
|
||||||
|
// TODO Get a proper fee calculation from BitcoinJ directly
|
||||||
Coin requiredFee = walletService.getRequiredFeeForMultipleAddresses(fromAddresses,
|
Coin requiredFee = walletService.getRequiredFeeForMultipleAddresses(fromAddresses,
|
||||||
withdrawToTextField.getText(), senderAmount);
|
withdrawToTextField.getText(), amountOfSelectedItems);
|
||||||
Coin receiverAmount = senderAmount.subtract(requiredFee);
|
Coin receiverAmount = senderAmount.subtract(requiredFee);
|
||||||
if (BitsquareApp.DEV_MODE) {
|
if (BitsquareApp.DEV_MODE) {
|
||||||
doWithdraw(receiverAmount, callback);
|
doWithdraw(receiverAmount, callback);
|
||||||
|
@ -227,9 +231,9 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
if (!selectedItems.isEmpty()) {
|
if (!selectedItems.isEmpty()) {
|
||||||
Coin sum = Coin.valueOf(selectedItems.stream().mapToLong(e -> e.getBalance().getValue()).sum());
|
amountOfSelectedItems = Coin.valueOf(selectedItems.stream().mapToLong(e -> e.getBalance().getValue()).sum());
|
||||||
if (sum.isPositive()) {
|
if (amountOfSelectedItems.isPositive()) {
|
||||||
amountTextField.setText(formatter.formatCoin(sum));
|
amountTextField.setText(formatter.formatCoin(amountOfSelectedItems));
|
||||||
} else {
|
} else {
|
||||||
amountTextField.setText("");
|
amountTextField.setText("");
|
||||||
withdrawFromTextField.setText("");
|
withdrawFromTextField.setText("");
|
||||||
|
@ -338,9 +342,14 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean areInputsValid() {
|
private boolean areInputsValid() {
|
||||||
return btcAddressValidator.validate(withdrawToTextField.getText()).isValid &&
|
if (amountTextField.getText().length() > 0) {
|
||||||
amountTextField.getText().length() > 0 &&
|
Coin amount = formatter.parseToCoin(amountTextField.getText());
|
||||||
Restrictions.isAboveFixedTxFeeAndDust(formatter.parseToCoin(amountTextField.getText()));
|
return btcAddressValidator.validate(withdrawToTextField.getText()).isValid &&
|
||||||
|
amount.compareTo(amountOfSelectedItems) <= 0 &&
|
||||||
|
Restrictions.isAboveFixedTxFeeAndDust(amount);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue