Descriptor policies should tell you which signers are used in satisfaction
Consider the extract policy trait:
pub trait ExtractPolicy {
/// Extract the spending [`policy`]
fn extract_policy(
&self,
signers: &SignersContainer,
psbt: BuildSatisfaction,
secp: &SecpCtx,
) -> Result<Option<Policy>, DescriptorError>;
}
we pass in signers and then get back a Policy which tells us which items we can satisfy, and which have already been satisfied. It would be really handy to know which of the signers were involved in helping to satisfy the policy. Then we could avoid calling .sign for every signer and only use the ones that will help. This is probably also necessary to solve #529.
Picking this up :)
Awesome would be really interested to see what you come up with here since I want to have it in bdk_core.
What do you think about the idea about being able to apply this logic before coin selection time so we know the weight of the forthcoming witness.
There seems to be a typo in the title - "singer" should be "signer" :sweat_smile: - whole world of difference haha.
This will be extremely helpful for the multi-descriptor capability (#486), so we do not have to attempt to sign with every single Signer contained within MultiTracker.
What do you think about the idea about being able to apply this logic before coin selection time so we know the weight of the forthcoming witness.
That would be really cool! I think we should have, as always, a "default" API, so that users that don't even know what a path is (they just use a single sig), can still use bdk without worrying too much. But sure, for more advanced users, this would be great!
@danielabrozzoni my idea was that BDK would use this internally when computing the weight for coin selection so we didn't just use max_satisfaction_weight. I guess advanced users should be able to configure what spending path gets used but the most value is just being able to choose it for internal use.