Skip to content

Does rust-miniscript need a KeyMap? #992

Description

@nymius

I'm moving whatever implements GetKey to rust-psbt, as it is only used in the context of PSBT signing.

One question arose while doing this was: Should I implement GetKey for KeyMap or should I implement it for the more general BTreeMap<DescriptorPublicKey, DescriptorSecretKey> type?

The problem is that parse_descriptor, extensively used in BDK, returns a KeyMap, not a BTreeMap, and it's not possible to access the inner type because it's private, so the only option left is to implement GetKey for KeyMap in rust-psbt.

But creating this implementation in rust-psbt for a type in an upstream dependency that was created just to fill that implementation is odd.

In addition, downstream projects wrap this type again and re-implement GetKey for those types, without composing the implementations, which I also find odd. I don't expect downstream projects to require many custom GetKey implementations.

If there is no strong reason against this:

a. Can we remove KeyMap and return BTreeMap directly? or
b. Can we expose the inner BTreeMap and avoid implementing GetKey for KeyMap?

Other questions:

  • Is KeyMap used for something else beside containerizing keys for Psbt.sign?
  • Is KeyMap used to simplify types?
  • Is KeyMap used because of a type abstraction? Could a conversion to BTreeMap be possible in this case?

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