Sjors / libwally-swift

Swift wrapper for LibWally, a collection of useful primitives for cryptocurrency wallets
MIT License
40 stars 18 forks source link

Use libwally's BIP32 path parsing for derivations #68

Closed Sjors closed 2 years ago

Sjors commented 2 years ago

This gets rid of BIP32Path. Using bip32_key_from_parent_path_str_alloc introduced in https://github.com/ElementsProject/libwally-core/pull/309 (v0.8.5)

We now let libwally parse the path for derivation. The other way around is not yet available; we still have to reconstruct the path string from a wally_ext_key. See https://github.com/ElementsProject/libwally-core/issues/241

There's still some path string parsing logic in PSBT, which is where most of the changes are for this PR.

Another downside is that afaik libwally-core can't handle the case where you provide an absolute path (m/x/y/z) when deriving from e.g. level 2. So instead we convert the absolute path to a relative path first (z). See https://github.com/ElementsProject/libwally-core/issues/326

Fixes #65