bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Descriptor policies should tell you which signers are used in satisfaction

Open LLFourn opened this issue 3 years ago • 6 comments

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.

LLFourn avatar Jan 21 '22 05:01 LLFourn

Picking this up :)

danielabrozzoni avatar Jul 06 '22 08:07 danielabrozzoni

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.

LLFourn avatar Jul 06 '22 09:07 LLFourn

There seems to be a typo in the title - "singer" should be "signer" :sweat_smile: - whole world of difference haha.

evanlinjin avatar Jul 18 '22 03:07 evanlinjin

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.

evanlinjin avatar Jul 18 '22 03:07 evanlinjin

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 avatar Jul 27 '22 14:07 danielabrozzoni

@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.

LLFourn avatar Aug 01 '22 02:08 LLFourn