Improve `Xpriv::derive_xpriv` and `Xpub::derive_xpub` ergonomics

This change enables references to slices, arrays, and Vecs to be passed
to derive methods.
This commit is contained in:
Daniel Roberts 2025-06-15 23:14:26 -05:00
parent 732a83c3a9
commit 9d4381c8fe
1 changed files with 4 additions and 4 deletions

View File

@ -756,7 +756,7 @@ impl Xpriv {
pub fn derive_priv<C: secp256k1::Signing, P: AsRef<[ChildNumber]>>( pub fn derive_priv<C: secp256k1::Signing, P: AsRef<[ChildNumber]>>(
&self, &self,
secp: &Secp256k1<C>, secp: &Secp256k1<C>,
path: &P, path: P,
) -> Result<Xpriv, DerivationError> { ) -> Result<Xpriv, DerivationError> {
self.derive_xpriv(secp, path) self.derive_xpriv(secp, path)
} }
@ -767,7 +767,7 @@ impl Xpriv {
pub fn derive_xpriv<C: secp256k1::Signing, P: AsRef<[ChildNumber]>>( pub fn derive_xpriv<C: secp256k1::Signing, P: AsRef<[ChildNumber]>>(
&self, &self,
secp: &Secp256k1<C>, secp: &Secp256k1<C>,
path: &P, path: P,
) -> Result<Xpriv, DerivationError> { ) -> Result<Xpriv, DerivationError> {
let mut sk: Xpriv = *self; let mut sk: Xpriv = *self;
for cnum in path.as_ref() { for cnum in path.as_ref() {
@ -910,7 +910,7 @@ impl Xpub {
pub fn derive_pub<C: secp256k1::Verification, P: AsRef<[ChildNumber]>>( pub fn derive_pub<C: secp256k1::Verification, P: AsRef<[ChildNumber]>>(
&self, &self,
secp: &Secp256k1<C>, secp: &Secp256k1<C>,
path: &P, path: P,
) -> Result<Xpub, DerivationError> { ) -> Result<Xpub, DerivationError> {
self.derive_xpub(secp, path) self.derive_xpub(secp, path)
} }
@ -921,7 +921,7 @@ impl Xpub {
pub fn derive_xpub<C: secp256k1::Verification, P: AsRef<[ChildNumber]>>( pub fn derive_xpub<C: secp256k1::Verification, P: AsRef<[ChildNumber]>>(
&self, &self,
secp: &Secp256k1<C>, secp: &Secp256k1<C>,
path: &P, path: P,
) -> Result<Xpub, DerivationError> { ) -> Result<Xpub, DerivationError> {
let mut pk: Xpub = *self; let mut pk: Xpub = *self;
for cnum in path.as_ref() { for cnum in path.as_ref() {