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?
I'm moving whatever implements
GetKeytorust-psbt, as it is only used in the context of PSBT signing.One question arose while doing this was: Should I implement
GetKeyforKeyMapor should I implement it for the more generalBTreeMap<DescriptorPublicKey, DescriptorSecretKey>type?The problem is that
parse_descriptor, extensively used in BDK, returns aKeyMap, not aBTreeMap, and it's not possible to access the inner type because it's private, so the only option left is to implementGetKeyforKeyMapinrust-psbt.But creating this implementation in
rust-psbtfor 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
GetKeyfor those types, without composing the implementations, which I also find odd. I don't expect downstream projects to require many customGetKeyimplementations.If there is no strong reason against this:
a. Can we remove
KeyMapand returnBTreeMapdirectly? orb. Can we expose the inner
BTreeMapand avoid implementingGetKeyforKeyMap?Other questions:
KeyMapused for something else beside containerizing keys forPsbt.sign?KeyMapused to simplify types?KeyMapused because of a type abstraction? Could a conversion toBTreeMapbe possible in this case?