1717
1818use std:: { io, fmt} ;
1919
20- use bitcoin:: { self , BitcoinHash , VarInt } ;
20+ use bitcoin:: { self , BitcoinHash , Txid , VarInt } ;
2121use bitcoin:: blockdata:: opcodes;
2222use bitcoin:: blockdata:: script:: { Script , Instruction } ;
2323use bitcoin:: hashes:: { Hash , sha256d} ;
@@ -44,7 +44,7 @@ impl_consensus_encoding!(AssetIssuance, asset_blinding_nonce, asset_entropy, amo
4444#[ derive( Copy , Clone , Debug , Eq , Hash , PartialEq , PartialOrd , Ord ) ]
4545pub struct OutPoint {
4646 /// The referenced transaction's txid
47- pub txid : sha256d :: Hash ,
47+ pub txid : Txid ,
4848 /// The index of the referenced output in its transaction's vout
4949 pub vout : u32 ,
5050}
@@ -54,7 +54,7 @@ impl Default for OutPoint {
5454 /// Coinbase outpoint
5555 fn default ( ) -> OutPoint {
5656 OutPoint {
57- txid : sha256d :: Hash :: default ( ) ,
57+ txid : Txid :: default ( ) ,
5858 vout : 0xffffffff ,
5959 }
6060 }
@@ -69,7 +69,7 @@ impl Encodable for OutPoint {
6969
7070impl Decodable for OutPoint {
7171 fn consensus_decode < D : io:: Read > ( mut d : D ) -> Result < OutPoint , encode:: Error > {
72- let txid = sha256d :: Hash :: consensus_decode ( & mut d) ?;
72+ let txid = Txid :: consensus_decode ( & mut d) ?;
7373 let vout = u32:: consensus_decode ( & mut d) ?;
7474 Ok ( OutPoint {
7575 txid : txid,
@@ -78,11 +78,11 @@ impl Decodable for OutPoint {
7878 }
7979}
8080
81- impl BitcoinHash for OutPoint {
82- fn bitcoin_hash ( & self ) -> sha256d :: Hash {
81+ impl BitcoinHash < Txid > for OutPoint {
82+ fn bitcoin_hash ( & self ) -> Txid {
8383 let mut enc = sha256d:: Hash :: engine ( ) ;
8484 self . consensus_encode ( & mut enc) . unwrap ( ) ;
85- sha256d :: Hash :: from_engine ( enc)
85+ Txid :: from_engine ( enc)
8686 }
8787}
8888
@@ -598,12 +598,12 @@ impl Transaction {
598598 }
599599}
600600
601- impl BitcoinHash for Transaction {
601+ impl BitcoinHash < Txid > for Transaction {
602602 /// To get a transaction's txid, which is usually what you want, use the `txid` method.
603- fn bitcoin_hash ( & self ) -> sha256d :: Hash {
603+ fn bitcoin_hash ( & self ) -> Txid {
604604 let mut enc = sha256d:: Hash :: engine ( ) ;
605605 self . consensus_encode ( & mut enc) . unwrap ( ) ;
606- sha256d :: Hash :: from_engine ( enc)
606+ Txid :: from_engine ( enc)
607607 }
608608}
609609
@@ -687,7 +687,7 @@ mod tests {
687687 let txid = "d0a5c455ea7221dead9513596d2f97c09943bad81a386fe61a14a6cda060e422" ;
688688 let s = format ! ( "{}:42" , txid) ;
689689 let expected = OutPoint {
690- txid : sha256d :: Hash :: from_hex ( & txid) . unwrap ( ) ,
690+ txid : Txid :: from_hex ( & txid) . unwrap ( ) ,
691691 vout : 42 ,
692692 } ;
693693 let op = :: std:: str:: FromStr :: from_str ( & s) . ok ( ) ;
@@ -1017,7 +1017,7 @@ mod tests {
10171017 tx. input[ 0 ] . pegin_data( ) ,
10181018 Some ( super :: PeginData {
10191019 outpoint: bitcoin:: OutPoint {
1020- txid: sha256d :: Hash :: from_hex(
1020+ txid: Txid :: from_hex(
10211021 "c9d88eb5130365deed045eab11cfd3eea5ba32ad45fa2e156ae6ead5f1fce93f" ,
10221022 ) . unwrap( ) ,
10231023 vout: 0 ,
0 commit comments