]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Update to rust-bitcoin v0.15
authorSteven Roose <steven@stevenroose.org>
Sun, 11 Nov 2018 22:40:01 +0000 (22:40 +0000)
committerSteven Roose <steven@stevenroose.org>
Wed, 14 Nov 2018 11:43:54 +0000 (11:43 +0000)
Cargo.toml
fuzz/Cargo.toml
fuzz/fuzz_targets/full_stack_target.rs
src/chain/chaininterface.rs
src/chain/transaction.rs
src/ln/channel.rs
src/ln/channelmanager.rs
src/ln/channelmonitor.rs

index 052f2fc03d2d98b6a8a99687e161e92a7f60080d..9ecd10fb2bede052abc6d0ddf2f2683e1c6b543f 100644 (file)
@@ -23,7 +23,7 @@ max_level_info = []
 max_level_debug = []
 
 [dependencies]
-bitcoin = "0.14"
+bitcoin = "0.15"
 rust-crypto = "0.2"
 rand = "0.4"
 secp256k1 = "0.11"
@@ -32,7 +32,7 @@ secp256k1 = "0.11"
 cc = "1.0"
 
 [dev-dependencies.bitcoin]
-version = "0.14"
+version = "0.15"
 features = ["bitcoinconsensus"]
 
 [dev-dependencies]
index a457df1a790eb0b628708263215a337ff273ae87..ecf3809c59b3ec8cc88ca349b3ad1eff3b9cb7b0 100644 (file)
@@ -18,7 +18,7 @@ honggfuzz_fuzz = ["honggfuzz"]
 [dependencies]
 afl = { version = "0.4", optional = true }
 lightning = { path = "..", features = ["fuzztarget"] }
-bitcoin = { version = "0.14", features = ["fuzztarget"] }
+bitcoin = { version = "0.15", features = ["fuzztarget"] }
 hex = "0.3"
 honggfuzz = { version = "0.5", optional = true }
 rust-crypto = "0.2"
index f943945531e834a854ebca0927288c57e46c108b..3b277906b0bea91d9bac2c89c194b5b147e952ac 100644 (file)
@@ -7,9 +7,9 @@ use bitcoin::blockdata::block::BlockHeader;
 use bitcoin::blockdata::transaction::{Transaction, TxOut};
 use bitcoin::blockdata::script::{Builder, Script};
 use bitcoin::blockdata::opcodes;
+use bitcoin::consensus::encode::{deserialize, serialize};
 use bitcoin::network::constants::Network;
-use bitcoin::network::serialize::{deserialize, serialize, BitcoinHash};
-use bitcoin::util::hash::{Sha256dHash, Hash160};
+use bitcoin::util::hash::{BitcoinHash, Sha256dHash, Hash160};
 
 use crypto::digest::Digest;
 
@@ -168,7 +168,7 @@ impl<'a> MoneyLossDetector<'a> {
                let mut txn = Vec::with_capacity(all_txn.len());
                let mut txn_idxs = Vec::with_capacity(all_txn.len());
                for (idx, tx) in all_txn.iter().enumerate() {
-                       let txid = Sha256dHash::from_data(&serialize(tx).unwrap()[..]);
+                       let txid = tx.txid();
                        match self.txids_confirmed.entry(txid) {
                                hash_map::Entry::Vacant(e) => {
                                        e.insert(self.height);
@@ -432,7 +432,7 @@ pub fn do_test(data: &[u8], logger: &Arc<Logger>) {
                                                        value: funding_generation.1, script_pubkey: funding_generation.2,
                                                }] };
                                        let funding_output = 'search_loop: loop {
-                                               let funding_txid = Sha256dHash::from_data(&serialize(&tx).unwrap()[..]);
+                                               let funding_txid = tx.txid();
                                                if let None = loss_detector.txids_confirmed.get(&funding_txid) {
                                                        let outpoint = OutPoint::new(funding_txid, 0);
                                                        for chan in channelmanager.list_channels() {
index 9999177de966e15a0b9ebb4c90b9f3a590c743b5..7b5e0d0749832a7cf2ffcfcd560156d085fd53f7 100644 (file)
@@ -8,9 +8,8 @@ use bitcoin::blockdata::block::{Block, BlockHeader};
 use bitcoin::blockdata::transaction::Transaction;
 use bitcoin::blockdata::script::Script;
 use bitcoin::blockdata::constants::genesis_block;
-use bitcoin::util::hash::Sha256dHash;
+use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
 use bitcoin::network::constants::Network;
-use bitcoin::network::serialize::BitcoinHash;
 
 use util::logger::Logger;
 
index e8ebae7092556286e4a6f22a8bfde7baa0ef9b30..a9b314dd08e4eec7ddb7a5bd6f94d43816191217 100644 (file)
@@ -44,13 +44,13 @@ mod tests {
        use chain::transaction::OutPoint;
 
        use bitcoin::blockdata::transaction::Transaction;
-       use bitcoin::network::serialize;
+       use bitcoin::consensus::encode;
 
        use hex;
 
        #[test]
        fn test_channel_id_calculation() {
-               let tx: Transaction = serialize::deserialize(&hex::decode("020000000001010e0adef48412e4361325ac1c6e36411299ab09d4f083b9d8ddb55fbc06e1b0c00000000000feffffff0220a1070000000000220020f81d95e040bd0a493e38bae27bff52fe2bb58b93b293eb579c01c31b05c5af1dc072cfee54a3000016001434b1d6211af5551905dc2642d05f5b04d25a8fe80247304402207f570e3f0de50546aad25a872e3df059d277e776dda4269fa0d2cc8c2ee6ec9a022054e7fae5ca94d47534c86705857c24ceea3ad51c69dd6051c5850304880fc43a012103cb11a1bacc223d98d91f1946c6752e358a5eb1a1c983b3e6fb15378f453b76bd00000000").unwrap()[..]).unwrap();
+               let tx: Transaction = encode::deserialize(&hex::decode("020000000001010e0adef48412e4361325ac1c6e36411299ab09d4f083b9d8ddb55fbc06e1b0c00000000000feffffff0220a1070000000000220020f81d95e040bd0a493e38bae27bff52fe2bb58b93b293eb579c01c31b05c5af1dc072cfee54a3000016001434b1d6211af5551905dc2642d05f5b04d25a8fe80247304402207f570e3f0de50546aad25a872e3df059d277e776dda4269fa0d2cc8c2ee6ec9a022054e7fae5ca94d47534c86705857c24ceea3ad51c69dd6051c5850304880fc43a012103cb11a1bacc223d98d91f1946c6752e358a5eb1a1c983b3e6fb15378f453b76bd00000000").unwrap()[..]).unwrap();
                assert_eq!(&OutPoint {
                        txid: tx.txid(),
                        index: 0
index b9a81f6ebc0465cf34396eb44073b790fd7c3925..207eda4183f7a8993c5ff0278df605637f59c4a0 100644 (file)
@@ -2,11 +2,9 @@ use bitcoin::blockdata::block::BlockHeader;
 use bitcoin::blockdata::script::{Script,Builder};
 use bitcoin::blockdata::transaction::{TxIn, TxOut, Transaction, SigHashType};
 use bitcoin::blockdata::opcodes;
-use bitcoin::util::hash::{Sha256dHash, Hash160};
+use bitcoin::util::hash::{BitcoinHash, Sha256dHash, Hash160};
 use bitcoin::util::bip143;
-use bitcoin::network;
-use bitcoin::network::serialize::{BitcoinHash, RawDecoder, RawEncoder};
-use bitcoin::network::encodable::{ConsensusEncodable, ConsensusDecodable};
+use bitcoin::consensus::encode::{self, Encodable, Decodable};
 
 use secp256k1::key::{PublicKey,SecretKey};
 use secp256k1::{Secp256k1,Message,Signature};
@@ -3511,9 +3509,9 @@ impl Writeable for Channel {
 
                (self.last_local_commitment_txn.len() as u64).write(writer)?;
                for tx in self.last_local_commitment_txn.iter() {
-                       if let Err(e) = tx.consensus_encode(&mut RawEncoder::new(WriterWriteAdaptor(writer))) {
+                       if let Err(e) = tx.consensus_encode(&mut WriterWriteAdaptor(writer)) {
                                match e {
-                                       network::serialize::Error::Io(e) => return Err(e),
+                                       encode::Error::Io(e) => return Err(e),
                                        _ => panic!("last_local_commitment_txn must have been well-formed!"),
                                }
                        }
@@ -3690,7 +3688,7 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
                let last_local_commitment_txn_count: u64 = Readable::read(reader)?;
                let mut last_local_commitment_txn = Vec::with_capacity(cmp::min(last_local_commitment_txn_count as usize, OUR_MAX_HTLCS as usize*2 + 1));
                for _ in 0..last_local_commitment_txn_count {
-                       last_local_commitment_txn.push(match Transaction::consensus_decode(&mut RawDecoder::new(reader.by_ref())) {
+                       last_local_commitment_txn.push(match Transaction::consensus_decode(reader.by_ref()) {
                                Ok(tx) => tx,
                                Err(_) => return Err(DecodeError::InvalidValue),
                        });
@@ -3818,7 +3816,7 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
 mod tests {
        use bitcoin::util::hash::{Sha256dHash, Hash160};
        use bitcoin::util::bip143;
-       use bitcoin::network::serialize::serialize;
+       use bitcoin::consensus::encode::serialize;
        use bitcoin::blockdata::script::{Script, Builder};
        use bitcoin::blockdata::transaction::Transaction;
        use bitcoin::blockdata::opcodes;
@@ -3940,7 +3938,7 @@ mod tests {
 
                                chan.sign_commitment_transaction(&mut unsigned_tx.0, &their_signature);
 
-                               assert_eq!(serialize(&unsigned_tx.0).unwrap()[..],
+                               assert_eq!(serialize(&unsigned_tx.0)[..],
                                                hex::decode($tx_hex).unwrap()[..]);
                        };
                }
@@ -3973,7 +3971,7 @@ mod tests {
                                }
 
                                chan.sign_htlc_transaction(&mut htlc_tx, &remote_signature, &preimage, &htlc, &keys).unwrap();
-                               assert_eq!(serialize(&htlc_tx).unwrap()[..],
+                               assert_eq!(serialize(&htlc_tx)[..],
                                                hex::decode($tx_hex).unwrap()[..]);
                        };
                }
index a650c89bb44668149cb305a4c0f4b35d307ad279..1f765eb197f5f218582af1dfdf39ee43a3e1926e 100644 (file)
@@ -12,8 +12,7 @@ use bitcoin::blockdata::block::BlockHeader;
 use bitcoin::blockdata::transaction::Transaction;
 use bitcoin::blockdata::constants::genesis_block;
 use bitcoin::network::constants::Network;
-use bitcoin::network::serialize::BitcoinHash;
-use bitcoin::util::hash::Sha256dHash;
+use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
 
 use secp256k1::key::{SecretKey,PublicKey};
 use secp256k1::{Secp256k1,Message};
@@ -3224,13 +3223,11 @@ mod tests {
        use util::ser::{Writeable, Writer, ReadableArgs};
        use util::config::UserConfig;
 
-       use bitcoin::util::hash::Sha256dHash;
+       use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
        use bitcoin::blockdata::block::{Block, BlockHeader};
        use bitcoin::blockdata::transaction::{Transaction, TxOut};
        use bitcoin::blockdata::constants::genesis_block;
        use bitcoin::network::constants::Network;
-       use bitcoin::network::serialize::serialize;
-       use bitcoin::network::serialize::BitcoinHash;
 
        use hex;
 
@@ -3520,7 +3517,7 @@ mod tests {
                                tx = Transaction { version: chan_id as u32, lock_time: 0, input: Vec::new(), output: vec![TxOut {
                                        value: *channel_value_satoshis, script_pubkey: output_script.clone(),
                                }]};
-                               funding_output = OutPoint::new(Sha256dHash::from_data(&serialize(&tx).unwrap()[..]), 0);
+                               funding_output = OutPoint::new(tx.txid(), 0);
 
                                node_a.node.funding_transaction_generated(&temporary_channel_id, funding_output);
                                let mut added_monitors = node_a.chan_monitor.added_monitors.lock().unwrap();
index 5d1e4e09516b73200ed3834ae1190975ba28e2de..458c0dec741035cee06d5c7938779993570e1fd0 100644 (file)
@@ -15,10 +15,8 @@ use bitcoin::blockdata::block::BlockHeader;
 use bitcoin::blockdata::transaction::{TxIn,TxOut,SigHashType,Transaction};
 use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
 use bitcoin::blockdata::script::Script;
-use bitcoin::network::serialize;
-use bitcoin::network::serialize::BitcoinHash;
-use bitcoin::network::encodable::{ConsensusDecodable, ConsensusEncodable};
-use bitcoin::util::hash::Sha256dHash;
+use bitcoin::consensus::encode::{self, Decodable, Encodable};
+use bitcoin::util::hash::{BitcoinHash,Sha256dHash};
 use bitcoin::util::bip143;
 
 use crypto::digest::Digest;
@@ -731,9 +729,9 @@ impl ChannelMonitor {
 
                macro_rules! serialize_local_tx {
                        ($local_tx: expr) => {
-                               if let Err(e) = $local_tx.tx.consensus_encode(&mut serialize::RawEncoder::new(WriterWriteAdaptor(writer))) {
+                               if let Err(e) = $local_tx.tx.consensus_encode(&mut WriterWriteAdaptor(writer)) {
                                        match e {
-                                               serialize::Error::Io(e) => return Err(e),
+                                               encode::Error::Io(e) => return Err(e),
                                                _ => panic!("local tx must have been well-formed!"),
                                        }
                                }
@@ -1579,10 +1577,10 @@ impl<R: ::std::io::Read> ReadableArgs<R, Arc<Logger>> for (Sha256dHash, ChannelM
                macro_rules! read_local_tx {
                        () => {
                                {
-                                       let tx = match Transaction::consensus_decode(&mut serialize::RawDecoder::new(reader.by_ref())) {
+                                       let tx = match Transaction::consensus_decode(reader.by_ref()) {
                                                Ok(tx) => tx,
                                                Err(e) => match e {
-                                                       serialize::Error::Io(ioe) => return Err(DecodeError::Io(ioe)),
+                                                       encode::Error::Io(ioe) => return Err(DecodeError::Io(ioe)),
                                                        _ => return Err(DecodeError::InvalidValue),
                                                },
                                        };