From 673ca2d2fe8aca512c3b2a860727745a1b1a376a Mon Sep 17 00:00:00 2001 From: Lorenzo Maturano Date: Tue, 21 Feb 2023 14:22:44 -0300 Subject: [PATCH 1/2] changing docs and examples to use reference to slice in `derive_pub` --- bitcoin/examples/bip32.rs | 2 +- bitcoin/examples/ecdsa-psbt.rs | 2 +- bitcoin/src/bip32.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bitcoin/examples/bip32.rs b/bitcoin/examples/bip32.rs index 738d9268..7904c5f6 100644 --- a/bitcoin/examples/bip32.rs +++ b/bitcoin/examples/bip32.rs @@ -52,7 +52,7 @@ fn main() { // generate first receiving address at m/0/0 // manually creating indexes this time let zero = ChildNumber::from_normal_idx(0).unwrap(); - let public_key = xpub.derive_pub(&secp, &vec![zero, zero]).unwrap().public_key; + let public_key = xpub.derive_pub(&secp, &[zero, zero]).unwrap().public_key; let address = Address::p2wpkh(&PublicKey::new(public_key), network).unwrap(); println!("First receiving address: {}", address); } diff --git a/bitcoin/examples/ecdsa-psbt.rs b/bitcoin/examples/ecdsa-psbt.rs index 756ac8c3..8fe385d2 100644 --- a/bitcoin/examples/ecdsa-psbt.rs +++ b/bitcoin/examples/ecdsa-psbt.rs @@ -265,7 +265,7 @@ impl WatchOnly { &self, secp: &Secp256k1, ) -> Result<(PublicKey, Address, DerivationPath)> { - let path = vec![ChildNumber::from_normal_idx(1)?, ChildNumber::from_normal_idx(0)?]; + let path = [ChildNumber::from_normal_idx(1)?, ChildNumber::from_normal_idx(0)?]; let derived = self.account_0_xpub.derive_pub(secp, &path)?; let pk = derived.to_pub(); diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index 2497d4ab..1f6ee412 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -683,7 +683,7 @@ impl ExtendedPubKey { /// Attempts to derive an extended public key from a path. /// - /// The `path` argument can be both of type `DerivationPath` or `Vec`. + /// The `path` argument can be both of type `DerivationPath` or `AsRef`. pub fn derive_pub>( &self, secp: &Secp256k1, From f69363d71ad64046c7ebf94a603d6e923f66dd51 Mon Sep 17 00:00:00 2001 From: Lorenzo Maturano Date: Tue, 21 Feb 2023 16:58:22 -0300 Subject: [PATCH 2/2] adding suggested documentation for path arg --- bitcoin/src/bip32.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index 1f6ee412..0f490e4b 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -683,7 +683,7 @@ impl ExtendedPubKey { /// Attempts to derive an extended public key from a path. /// - /// The `path` argument can be both of type `DerivationPath` or `AsRef`. + /// The `path` argument can be any type implementing `AsRef`, such as `DerivationPath`, for instance. pub fn derive_pub>( &self, secp: &Secp256k1,