@@ -20,7 +20,7 @@ use std::{io, fmt};
2020use bitcoin:: { self , BitcoinHash , Txid , VarInt } ;
2121use bitcoin:: blockdata:: opcodes;
2222use bitcoin:: blockdata:: script:: { Script , Instruction } ;
23- use bitcoin:: hashes:: { Hash , sha256d } ;
23+ use bitcoin:: hashes:: Hash ;
2424
2525use confidential;
2626use encode:: { self , Encodable , Decodable } ;
@@ -80,7 +80,7 @@ impl Decodable for OutPoint {
8080
8181impl BitcoinHash < Txid > for OutPoint {
8282 fn bitcoin_hash ( & self ) -> Txid {
83- let mut enc = sha256d :: Hash :: engine ( ) ;
83+ let mut enc = Txid :: engine ( ) ;
8484 self . consensus_encode ( & mut enc) . unwrap ( ) ;
8585 Txid :: from_engine ( enc)
8686 }
@@ -143,7 +143,7 @@ pub struct PeginData<'tx> {
143143 /// Asset type being pegged in
144144 pub asset : confidential:: Asset ,
145145 /// Hash of genesis block of originating blockchain
146- pub genesis_hash : sha256d :: Hash ,
146+ pub genesis_hash : bitcoin :: BlockHash ,
147147 /// The claim script that we should hash to tweak our address. Unparsed
148148 /// to avoid unnecessary allocation and copying. Typical use is simply
149149 /// to feed it raw into a hash function.
@@ -157,7 +157,7 @@ pub struct PeginData<'tx> {
157157 pub merkle_proof : & ' tx [ u8 ] ,
158158 /// The Bitcoin block that the pegin output appears in; scraped
159159 /// from the transaction inclusion proof
160- pub referenced_block : sha256d :: Hash ,
160+ pub referenced_block : bitcoin :: BlockHash ,
161161}
162162
163163/// A transaction input, which defines old coins to be consumed
@@ -284,7 +284,7 @@ impl TxIn {
284284 claim_script : & self . witness . pegin_witness [ 3 ] ,
285285 tx : & self . witness . pegin_witness [ 4 ] ,
286286 merkle_proof : & self . witness . pegin_witness [ 5 ] ,
287- referenced_block : sha256d :: Hash :: hash (
287+ referenced_block : bitcoin :: BlockHash :: hash (
288288 & self . witness . pegin_witness [ 5 ] [ 0 ..80 ] ,
289289 ) ,
290290 } )
@@ -322,7 +322,7 @@ pub struct PegoutData<'txo> {
322322 /// Asset of pegout
323323 pub asset : confidential:: Asset ,
324324 /// Genesis hash of the target blockchain
325- pub genesis_hash : sha256d :: Hash ,
325+ pub genesis_hash : bitcoin :: BlockHash ,
326326 /// Scriptpubkey to create on the target blockchain
327327 pub script_pubkey : Script ,
328328 /// Remaining pegout data used by some forks of Elements
@@ -416,7 +416,7 @@ impl TxOut {
416416
417417 // Parse destination chain's genesis block
418418 let genesis_hash = if let Some ( Instruction :: PushBytes ( data) ) = iter. next ( ) {
419- if let Ok ( hash) = sha256d :: Hash :: from_slice ( data) {
419+ if let Ok ( hash) = bitcoin :: BlockHash :: from_slice ( data) {
420420 hash
421421 } else {
422422 return None ;
@@ -587,21 +587,21 @@ impl Transaction {
587587 }
588588
589589 /// The txid of the transaction. To get its hash, use `BitcoinHash::bitcoin_hash()`.
590- pub fn txid ( & self ) -> sha256d :: Hash {
591- let mut enc = sha256d :: Hash :: engine ( ) ;
590+ pub fn txid ( & self ) -> bitcoin :: Txid {
591+ let mut enc = bitcoin :: Txid :: engine ( ) ;
592592 self . version . consensus_encode ( & mut enc) . unwrap ( ) ;
593593 0u8 . consensus_encode ( & mut enc) . unwrap ( ) ;
594594 self . input . consensus_encode ( & mut enc) . unwrap ( ) ;
595595 self . output . consensus_encode ( & mut enc) . unwrap ( ) ;
596596 self . lock_time . consensus_encode ( & mut enc) . unwrap ( ) ;
597- sha256d :: Hash :: from_engine ( enc)
597+ bitcoin :: Txid :: from_engine ( enc)
598598 }
599599}
600600
601601impl BitcoinHash < Txid > for Transaction {
602602 /// To get a transaction's txid, which is usually what you want, use the `txid` method.
603603 fn bitcoin_hash ( & self ) -> Txid {
604- let mut enc = sha256d :: Hash :: engine ( ) ;
604+ let mut enc = Txid :: engine ( ) ;
605605 self . consensus_encode ( & mut enc) . unwrap ( ) ;
606606 Txid :: from_engine ( enc)
607607 }
@@ -1024,7 +1024,7 @@ mod tests {
10241024 } ,
10251025 value: 100000000 ,
10261026 asset: tx. output[ 0 ] . asset,
1027- genesis_hash: sha256d :: Hash :: from_hex(
1027+ genesis_hash: bitcoin :: BlockHash :: from_hex(
10281028 "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"
10291029 ) . unwrap( ) ,
10301030 claim_script: & [
@@ -1083,7 +1083,7 @@ mod tests {
10831083 0x25 , 0xf8 , 0x55 , 0x52 , 0x97 , 0x11 , 0xed , 0x64 ,
10841084 0x50 , 0xcc , 0x9b , 0x3c , 0x95 , 0x01 , 0x0b ,
10851085 ] ,
1086- referenced_block: sha256d :: Hash :: from_hex(
1086+ referenced_block: bitcoin :: BlockHash :: from_hex(
10871087 "297852caf43464d8f13a3847bd602184c21474cd06760dbf9fc5e87bade234f1"
10881088 ) . unwrap( ) ,
10891089 } )
@@ -1128,7 +1128,7 @@ mod tests {
11281128 Some ( super :: PegoutData {
11291129 asset: tx. output[ 0 ] . asset,
11301130 value: 99993900 ,
1131- genesis_hash: sha256d :: Hash :: from_hex(
1131+ genesis_hash: bitcoin :: BlockHash :: from_hex(
11321132 "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"
11331133 ) . unwrap( ) ,
11341134 script_pubkey: hex_deserialize!(
0 commit comments