From 38f8132067bad2ea83a5a0bd956d266cf3b6e5b9 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Thu, 28 Aug 2014 11:13:33 -0700 Subject: [PATCH] Fix for upstream --- src/util/patricia_tree.rs | 2 +- src/wallet/bip32.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/util/patricia_tree.rs b/src/util/patricia_tree.rs index 95e2bae..e1878be 100644 --- a/src/util/patricia_tree.rs +++ b/src/util/patricia_tree.rs @@ -411,7 +411,7 @@ impl, E, K:ConsensusDecodable, V:ConsensusDecodable { +pub struct Items<'tree, K: 'tree, V: 'tree> { started: bool, node: Option<&'tree PatriciaTree>, parents: Vec<&'tree PatriciaTree> diff --git a/src/wallet/bip32.rs b/src/wallet/bip32.rs index 1a31515..6df4ac4 100644 --- a/src/wallet/bip32.rs +++ b/src/wallet/bip32.rs @@ -126,8 +126,8 @@ impl ExtendedPrivKey { if n >= (1 << 31) { return Err(InvalidChildNumber(i)) } // Non-hardened key: compute public data and use that secp256k1::init(); - // Unsafety just because I have to call the init() function - hmac.input(unsafe { PublicKey::from_secret_key(&self.secret_key, true).as_slice() }); + // Note the unwrap: this is fine, we checked the SK when we created it + hmac.input(PublicKey::from_secret_key(&self.secret_key, true).as_slice()); u64_to_be_bytes(n as u64, 4, |raw| hmac.input(raw)); } Hardened(n) => { @@ -185,8 +185,7 @@ impl ExtendedPubKey { depth: sk.depth, parent_fingerprint: sk.parent_fingerprint, child_number: sk.child_number, - // Unsafety because we needed to run `init` above first - public_key: unsafe { PublicKey::from_secret_key(&sk.secret_key, true) }, + public_key: PublicKey::from_secret_key(&sk.secret_key, true), chain_code: sk.chain_code } }