-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
0.16 Min relay fee issue caused by vsize miscalculation #2235
Comments
I can attest that if I pay exactly 1 sat per 1 vbyte, that sometimes a tiny bit less is paid, and the transaction becomes stuck. However, this is not always the case. I also had cases where the fee was exact. I assume this comes from the fact that the encoding of signatures is not always exactly 32 bytes (pre-taproot, afaicr this has been fixed). Sorry I may be stating the obvious, but I'd like to make sure we're on the same page here. |
To me it looks like a math problem, since the original author actually expected the need to round up - hence the comment. I've actually tested a few transactions and if the value would have been rounded up, it would have been the exact fee. I've created a PR for the rounding up issue: #2236 |
As I just mentioned in #2236, I had another look and think that |
@schildbach I see. Interestingly enough,
|
However, you can try on a few examples and you'll see that the |
I did just that, and I think it behaves the right way:
|
For i.e (12+3)/4 => 15/4 = 3,75. Rounding up it should be 4, not 3. From BIP0141 (the docs): Virtual transaction size is defined as Transaction weight / 4 (rounded up to the next integer). |
I think that line is a bit inexact, but it should lead only to overpaying not to underpaying. Both raw vbytes and sig vbytes are rounded up, rather than adding them as bytes and convert/round to vbytes afterwards. |
The actual division is 12/4 = 3 (without remainer). So 3 is correct, there is nothing to round up. |
To make this clearer, here is the sentence from the spec:
|
I think that explains why you don't see the issue with However, I'm beginning to think that in |
Ah wow, I see what you mean. So you are saying that Edit: I've closed the PR, you are right about the rounding part, but there is a problem somewhere with the estimation. |
I'll look into it in a couple of hours, but if you beat me at it, let me know. |
@alexandrupele see #2239 |
@schildbach great news! Thank you for your prompt response. For now, to avoid our issue with stuck transactions, we'll just set a slightly higher fee. Do you know when we can expect the next minor release or patch that will contain this improvement? |
The fix is merged to master and I've already backported it to the 0.16 branch. We can do a minor release soon if there is demand for it. |
I went ahead and actually released 0.16.1, containing this fix. |
That's great @schildbach! I'll give it a spin tomorrow and I let you know if we still encounter the issue. Thanks! |
So far so good. I can confirm that the issue we had went away and now we can do 1 sat / vbyte transactions on testnet without issues. Thank you again for the support and for the quick fix @schildbach, you are the best! |
Thanks again for reporting and testing this. |
In the latest 0.16 version, the fee is calculated at a "per virtual kilobyte" rate which is great, but the actual vsize value seems to be off by 1 vbyte (less than it should be). The problem seems to be in
Wallet#estimateVirtualBytesForSigning
vsize += (script.getNumberOfBytesRequiredToSpend(key, redeemScript) + 3) / 4; // round up
The value is not actually rounded up! There is a comment about it but I think the implementation was forgotten.
What this means in practice is that given a minimum fee rate of 1000 sats/vbyte, the transaction will most likely be ignored or not even relayed by most applications because it's not passing the min relay fee filter.
The text was updated successfully, but these errors were encountered: