-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent dust outputs from being created during withdraw from wallet #4093
Conversation
This change fixes an issue whereby dust change outputs are inadvertently created when users make withdrawals from their wallets. (Funds -> Send Funds) The solution taken here is to detect a dust TXO during the withdrawal fee estimation process and add that amount to the fee thus eliminating the dust output. For example if the user has 1 BTC and goes to withdraw 0.99999900 BTC it will detect a change TXO of 100 sats which is below the dust limit, increase the fee by 100 sats and therefore withdraw 1 BTC. This fix only applies to user withdrawals from their wallet. Other use cases such as P2P trading, deposits and fees will be handled separately. Related to #4039
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for improving the dust handling.
Please see inline comments on the code.
desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java
Outdated
Show resolved
Hide resolved
desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java
Outdated
Show resolved
Hide resolved
desktop/src/main/java/bisq/desktop/main/funds/withdrawal/WithdrawalView.java
Outdated
Show resolved
Hide resolved
- added a comment describing the `removeDust` method and its effects. - use more descriptive variable names. - made the logging more verbose to help log readers. - use a constant for the dust limit - add a notice to the user when dust is padded to the fee
Here are some tests I found useful: TEST 1 - sending full wallet balance minus 1 satoshi
TEST 2 - avoid dusty change output (amount excludes fee)
TEST 3 - avoid dusty change output (amount includes fee)
TEST 4 - normal transaction with change output (amount excludes fee)
TEST 5 - normal transaction with change output (amount includes fee)
|
Now using `Restrictions.getMinNonDustOutput()` which equates to 546 sats
Moved message text into displaystrings.properties
This commit fixes bisq-network#4093, where it was demonstrated that a bisq.properties file containing the following entries would cause Bisq to fail at startup: baseCurrencyNetwork=BTC_MAINNET bannedSeedNodes= bannedBtcNodes= bannedPriceRelayNodes=5bmpx76qllutpcyp The source of the problem was that the jOptSimple argument parsing library converts the empty value of bannedSeedNodes to a List<String> of size 1 where the 0th element of the list is an empty string. This empty string was then attempted to be converted into a new NodeAddress, causing a validation error. This conversion happened during Guice wiring, and manifested as a blank white screen appearing as wiring errors often do in Bisq. The fix is simple and surgical. We now filter out any empty string elements before attempting to convert the banned seed node value to a new node address. I have reviewed the other related options, such as bannedPriceRelayNodes and bannedBtcNodes, and they do not cause the problem described above, so no filtering or other changes have been made to the way they work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
This is a lot easier to read than current master, good work. Tested and works as expected, good guide to testing as well.
This change fixes an issue whereby dust change outputs are inadvertently created when users make withdrawals from their wallets. (Funds -> Send Funds)
The solution taken here is to detect a dust TXO during the withdrawal fee estimation process and add that amount to the fee thus eliminating the dust output.
For example if the user has 1 BTC and goes to withdraw 0.99999900 BTC it will detect a change TXO of 100 sats which is below the dust limit, increase the fee by 100 sats and therefore withdraw 1 BTC.
This fix only applies to user withdrawals from their wallet. Other use cases such as P2P trading, deposits and fees will be handled separately.
Related to #4039