Skip to content

DefiniteDescriptorKey does not expose a way to get the key out if it's internally a single key #491

Closed
@apoelstra

Description

@apoelstra

Right now if you have a DescriptorPublicKey and you convert it to a DefiniteDescriptorKey with at_derivation_index, you lose any good way to determine whether you have a single key or not, and you lose access to the key.

With DescriptorPublicKey you can just match on it since it's a public enum and is either Single or XPub. But DefiniteDescriptorKey is an opaque struct.

Consider the case where you have a descriptor public key, potentially with hardened wildcards, but it's user-provided so it could be anything. To get a specific public key out of this you need to talk to a hww. With a DescriptorPublicKey you'd match on the key; for Single you directly pull the key out, and for Xpub you pass the derivation path over USB to your hww and use the result. But now with DefiniteDescriptorKey you're forced to call derive_public_key, which requires you have a secp context available, and only after this fails do you know that you need to switch to the hww.

I'm not sure what the best solution here is. Probably just a single_key -> Option<SinglePub> method on DefiniteDescriptorKey.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions