changing docs and examples to use reference to slice in `derive_pub`

This commit is contained in:
Lorenzo Maturano 2023-02-21 14:22:44 -03:00
parent 483605add2
commit 673ca2d2fe
3 changed files with 3 additions and 3 deletions

View File

@ -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);
}

View File

@ -265,7 +265,7 @@ impl WatchOnly {
&self,
secp: &Secp256k1<C>,
) -> 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();

View File

@ -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<ChildNumber>`.
/// The `path` argument can be both of type `DerivationPath` or `AsRef<ChildNumber>`.
pub fn derive_pub<C: secp256k1::Verification, P: AsRef<[ChildNumber]>>(
&self,
secp: &Secp256k1<C>,