mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-24 23:46:00 -04:00
Bugfix with withdrawal, display exact bitcoin value without rounding
This commit is contained in:
parent
a38fb9d21c
commit
24cc6800e7
10 changed files with 99 additions and 55 deletions
|
@ -24,7 +24,7 @@ public class Restrictions {
|
|||
|
||||
public static final Coin MIN_TRADE_AMOUNT = Coin.parseCoin("0.0001"); // 4 cent @ 400 EUR/BTC
|
||||
|
||||
public static boolean isAboveFixedTxFeeAndDust(Coin amount) {
|
||||
public static boolean isAboveFixedTxFeeForTradesAndDust(Coin amount) {
|
||||
return amount != null && amount.compareTo(FeePolicy.getFixedTxFeeForTrades().add(Transaction.MIN_NONDUST_OUTPUT)) > 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ public class TradeWalletService {
|
|||
boolean useSavingsWallet, Coin tradingFee, String feeReceiverAddresses)
|
||||
throws InsufficientMoneyException, AddressFormatException {
|
||||
Transaction tradingFeeTx = new Transaction(params);
|
||||
Preconditions.checkArgument(Restrictions.isAboveFixedTxFeeAndDust(tradingFee),
|
||||
Preconditions.checkArgument(Restrictions.isAboveFixedTxFeeForTradesAndDust(tradingFee),
|
||||
"You cannot send an amount which are smaller than the fee + dust output.");
|
||||
Coin outPutAmount = tradingFee.subtract(FeePolicy.getFixedTxFeeForTrades());
|
||||
tradingFeeTx.addOutput(outPutAmount, new Address(params, feeReceiverAddresses));
|
||||
|
|
|
@ -717,7 +717,7 @@ public class WalletService {
|
|||
AddressEntryException, InsufficientMoneyException {
|
||||
Transaction tx = new Transaction(params);
|
||||
Preconditions.checkArgument(Restrictions.isAboveDust(amount),
|
||||
"You cannot send an amount which are smaller than 546 satoshis.");
|
||||
"The amount is too low (dust limit).");
|
||||
tx.addOutput(amount, new Address(params, toAddress));
|
||||
|
||||
Wallet.SendRequest sendRequest = Wallet.SendRequest.forTx(tx);
|
||||
|
@ -742,7 +742,7 @@ public class WalletService {
|
|||
AddressFormatException, AddressEntryException, InsufficientMoneyException {
|
||||
Transaction tx = new Transaction(params);
|
||||
Preconditions.checkArgument(Restrictions.isAboveDust(amount),
|
||||
"You cannot send an amount which are smaller than 546 satoshis.");
|
||||
"The amount is too low (dust limit).");
|
||||
tx.addOutput(amount, new Address(params, toAddress));
|
||||
|
||||
Wallet.SendRequest sendRequest = Wallet.SendRequest.forTx(tx);
|
||||
|
|
|
@ -28,21 +28,21 @@ public class RestrictionsTest {
|
|||
@Test
|
||||
public void testIsMinSpendableAmount() {
|
||||
Coin amount = null;
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeAndDust(amount));
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeForTradesAndDust(amount));
|
||||
|
||||
amount = Coin.ZERO;
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeAndDust(amount));
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeForTradesAndDust(amount));
|
||||
|
||||
amount = FeePolicy.getFixedTxFeeForTrades();
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeAndDust(amount));
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeForTradesAndDust(amount));
|
||||
|
||||
amount = Transaction.MIN_NONDUST_OUTPUT;
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeAndDust(amount));
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeForTradesAndDust(amount));
|
||||
|
||||
amount = FeePolicy.getFixedTxFeeForTrades().add(Transaction.MIN_NONDUST_OUTPUT);
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeAndDust(amount));
|
||||
assertFalse("tx unfunded, pending", Restrictions.isAboveFixedTxFeeForTradesAndDust(amount));
|
||||
|
||||
amount = FeePolicy.getFixedTxFeeForTrades().add(Transaction.MIN_NONDUST_OUTPUT).add(Coin.valueOf(1));
|
||||
assertTrue("tx unfunded, pending", Restrictions.isAboveFixedTxFeeAndDust(amount));
|
||||
assertTrue("tx unfunded, pending", Restrictions.isAboveFixedTxFeeForTradesAndDust(amount));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue