X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fchain%2Ftransaction.rs;h=ce43984ebd48b270f0f32da2266da2ac940e2a6b;hb=ce6f561485f3266c28ce5150a225fbe1f8137d0c;hp=227afa0de68e35bf8a104ea913f6ce7e2c6b0db0;hpb=cd9d680986bb4cd24464b2a3223ab7735291bcfa;p=rust-lightning diff --git a/src/chain/transaction.rs b/src/chain/transaction.rs index 227afa0d..ce43984e 100644 --- a/src/chain/transaction.rs +++ b/src/chain/transaction.rs @@ -1,7 +1,10 @@ -use bitcoin::util::hash::Sha256dHash; +//! Contains simple structs describing parts of transactions on the chain. + +use bitcoin_hashes::sha256d::Hash as Sha256dHash; use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint; /// A reference to a transaction output. +/// /// Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 /// due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] @@ -27,6 +30,7 @@ impl OutPoint { res } + /// Converts this OutPoint into the OutPoint field as used by rust-bitcoin pub fn into_bitcoin_outpoint(self) -> BitcoinOutPoint { BitcoinOutPoint { txid: self.txid, @@ -40,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