Rename bitcoin-secp256k1-rs to secp256k1
This commit is contained in:
parent
c3377032f8
commit
2101e4a56d
|
@ -11,6 +11,6 @@ path = "src/lib.rs"
|
||||||
[dependencies.rust-crypto]
|
[dependencies.rust-crypto]
|
||||||
git = "https://github.com/DaGenix/rust-crypto.git"
|
git = "https://github.com/DaGenix/rust-crypto.git"
|
||||||
|
|
||||||
[dependencies.bitcoin-secp256k1-rs]
|
[dependencies.secp256k1]
|
||||||
git = "https://github.com/apoelstra/bitcoin-secp256k1-rs.git"
|
git = "https://github.com/apoelstra/bitcoin-secp256k1-rs.git"
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
|
|
||||||
use std::num::{Zero, from_u64};
|
use std::num::{Zero, from_u64};
|
||||||
|
|
||||||
use util::error::{BitcoinResult, SpvBadTarget, SpvBadProofOfWork};
|
use util::error::{BitcoinResult};
|
||||||
|
use util::error::BitcoinError::{SpvBadTarget, SpvBadProofOfWork};
|
||||||
use util::hash::Sha256dHash;
|
use util::hash::Sha256dHash;
|
||||||
use util::uint::Uint256;
|
use util::uint::Uint256;
|
||||||
use network::encodable::{ConsensusEncodable, VarInt};
|
use network::encodable::{ConsensusEncodable, VarInt};
|
||||||
|
|
|
@ -29,11 +29,12 @@ use blockdata::block::{Block, BlockHeader};
|
||||||
use blockdata::transaction::Transaction;
|
use blockdata::transaction::Transaction;
|
||||||
use blockdata::constants::{DIFFCHANGE_INTERVAL, DIFFCHANGE_TIMESPAN,
|
use blockdata::constants::{DIFFCHANGE_INTERVAL, DIFFCHANGE_TIMESPAN,
|
||||||
TARGET_BLOCK_SPACING, max_target, genesis_block};
|
TARGET_BLOCK_SPACING, max_target, genesis_block};
|
||||||
use network::constants::{Network, BitcoinTestnet};
|
use network::constants::Network::{self, BitcoinTestnet};
|
||||||
use network::encodable::{ConsensusDecodable, ConsensusEncodable};
|
use network::encodable::{ConsensusDecodable, ConsensusEncodable};
|
||||||
use network::serialize::{BitcoinHash, SimpleDecoder, SimpleEncoder};
|
use network::serialize::{BitcoinHash, SimpleDecoder, SimpleEncoder};
|
||||||
use util::BitArray;
|
use util::BitArray;
|
||||||
use util::error::{BitcoinResult, BlockNotFound, DuplicateHash, PrevHashNotFound};
|
use util::error::BitcoinResult;
|
||||||
|
use util::error::BitcoinError::{BlockNotFound, DuplicateHash, PrevHashNotFound};
|
||||||
use util::uint::Uint256;
|
use util::uint::Uint256;
|
||||||
use util::hash::Sha256dHash;
|
use util::hash::Sha256dHash;
|
||||||
use util::patricia_tree::PatriciaTree;
|
use util::patricia_tree::PatriciaTree;
|
||||||
|
@ -613,7 +614,7 @@ mod tests {
|
||||||
|
|
||||||
use blockdata::blockchain::Blockchain;
|
use blockdata::blockchain::Blockchain;
|
||||||
use blockdata::constants::genesis_block;
|
use blockdata::constants::genesis_block;
|
||||||
use network::constants::Bitcoin;
|
use network::constants::Network::Bitcoin;
|
||||||
use network::serialize::{BitcoinHash, deserialize, serialize};
|
use network::serialize::{BitcoinHash, deserialize, serialize};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -26,7 +26,7 @@ use blockdata::opcodes;
|
||||||
use blockdata::script::Script;
|
use blockdata::script::Script;
|
||||||
use blockdata::transaction::{Transaction, TxOut, TxIn};
|
use blockdata::transaction::{Transaction, TxOut, TxIn};
|
||||||
use blockdata::block::{Block, BlockHeader};
|
use blockdata::block::{Block, BlockHeader};
|
||||||
use network::constants::{Network, Bitcoin, BitcoinTestnet};
|
use network::constants::Network::{Bitcoin, BitcoinTestnet};
|
||||||
use util::misc::hex_bytes;
|
use util::misc::hex_bytes;
|
||||||
use util::hash::MerkleRoot;
|
use util::hash::MerkleRoot;
|
||||||
use util::uint::Uint256;
|
use util::uint::Uint256;
|
||||||
|
@ -123,7 +123,7 @@ mod test {
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use serialize::hex::FromHex;
|
use serialize::hex::FromHex;
|
||||||
|
|
||||||
use network::constants::{Bitcoin, BitcoinTestnet};
|
use network::constants::Network::{Bitcoin, BitcoinTestnet};
|
||||||
use network::serialize::{BitcoinHash, serialize};
|
use network::serialize::{BitcoinHash, serialize};
|
||||||
use blockdata::constants::{genesis_block, bitcoin_genesis_tx};
|
use blockdata::constants::{genesis_block, bitcoin_genesis_tx};
|
||||||
use blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};
|
use blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};
|
||||||
|
|
|
@ -2453,7 +2453,7 @@ mod test {
|
||||||
|
|
||||||
use super::{Script, build_scriptint, read_scriptint, read_scriptbool};
|
use super::{Script, build_scriptint, read_scriptint, read_scriptbool};
|
||||||
use super::{EqualVerifyFailed, NoTransaction, PopEmptyStack};
|
use super::{EqualVerifyFailed, NoTransaction, PopEmptyStack};
|
||||||
use super::Owned;
|
use super::MaybeOwned::Owned;
|
||||||
|
|
||||||
use network::serialize::{deserialize, serialize};
|
use network::serialize::{deserialize, serialize};
|
||||||
use blockdata::opcodes;
|
use blockdata::opcodes;
|
||||||
|
|
|
@ -27,7 +27,7 @@ use std::os::num_cpus;
|
||||||
use std::sync::Future;
|
use std::sync::Future;
|
||||||
|
|
||||||
use blockdata::transaction::{Transaction, TxOut};
|
use blockdata::transaction::{Transaction, TxOut};
|
||||||
use blockdata::transaction::{TransactionError, InputNotFound};
|
use blockdata::transaction::TransactionError::{self, InputNotFound};
|
||||||
use blockdata::constants::genesis_block;
|
use blockdata::constants::genesis_block;
|
||||||
use blockdata::block::Block;
|
use blockdata::block::Block;
|
||||||
use network::constants::Network;
|
use network::constants::Network;
|
||||||
|
@ -437,7 +437,7 @@ mod tests {
|
||||||
use super::{UtxoSet, TxoValidation};
|
use super::{UtxoSet, TxoValidation};
|
||||||
|
|
||||||
use blockdata::block::Block;
|
use blockdata::block::Block;
|
||||||
use network::constants::Bitcoin;
|
use network::constants::Network::Bitcoin;
|
||||||
use network::serialize::{BitcoinHash, deserialize, serialize};
|
use network::serialize::{BitcoinHash, deserialize, serialize};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -51,7 +51,7 @@ extern crate serialize;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
extern crate "bitcoin-secp256k1-rs" as secp256k1;
|
extern crate secp256k1;
|
||||||
extern crate crypto;
|
extern crate crypto;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl<D:SimpleDecoder<E>, E> ConsensusDecodable<D, E> for Network {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{Network, Bitcoin, BitcoinTestnet};
|
use super::Network::{self, Bitcoin, BitcoinTestnet};
|
||||||
|
|
||||||
use network::serialize::{deserialize, serialize};
|
use network::serialize::{deserialize, serialize};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
use std::io::{IoResult, standard_error, ConnectionFailed};
|
use std::io::{IoResult, standard_error, ConnectionFailed};
|
||||||
|
|
||||||
use network::constants::Network;
|
use network::constants::Network;
|
||||||
use network::message::{self, SocketResponse, MessageReceived, Verack};
|
use network::message;
|
||||||
|
use network::message::SocketResponse::{self, MessageReceived};
|
||||||
|
use network::message::NetworkMessage::Verack;
|
||||||
use network::socket::Socket;
|
use network::socket::Socket;
|
||||||
|
|
||||||
/// A message which can be sent on the Bitcoin network
|
/// A message which can be sent on the Bitcoin network
|
||||||
|
|
|
@ -28,7 +28,8 @@ use std::sync::{Arc, Mutex};
|
||||||
use network::constants;
|
use network::constants;
|
||||||
use network::address::Address;
|
use network::address::Address;
|
||||||
use network::encodable::{ConsensusEncodable, ConsensusDecodable};
|
use network::encodable::{ConsensusEncodable, ConsensusDecodable};
|
||||||
use network::message::{RawNetworkMessage, NetworkMessage, Version};
|
use network::message::{RawNetworkMessage, NetworkMessage};
|
||||||
|
use network::message::NetworkMessage::Version;
|
||||||
use network::message_network::VersionMessage;
|
use network::message_network::VersionMessage;
|
||||||
use network::serialize::{RawEncoder, RawDecoder};
|
use network::serialize::{RawEncoder, RawDecoder};
|
||||||
use util::misc::prepend_err;
|
use util::misc::prepend_err;
|
||||||
|
|
|
@ -529,8 +529,8 @@ mod tests {
|
||||||
|
|
||||||
use network::serialize::{deserialize, serialize};
|
use network::serialize::{deserialize, serialize};
|
||||||
use util::hash::Sha256dHash;
|
use util::hash::Sha256dHash;
|
||||||
use util::usize::Uint128;
|
use util::uint::Uint128;
|
||||||
use util::usize::Uint256;
|
use util::uint::Uint256;
|
||||||
use util::patricia_tree::PatriciaTree;
|
use util::patricia_tree::PatriciaTree;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
use alloc::heap::{allocate, reallocate, deallocate};
|
use alloc::heap::{allocate, reallocate, deallocate};
|
||||||
use std::raw;
|
use std::raw;
|
||||||
use std::slice::{Items, MutItems};
|
use std::slice::{Iter, MutIter};
|
||||||
use std::{fmt, mem, ptr};
|
use std::{fmt, mem, ptr};
|
||||||
use std::u32;
|
use std::u32;
|
||||||
|
|
||||||
|
@ -63,13 +63,13 @@ impl<T> ThinVec<T> {
|
||||||
|
|
||||||
/// Iterator over elements of the vector
|
/// Iterator over elements of the vector
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter<'a>(&'a self) -> Items<'a, T> {
|
pub fn iter<'a>(&'a self) -> Iter<'a, T> {
|
||||||
self.as_slice().iter()
|
self.as_slice().iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mutable iterator over elements of the vector
|
/// Mutable iterator over elements of the vector
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> {
|
pub fn iter_mut<'a>(&'a mut self) -> MutIter<'a, T> {
|
||||||
self.as_mut_slice().iter_mut()
|
self.as_mut_slice().iter_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,10 @@ use crypto::sha2::Sha256;
|
||||||
|
|
||||||
use blockdata::script::Script;
|
use blockdata::script::Script;
|
||||||
use blockdata::opcodes::all;
|
use blockdata::opcodes::all;
|
||||||
use network::constants::{Network, Bitcoin, BitcoinTestnet};
|
use network::constants::Network::{self, Bitcoin, BitcoinTestnet};
|
||||||
use util::hash::Ripemd160Hash;
|
use util::hash::Ripemd160Hash;
|
||||||
use util::base58::{Base58Error,
|
use util::base58::Base58Error::{self, InvalidLength, InvalidVersion};
|
||||||
InvalidLength, InvalidVersion,
|
use util::base58::{FromBase58, ToBase58};
|
||||||
FromBase58, ToBase58};
|
|
||||||
|
|
||||||
#[deriving(Clone, PartialEq, Eq)]
|
#[deriving(Clone, PartialEq, Eq)]
|
||||||
/// A Bitcoin address
|
/// A Bitcoin address
|
||||||
|
@ -130,7 +129,7 @@ mod tests {
|
||||||
|
|
||||||
use secp256k1::Secp256k1;
|
use secp256k1::Secp256k1;
|
||||||
|
|
||||||
use network::constants::Bitcoin;
|
use network::constants::Network::Bitcoin;
|
||||||
use util::hash::Ripemd160Hash;
|
use util::hash::Ripemd160Hash;
|
||||||
use util::base58::{FromBase58, ToBase58};
|
use util::base58::{FromBase58, ToBase58};
|
||||||
use super::Address;
|
use super::Address;
|
||||||
|
|
|
@ -23,7 +23,8 @@ use collections::hash::sip::hash_with_keys;
|
||||||
|
|
||||||
use secp256k1::key::SecretKey;
|
use secp256k1::key::SecretKey;
|
||||||
|
|
||||||
use blockdata::transaction::{TxOut, PayToPubkeyHash};
|
use blockdata::transaction::TxOut;
|
||||||
|
use blockdata::transaction::ScriptPubkeyTemplate::PayToPubkeyHash;
|
||||||
use blockdata::utxoset::UtxoSet;
|
use blockdata::utxoset::UtxoSet;
|
||||||
use blockdata::script::Script;
|
use blockdata::script::Script;
|
||||||
use network::constants::Network;
|
use network::constants::Network;
|
||||||
|
|
|
@ -29,10 +29,10 @@ use crypto::sha2::Sha512;
|
||||||
use secp256k1::key::{PublicKey, SecretKey};
|
use secp256k1::key::{PublicKey, SecretKey};
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
|
|
||||||
use network::constants::{Network, Bitcoin, BitcoinTestnet};
|
use network::constants::Network::{self, Bitcoin, BitcoinTestnet};
|
||||||
use util::base58::{Base58Error,
|
use util::base58::Base58Error::{self, InvalidLength, InvalidVersion,
|
||||||
InvalidLength, InvalidVersion, OtherBase58Error,
|
OtherBase58Error};
|
||||||
FromBase58, ToBase58};
|
use util::base58::{FromBase58, ToBase58};
|
||||||
|
|
||||||
/// A chain code
|
/// A chain code
|
||||||
pub struct ChainCode([u8; 32]);
|
pub struct ChainCode([u8; 32]);
|
||||||
|
@ -96,8 +96,8 @@ pub enum ChildNumber {
|
||||||
impl<S: Encoder<E>, E> Encodable<S, E> for ChildNumber {
|
impl<S: Encoder<E>, E> Encodable<S, E> for ChildNumber {
|
||||||
fn encode(&self, s: &mut S) -> Result<(), E> {
|
fn encode(&self, s: &mut S) -> Result<(), E> {
|
||||||
match *self {
|
match *self {
|
||||||
Hardened(n) => (n + (1 << 31)).encode(s),
|
ChildNumber::Hardened(n) => (n + (1 << 31)).encode(s),
|
||||||
Normal(n) => n.encode(s)
|
ChildNumber::Normal(n) => n.encode(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,9 +106,9 @@ impl<D: Decoder<E>, E> Decodable<D, E> for ChildNumber {
|
||||||
fn decode(d: &mut D) -> Result<ChildNumber, E> {
|
fn decode(d: &mut D) -> Result<ChildNumber, E> {
|
||||||
let n: u32 = try!(Decodable::decode(d));
|
let n: u32 = try!(Decodable::decode(d));
|
||||||
if n < (1 << 31) {
|
if n < (1 << 31) {
|
||||||
Ok(Normal(n))
|
Ok(ChildNumber::Normal(n))
|
||||||
} else {
|
} else {
|
||||||
Ok(Hardened(n - (1 << 31)))
|
Ok(ChildNumber::Hardened(n - (1 << 31)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ impl ExtendedPrivKey {
|
||||||
network: network,
|
network: network,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
parent_fingerprint: Default::default(),
|
parent_fingerprint: Default::default(),
|
||||||
child_number: Normal(0),
|
child_number: ChildNumber::Normal(0),
|
||||||
secret_key: try!(SecretKey::from_slice(result.slice_to(32)).map_err(EcdsaError)),
|
secret_key: try!(SecretKey::from_slice(result.slice_to(32)).map_err(EcdsaError)),
|
||||||
chain_code: ChainCode::from_slice(result.slice_from(32))
|
chain_code: ChainCode::from_slice(result.slice_from(32))
|
||||||
})
|
})
|
||||||
|
@ -159,7 +159,7 @@ impl ExtendedPrivKey {
|
||||||
let mut result = [0; 64];
|
let mut result = [0; 64];
|
||||||
let mut hmac = Hmac::new(Sha512::new(), self.chain_code.as_slice());
|
let mut hmac = Hmac::new(Sha512::new(), self.chain_code.as_slice());
|
||||||
match i {
|
match i {
|
||||||
Normal(n) => {
|
ChildNumber::Normal(n) => {
|
||||||
if n >= (1 << 31) { return Err(InvalidChildNumber(i)) }
|
if n >= (1 << 31) { return Err(InvalidChildNumber(i)) }
|
||||||
// Non-hardened key: compute public data and use that
|
// Non-hardened key: compute public data and use that
|
||||||
secp256k1::init();
|
secp256k1::init();
|
||||||
|
@ -167,7 +167,7 @@ impl ExtendedPrivKey {
|
||||||
hmac.input(PublicKey::from_secret_key(&self.secret_key, true).as_slice());
|
hmac.input(PublicKey::from_secret_key(&self.secret_key, true).as_slice());
|
||||||
u64_to_be_bytes(n as u64, 4, |raw| hmac.input(raw));
|
u64_to_be_bytes(n as u64, 4, |raw| hmac.input(raw));
|
||||||
}
|
}
|
||||||
Hardened(n) => {
|
ChildNumber::Hardened(n) => {
|
||||||
if n >= (1 << 31) { return Err(InvalidChildNumber(i)) }
|
if n >= (1 << 31) { return Err(InvalidChildNumber(i)) }
|
||||||
// Hardened key: use only secret data to prevent public derivation
|
// Hardened key: use only secret data to prevent public derivation
|
||||||
hmac.input([0]);
|
hmac.input([0]);
|
||||||
|
@ -230,14 +230,14 @@ impl ExtendedPubKey {
|
||||||
/// Public->Public child key derivation
|
/// Public->Public child key derivation
|
||||||
pub fn ckd_pub(&self, i: ChildNumber) -> Result<ExtendedPubKey, Error> {
|
pub fn ckd_pub(&self, i: ChildNumber) -> Result<ExtendedPubKey, Error> {
|
||||||
match i {
|
match i {
|
||||||
Hardened(n) => {
|
ChildNumber::Hardened(n) => {
|
||||||
if n >= (1 << 31) {
|
if n >= (1 << 31) {
|
||||||
Err(InvalidChildNumber(i))
|
Err(InvalidChildNumber(i))
|
||||||
} else {
|
} else {
|
||||||
Err(CannotDeriveFromHardenedKey)
|
Err(CannotDeriveFromHardenedKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Normal(n) => {
|
ChildNumber::Normal(n) => {
|
||||||
let mut hmac = Hmac::new(Sha512::new(), self.chain_code.as_slice());
|
let mut hmac = Hmac::new(Sha512::new(), self.chain_code.as_slice());
|
||||||
hmac.input(self.public_key.as_slice());
|
hmac.input(self.public_key.as_slice());
|
||||||
u64_to_be_bytes(n as u64, 4, |raw| hmac.input(raw));
|
u64_to_be_bytes(n as u64, 4, |raw| hmac.input(raw));
|
||||||
|
@ -293,10 +293,10 @@ impl ToBase58 for ExtendedPrivKey {
|
||||||
ret.push(self.depth as u8);
|
ret.push(self.depth as u8);
|
||||||
ret.push_all(self.parent_fingerprint.as_slice());
|
ret.push_all(self.parent_fingerprint.as_slice());
|
||||||
match self.child_number {
|
match self.child_number {
|
||||||
Hardened(n) => {
|
ChildNumber::Hardened(n) => {
|
||||||
u64_to_be_bytes(n as u64 + (1 << 31), 4, |raw| ret.push_all(raw));
|
u64_to_be_bytes(n as u64 + (1 << 31), 4, |raw| ret.push_all(raw));
|
||||||
}
|
}
|
||||||
Normal(n) => {
|
ChildNumber::Normal(n) => {
|
||||||
u64_to_be_bytes(n as u64, 4, |raw| ret.push_all(raw));
|
u64_to_be_bytes(n as u64, 4, |raw| ret.push_all(raw));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,8 +314,8 @@ impl FromBase58 for ExtendedPrivKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
let cn_int = u64_from_be_bytes(data.as_slice(), 9, 4) as u32;
|
let cn_int = u64_from_be_bytes(data.as_slice(), 9, 4) as u32;
|
||||||
let child_number = if cn_int < (1 << 31) { Normal(cn_int) }
|
let child_number = if cn_int < (1 << 31) { ChildNumber::Normal(cn_int) }
|
||||||
else { Hardened(cn_int - (1 << 31)) };
|
else { ChildNumber::Hardened(cn_int - (1 << 31)) };
|
||||||
|
|
||||||
Ok(ExtendedPrivKey {
|
Ok(ExtendedPrivKey {
|
||||||
network: match data.slice_to(4) {
|
network: match data.slice_to(4) {
|
||||||
|
@ -345,10 +345,10 @@ impl ToBase58 for ExtendedPubKey {
|
||||||
ret.push(self.depth as u8);
|
ret.push(self.depth as u8);
|
||||||
ret.push_all(self.parent_fingerprint.as_slice());
|
ret.push_all(self.parent_fingerprint.as_slice());
|
||||||
match self.child_number {
|
match self.child_number {
|
||||||
Hardened(n) => {
|
ChildNumber::Hardened(n) => {
|
||||||
u64_to_be_bytes(n as u64 + (1 << 31), 4, |raw| ret.push_all(raw));
|
u64_to_be_bytes(n as u64 + (1 << 31), 4, |raw| ret.push_all(raw));
|
||||||
}
|
}
|
||||||
Normal(n) => {
|
ChildNumber::Normal(n) => {
|
||||||
u64_to_be_bytes(n as u64, 4, |raw| ret.push_all(raw));
|
u64_to_be_bytes(n as u64, 4, |raw| ret.push_all(raw));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,8 +365,8 @@ impl FromBase58 for ExtendedPubKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
let cn_int = u64_from_be_bytes(data.as_slice(), 9, 4) as u32;
|
let cn_int = u64_from_be_bytes(data.as_slice(), 9, 4) as u32;
|
||||||
let child_number = if cn_int < (1 << 31) { Normal(cn_int) }
|
let child_number = if cn_int < (1 << 31) { ChildNumber::Normal(cn_int) }
|
||||||
else { Hardened(cn_int - (1 << 31)) };
|
else { ChildNumber::Hardened(cn_int - (1 << 31)) };
|
||||||
|
|
||||||
Ok(ExtendedPubKey {
|
Ok(ExtendedPubKey {
|
||||||
network: match data.slice_to(4) {
|
network: match data.slice_to(4) {
|
||||||
|
@ -390,10 +390,11 @@ mod tests {
|
||||||
use serialize::hex::FromHex;
|
use serialize::hex::FromHex;
|
||||||
use test::{Bencher, black_box};
|
use test::{Bencher, black_box};
|
||||||
|
|
||||||
use network::constants::{Network, Bitcoin};
|
use network::constants::Network::{self, Bitcoin};
|
||||||
use util::base58::{FromBase58, ToBase58};
|
use util::base58::{FromBase58, ToBase58};
|
||||||
|
|
||||||
use super::{ChildNumber, ExtendedPrivKey, ExtendedPubKey, Hardened, Normal};
|
use super::{ChildNumber, ExtendedPrivKey, ExtendedPubKey};
|
||||||
|
use super::ChildNumber::{Hardened, Normal};
|
||||||
|
|
||||||
fn test_path(network: Network,
|
fn test_path(network: Network,
|
||||||
seed: &[u8],
|
seed: &[u8],
|
||||||
|
|
|
@ -25,7 +25,8 @@ use secp256k1::key::PublicKey;
|
||||||
|
|
||||||
use blockdata::utxoset::UtxoSet;
|
use blockdata::utxoset::UtxoSet;
|
||||||
use network::constants::Network;
|
use network::constants::Network;
|
||||||
use wallet::bip32::{self, ChildNumber, ExtendedPrivKey, ExtendedPubKey, Normal, Hardened};
|
use wallet::bip32::{self, ChildNumber, ExtendedPrivKey, ExtendedPubKey};
|
||||||
|
use wallet::bip32::ChildNumber::{Normal, Hardened};
|
||||||
use wallet::address::Address;
|
use wallet::address::Address;
|
||||||
use wallet::address_index::AddressIndex;
|
use wallet::address_index::AddressIndex;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue