max_level_debug = []
[dependencies]
-bitcoin = "0.14"
+bitcoin = "0.15"
rust-crypto = "0.2"
rand = "0.4"
secp256k1 = "0.11"
cc = "1.0"
[dev-dependencies.bitcoin]
-version = "0.14"
+version = "0.15"
features = ["bitcoinconsensus"]
[dev-dependencies]
[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"
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;
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);
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() {
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;
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
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};
(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!"),
}
}
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),
});
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;
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()[..]);
};
}
}
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()[..]);
};
}
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};
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;
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();
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;
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!"),
}
}
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),
},
};