-
Notifications
You must be signed in to change notification settings - Fork 354
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
Fix policy condition calculation #932
Fix policy condition calculation #932
Conversation
When constructing the `Condition` struct we recursively call `get_condition` on all the items in a threshold and short-circuit if there's an error somewhere (for example, because the policy-path hasn't been provided for a specific threshold). This can cause issues when the user doesn't care about a subtree, because we still try to call `get_condition` on all the items and fail if something is missing, even if the specific subtree isn't selected and won't be used later on. This commit changes the logic so that we first filter only the `selected` items, and then unwrap the error using the question mark. If errors happened somewhere else they will be ignored, as it should.
539c56b
to
ebd6103
Compare
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 ebd6103
I did a simple manual test with and without the code fix to confirm test_create_tx_policy_path_ignored_subtree_with_csv
fails without the fix.
I also confirmed the manual work around passes the same test without the code fix, by adding ("w5ay6ydv".to_string(),vec![0])
to the policy path.
…ase/0.28 9cffaad Fix build errors (junderw) 3ccdb84 Fix policy condition calculation When constructing the `Condition` struct we recursively call `get_condition` on all the items in a threshold and short-circuit if there's an error somewhere (for example, because the policy-path hasn't been provided for a specific threshold). (Alekos Filini) Pull request description: Fixes #942 ### Description This backports "Fix policy condition calculation" (#932) onto release/0.28 ### Notes to the reviewers Currently kept the Author the same and the committer is myself. Let me know if this is not the desired outcome of the history. (I have made no modifications myself) ### Changelog notice Backported "Fix policy condition calculation" ### 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 9cffaad Tree-SHA512: c505bc9c8efd75cfa23db7a0e77f010f1758a1b6725661a1af1bcb40c6fd606a13e50ca005c7752fe28c3b7cd748c182fdb5870693e299adaf230adeef02517a
Summary This patch release backports (from the BDK 1.0 dev branch) a fix for a bug in the policy condition calculation and adds a new taproot single key descriptor template (BIP-86). The policy condition calculation bug can cause issues when a policy subtree fails due to missing info even if it's not selected when creating a new transaction, errors on unused policy paths are now ignored. Fixed - Backported bitcoindevkit#932 fix for policy condition calculation bitcoindevkit#1008 Added - Backported bitcoindevkit#840 taproot descriptor template (BIP-86) bitcoindevkit#1033
Description
When constructing the
Condition
struct we recursively callget_condition
on all the items in a threshold and short-circuit if there's an error somewhere (for example, because the policy-path hasn't been provided for a specific threshold).This can cause issues when the user doesn't care about a subtree, because we still try to call
get_condition
on all the items and fail if something is missing, even if the specific subtree isn't selected and won't be used later on.This commit changes the logic so that we first filter only the
selected
items, and then unwrap the error using the question mark. If errors happened somewhere else they will be ignored, as they should.Notes to the reviewers
I think it makes sense to backport this to
0.27
: even though it's not a critical issue (and there's a workaround1 for the bug) it may be a while before the new1.0
is released. I wouldn't do a release just for this, but I would just leave it there and maybe in a few weeks if there are other fixes to be backported to pre-1.0 they could all be released.Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
Bugfixes:
Footnotes
The workaround is to simply set the items in the policy tree even if they won't be used. For example, if the item causing troubles is a
thresh(1, ...)
just set[0]
in the policy path for that id. ↩