You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge rust-bitcoin#4623: Improve Xpriv::derive_xpriv and Xpub::derive_xpub ergonomics slightly
3527122 psbt: Use new `derive_xpriv` flexibility in GetKey (Daniel Roberts)
bd3f4b6 psbt: Add test for GetKey bip32 (Daniel Roberts)
c7bdec1 Fix clippy lint and formatting for `Xpriv::derive_xpriv` and `Xpriv::derive_xpub` calls (Daniel Roberts)
9d4381c Improve `Xpriv::derive_xpriv` and `Xpub::derive_xpub` ergonomics (Daniel Roberts)
Pull request description:
This enables a couple more things to be passed to the bip32 derive methods, with (afaict) no downside (all existing call sites remain valid and work as before).
Given
```
let secp = Secp256k1::new();
let path: DerivationPath = "42'/350'/0".parse().unwrap();
let xpriv: Xpriv = "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi".parse().unwrap();
```
The following *new* ways to call derive are enabled:
```
/// Derive using only part of the path
xpriv.derive_xpriv(&secp, &path[1..])
```
```
/// Derive moving into the method
xpriv.derive_xpriv(&secp, path)
```
The second case is probably of questionable usefulness, but I've ended up writing something like
```
let path: DerivationPath = path.into_iter().skip(n).cloned().collect()
```
enough that the first case would be welcome, and can be done with a minimal change.
I'm reasonably confident this doesn't break anything (and it indeed doesn't break any tests that I can see) but this is definitely on the edge of my comfort with the rust type system, which is why I've created this as a draft.
ACKs for top commit:
tcharding:
ACK 3527122
apoelstra:
ACK 3527122; successfully ran local tests; nice!
Tree-SHA512: 0babdd9589d3312d4df54d77202a71dbb021e216167514c1a87f1f992f254f2b298b874411f8c7a3d56d7f730b22d104c3a78f9145715ea8df6bedad35c1ffd5
0 commit comments