-
Notifications
You must be signed in to change notification settings - Fork 64
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
spend: feerate using rounded-up vbytes can be lower than target value #1132
Comments
Michael opened an issue about this upstream: bitcoindevkit/coin-select#26. |
To be clear, and to make this appear in searches: this can in particular make a transaction feerate be below min fee (for 1sat/vb txs) thereby making the transaction not broadcastable. |
Preventing the transaction from broadcasting is probably the worst case, and could probably be worked around short term for v7 (h/t @kloaec) by slightly increasing the feerate asked by the user when it's 1sat/vb. For instance making it 1.1 or 1.2 sat/vb. I guess this could work. |
I don't think this specific rounding issue can lead to a feerate below 1 sat/vb:
|
It's worth noting that both the coin selection crate and mempool.space are using vsize = weight/4, without any rounding. If we were to follow the same approach, then we wouldn't face this particular issue. As per my previous comment (#1132 (comment)), I don't think using this approach could lead to a feerate below 1 even if rounding up. Unless I'm missing something, I would favour this approach of not rounding up vbytes. |
It seems that rounding up when calculating the feerate is consistent with Bitcoin Core (bitcoindevkit/coin-select#26 (comment)) so let's stick to that for now. |
The fix has now been merged upstream (bitcoindevkit/coin-select#29) so we just need to wait for the next release of the crate. |
This issue came up recently in #1125 (comment) and also in the past.
When creating a new spend, we target a feerate in terms of sat/vb, but the bdk_coin_select crate we use for coin selection and determining the change amount uses sat/wu, which can lead to the feerate in sat/vb being lower than the target value, given that we round up when converting from wu to vb:
vb = ceil(wu/4)
.One option to fix this is to modify the bdk_coin_select crate so that, if a feerate is specified in sat/vb, it calculates the excess and change amount of a given selection based on the size in vb of the transaction rather than its weight.
The text was updated successfully, but these errors were encountered: