diff --git a/src/blockdata/utxoset.rs b/src/blockdata/utxoset.rs index 3eb357d..d26d43c 100644 --- a/src/blockdata/utxoset.rs +++ b/src/blockdata/utxoset.rs @@ -20,7 +20,7 @@ use std::cmp; use std::collections::HashMap; -use std::collections::hash::map::Iter; +use std::collections::hash_map::Iter; use std::default::Default; use std::mem; use eventual; diff --git a/src/internal_macros.rs b/src/internal_macros.rs index c5748e5..5d26ac8 100644 --- a/src/internal_macros.rs +++ b/src/internal_macros.rs @@ -165,6 +165,7 @@ macro_rules! impl_array_newtype_encodable { None => return Err(::serde::de::Error::end_of_stream_error()) }; } + v.end(); Ok($thing(ret)) } } diff --git a/src/macros.rs b/src/macros.rs index 74c5ee7..13c68f9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -92,7 +92,7 @@ macro_rules! user_enum { impl ::std::fmt::Debug for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.pad(match *self { - $($elem => $txt),* + $($name::$elem => $txt),* }) } } @@ -100,7 +100,7 @@ macro_rules! user_enum { impl ::std::fmt::Display for $name { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.pad(match *self { - $($elem => $txt),* + $($name::$elem => $txt),* }) } } diff --git a/src/network/socket.rs b/src/network/socket.rs index a3667ca..062d8a0 100644 --- a/src/network/socket.rs +++ b/src/network/socket.rs @@ -20,7 +20,7 @@ use time::now; use rand::{thread_rng, Rng}; use std::io::{self, Cursor, Write}; -use std::net::{ip, tcp}; +use std::net; use std::sync::{Arc, Mutex}; use network::constants; @@ -33,10 +33,10 @@ use network::serialize::{RawEncoder, RawDecoder}; use util::{self, propagate_err}; /// Format an IP address in the 16-byte bitcoin protocol serialization -fn ipaddr_to_bitcoin_addr(ipaddr: &ip::IpAddr) -> [u16; 8] { +fn ipaddr_to_bitcoin_addr(ipaddr: &net::IpAddr) -> [u16; 8] { match *ipaddr { - ip::IpAddr::V4(ref addr) => &addr.to_ipv6_mapped(), - ip::IpAddr::V6(ref addr) => addr + net::IpAddr::V4(ref addr) => &addr.to_ipv6_mapped(), + net::IpAddr::V6(ref addr) => addr }.segments() } @@ -44,7 +44,7 @@ fn ipaddr_to_bitcoin_addr(ipaddr: &ip::IpAddr) -> [u16; 8] { #[derive(Clone)] pub struct Socket { /// The underlying TCP socket - socket: Arc>>, + socket: Arc>>, /// Services supported by us pub services: u64, /// Our user agent @@ -73,7 +73,7 @@ impl Socket { pub fn connect(&mut self, host: &str, port: u16) -> Result<(), util::Error> { // Entirely replace the Mutex, in case it was poisoned; // this will also drop any preexisting socket that might be open - match tcp::TcpStream::connect((host, port)) { + match net::TcpStream::connect((host, port)) { Ok(s) => { self.socket = Arc::new(Mutex::new(Some(s))); Ok(()) @@ -85,7 +85,7 @@ impl Socket { } } - fn socket(&mut self) -> Result<&mut tcp::TcpStream, util::Error> { + fn socket(&mut self) -> Result<&mut net::TcpStream, util::Error> { let mut sock_lock = self.socket.lock(); match sock_lock { Err(_) => { diff --git a/src/util/patricia_tree.rs b/src/util/patricia_tree.rs index 40f8c0a..4f91634 100644 --- a/src/util/patricia_tree.rs +++ b/src/util/patricia_tree.rs @@ -364,7 +364,7 @@ impl PatriciaTree impl Debug for PatriciaTree { /// Print the entire tree - pub fn fmt<'a>(&'a self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt<'a>(&'a self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { fn recurse<'a, K:BitArray, V:Debug>(tree: &'a PatriciaTree, f: &mut fmt::Formatter, depth: usize) -> Result<(), fmt::Error> { for i in 0..tree.skip_len as usize { try!(write!(f, "{:}", if tree.skip_prefix.bit(i) { 1 } else { 0 })); @@ -394,7 +394,7 @@ impl Debug for PatriciaTree { } Ok(()) } - recurse(self, f, 0); + recurse(self, f, 0) } } diff --git a/src/wallet/bip32.rs b/src/wallet/bip32.rs index db4d374..4fbfce4 100644 --- a/src/wallet/bip32.rs +++ b/src/wallet/bip32.rs @@ -17,9 +17,10 @@ //! at https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki use std::default::Default; +use std::io::Cursor; use serde::{Serialize, Deserialize, Serializer, Deserializer}; -use crypto::cryptoutil::{read_u32_be, write_u32_be}; +use byteorder::{BigEndian, ByteOrder, ReadBytesExt}; use crypto::digest::Digest; use crypto::hmac::Hmac; use crypto::mac::Mac; @@ -167,14 +168,14 @@ impl ExtendedPrivKey { secp256k1::init(); // Note the unwrap: this is fine, we checked the SK when we created it hmac.input(&PublicKey::from_secret_key(&self.secret_key, true)[..]); - write_u32_be(&mut be_n, n); + BigEndian::write_u32(&mut be_n, n); } ChildNumber::Hardened(n) => { if n >= (1 << 31) { return Err(Error::InvalidChildNumber(i)) } // Hardened key: use only secret data to prevent public derivation hmac.input(&[0u8]); hmac.input(&self.secret_key[..]); - write_u32_be(&mut be_n, n + (1 << 31)); + BigEndian::write_u32(&mut be_n, n + (1 << 31)); } } hmac.input(&be_n); @@ -244,7 +245,7 @@ impl ExtendedPubKey { let mut hmac = Hmac::new(Sha512::new(), &self.chain_code[..]); hmac.input(&self.public_key[..]); let mut be_n = [0; 32]; - write_u32_be(&mut be_n, n); + BigEndian::write_u32(&mut be_n, n); hmac.input(&be_n); let mut result = [0; 64]; @@ -300,10 +301,10 @@ impl ToBase58 for ExtendedPrivKey { let mut be_n = [0; 32]; match self.child_number { ChildNumber::Hardened(n) => { - write_u32_be(&mut be_n, n + (1 << 31)); + BigEndian::write_u32(&mut be_n, n + (1 << 31)); } ChildNumber::Normal(n) => { - write_u32_be(&mut be_n, n); + BigEndian::write_u32(&mut be_n, n); } } ret.push_all(&be_n); @@ -320,7 +321,7 @@ impl FromBase58 for ExtendedPrivKey { return Err(base58::Error::InvalidLength(data.len())); } - let cn_int = read_u32_be(&data[9..13]); + let cn_int = Cursor::new(&data[9..13]).read_u32::().unwrap(); let child_number = if cn_int < (1 << 31) { ChildNumber::Normal(cn_int) } else { ChildNumber::Hardened(cn_int - (1 << 31)) }; @@ -354,10 +355,10 @@ impl ToBase58 for ExtendedPubKey { let mut be_n = [0; 32]; match self.child_number { ChildNumber::Hardened(n) => { - write_u32_be(&mut be_n, n + (1 << 31)); + BigEndian::write_u32(&mut be_n, n + (1 << 31)); } ChildNumber::Normal(n) => { - write_u32_be(&mut be_n, n); + BigEndian::write_u32(&mut be_n, n); } } ret.push_all(&be_n); @@ -373,7 +374,7 @@ impl FromBase58 for ExtendedPubKey { return Err(base58::Error::InvalidLength(data.len())); } - let cn_int = read_u32_be(&data[9..13]); + let cn_int = Cursor::new(&data[9..13]).read_u32::().unwrap(); let child_number = if cn_int < (1 << 31) { ChildNumber::Normal(cn_int) } else { ChildNumber::Hardened(cn_int - (1 << 31)) }; diff --git a/src/wallet/wallet.rs b/src/wallet/wallet.rs index 940a1f2..bed2e0b 100644 --- a/src/wallet/wallet.rs +++ b/src/wallet/wallet.rs @@ -173,14 +173,14 @@ impl Wallet { let index = match self.index { Some(ref i) => i, None => return Err(Error::NoAddressIndex) }; let (mut i, master) = match chain { - Internal => (account.internal_next, - try!(ExtendedPrivKey::from_path( - &self.master, - account.internal_path.as_slice()).map_err(Error::Bip32Error))), - External => (account.external_next, - try!(ExtendedPrivKey::from_path( - &self.master, - account.external_path.as_slice()).map_err(Error::Bip32Error))), + AccountChain::Internal => (account.internal_next, + try!(ExtendedPrivKey::from_path( + &self.master, + account.internal_path.as_slice()).map_err(Error::Bip32Error))), + AccountChain::External => (account.external_next, + try!(ExtendedPrivKey::from_path( + &self.master, + account.external_path.as_slice()).map_err(Error::Bip32Error))), }; // Scan for next admissible address @@ -197,11 +197,11 @@ impl Wallet { } match chain { - Internal => { + AccountChain::Internal => { account.internal_used.push(Normal(i)); account.internal_next = i + 1; } - External => { + AccountChain::External => { account.external_used.push(Normal(i)); account.external_next = i + 1; }