BP-WG / bp-std

Modern & lightweight implementation of bitcoin standards without rust-bitcoin/miniscript dependencies
Apache License 2.0
16 stars 17 forks source link

Add XpubDerivable constructors #28

Closed dr-orlovsky closed 3 months ago

dr-orlovsky commented 3 months ago

Closes #27

dr-orlovsky commented 3 months ago

There is no trivial way of converting this two things; and since descriptor-wallet will be eventually replaced by bp-wallet, I do not think it worth spending a lot of time on this.

Currently you can use conversion between ExtendedPubkey and Xpub not through a string but through a fixed-size array serialization, which is supported by both and is ultra-performant. This PR makes field non-private and unlocks ability to use it.

zoedberg commented 3 months ago

Thanks for the suggestion, I'm now able to get an XpubDerivable starting from a DerivationAccount without having to manipulate any string. It requires quite a lot of code but since this should be temporary I think it's acceptable.

Just a couple of requests:

dr-orlovsky commented 3 months ago

is it possible to remove the &'static lifetime from the keychains param?

no, since it uses From<'static ...> for DervationSeg, which requires static since it panics if the length is wrong - and it means that I would need to change it to TryFrom and return error from with if a static type is not used. Why do you need it to be removed?

could you move this PR on top of the master branch please?

done

dr-orlovsky commented 3 months ago

@zoedberg I have added XpubDerivable::try_custom constructor which doesn't require a static argument, but which can fail. I have also renamed other constructor methods