-
Notifications
You must be signed in to change notification settings - Fork 493
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
Unable to speed up transaction: Bad request #11215
Comments
I can repro it now with another transaction aswell |
looks like you only need a single satoshi there : ) |
cant repro |
Update: After doing many more tests than the 4 below, I could reproduce the issue, but the conditions to reproduce are yet unclear. Sometimes speeding up a self-transaction works fine others it doesn't. Detailed explanation:To try to reproduce the issue, I made 2 different tests on Main and 2 different tests on Testnet, and I could not reproduce any unexpected behavior, but I found a potential improvement (balance check + UX message). On Main I could replace the transaction without any error related to fees, both using the speed-up and the cancellation. Main test 1:
Main test 2:
OS: Linux Then I tried to reproduce on Testnet with a different OS (Windows). On Testnet (Test 1), I could obtain the same error message. Testnet 1:
Logs:
Testnet 2:
OS: Windows |
After a lot more testing, I reached the conclusion that there is probably a rounding issue while calculating or subtracting the RBF fee to the output. That's why there is always 1 missing sat, and the transaction fails, but only when maths' want to make that rounding issue appear. I found the place in the code where the magic happens and added quite a few logs. It is in particular interesting:
Full logs below:
https://mempool.space/testnet/tx/c8dbe5fd6a28ed792a6e68525106fb4790c345714880d497c9841c624c5b2028 I should be able to find a fix soon |
The problem happens when the final fee rate has three decimals. In the previous failing example, the fee rate was: 2.445 Sat/B. I pulled the "cables" and found a few suspects in the NBitcoin library:
If _FeePerK.Satoshi has a value that doesn't evenly divide by 1000, we could lose some precision. And also:
This could also lead to rounding issues, especially if virtualSize doesn't multiply evenly into _FeePerK.Satoshi * 1000. A quick & easy solution could be to ceil-up the rbfFeeRate amount in RbfTransaction(...) to two decimals.
I'm testing the above, see if it solves this issue. Probably a unit test with edge cases would be appropriate. |
Is it possible to easily resolve it in NBitcoin? (Doesn't have to be quickly.) https://github.com/MetacoSA/NBitcoin/ |
Indeed, it would be cleaner to solve it on NBitcoin. I will see what is possible to suggest on that end. |
Thank you, I appreciate it. |
I could prevent the bug from appearing by altering NBitcoin FeeRate at FeeRate.cs. The conversion from decimal to long truncates the decimal portion. This can result in small inaccuracies. E.g.:
By using Math.Round with MidpointRounding.AwayFromZero, any decimal value from .5 to .999' is always rounded up to the next whole number. Without specifying MidpointRounding.AwayFromZero, and thus using the default MidpointRounding.ToEven (Banker’s Rounding), values ending in .5 are rounded to the nearest even whole number, which may produce discrepancies or undesired results in certain circumstances. I'm going to test it a bit more and make a pull request to the NBitcoin repo. |
General Description
This is a selfspend.
In the logs it says "not enough additional fees to relay"? this is the transaction https://mempool.space/testnet/tx/db82cd4e2383c95f1721dc5d10001a19ab792f0f79d1e20c0997c0beb4c4c448
How To Reproduce?
Screenshots
Logs
I got the same logs everytime (same item order and frequency), tried 4 times
Wasabi Version
3e151ca
The text was updated successfully, but these errors were encountered: