]> Untitled Git - bdk/commit
Fix policy condition calculation
authorAlekos Filini <alekos.filini@gmail.com>
Fri, 31 Mar 2023 18:08:23 +0000 (20:08 +0200)
committerAlekos Filini <alekos.filini@gmail.com>
Sat, 1 Apr 2023 10:57:49 +0000 (12:57 +0200)
commitebd6103e6597e0a66470541d2fcd25709ea77866
tree63755326f9ab4066a1ca2d2e2778ee7be5d93eaa
parent5a090fac904fff2c77c1384c9480e3d98394022d
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).

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.
crates/bdk/src/descriptor/policy.rs
crates/bdk/tests/wallet.rs