-
Notifications
You must be signed in to change notification settings - Fork 323
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
Absolute fee constraint in TxBuilder not being respected #1066
Comments
Can you also give a little code example and which version of bdk are you using? This would help us know which documentation needs to be improved. |
|
For example
In my experience the fee will not necessarily match the fee that was set. |
It's worth pointing out that the "absolute fee" is a really a minimum absolute fee -- it's possible to overshoot it slightly since adding a change output to drian the remaining excess might not be viable. How far off is the fee vs expected? |
Making tiny txs on testnet the fee varies by 100-150%. Is there a way to upper bound it? Or reduce variability at the cost of something else? |
Appreciated the work looking into this. No but I am not convinced that the implementation isn't simply wrong with respect to absolute fees. Is the fee wrong even when a change output is added? That would be the next question since the builder adds a change output and the resulting tx does not have the correct fee that would mean there's a bug I think. |
Yes same thing with the change descriptor. With Also I don't exactly understand this:
|
This does sound like a bug to me. Can you just check that we can distinguish the cases via whether change output is added vs when it is not. i.e. is it always 500 when a change output is added but when you have an output that is close enough to the target amount (here 500) it goes to 250 if not change output is added. In other words i think the bug occurs in the path that change output is added. The culprit is likely a change in or around #641. Strange that tests don't pick it up. |
Same behaviour without the change flag. |
Sorry I don't mean the flag. BDK will add a change output regardless of whether you add a change descriptor (it will just use the main descriptor for the change script pubkey). The question is about whether the change output correlates being added correlates with the bug. You'd need to check the number of outputs the tx has to confirm/deny this. If there's two then a change was added but if there's only one then it was not. |
Yes you are right the 250 fee corresponds with two outputs, the 500 with only one. |
What might cause the random difference in number of outputs? Fee estimate? or coin selection algorithm? |
The issue is when there is no exact match utxos the |
Right this is what I was suggesting here: #1066 (comment) I doubted it though because it seems unlikely that it would result in exactly 250 error (such a round number). Why would not adding a change output lead to an excess fee of exactly double the requirement -- I guess it's just because you were using rather round numbers for inputs and outputs in the experiment... |
0ecc028 doc(bdk): Clarify the absolute_fee, fee_rate docs (Daniela Brozzoni) Pull request description: Fixes #1066 ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: notmandatory: ACK 0ecc028 Tree-SHA512: 152e48b86c21d4fad711abf76dd8fdc0e8955030331005c1ba6ff0c866c52870161f91ec740838f8238c5ad1c620e06212099308a55d130699cb18e4666e3f3f
When creating a tx the absolute fee amount when set does not always match the actual fee amount. I see this is because the amount is added to several times, so it must be deliberate, but for someone using the library it is unintuitive. What is the rationale?
The text was updated successfully, but these errors were encountered: