@@ -18,7 +18,7 @@ use std::io;
1818use std:: str:: FromStr ;
1919
2020use bitcoin:: util:: hash:: BitcoinHash ;
21- use bitcoin:: hashes:: { hex, sha256, Hash } ;
21+ use bitcoin:: hashes:: { hex, sha256, sha256d , Hash } ;
2222
2323use encode:: { self , Encodable , Decodable } ;
2424use fast_merkle_root:: fast_merkle_root;
@@ -37,6 +37,8 @@ const TWO32: [u8; 32] = [
3737 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
3838] ;
3939
40+ hash_newtype ! ( ContractHash , sha256d:: Hash , 32 , doc="The hash of an asset contract." , true ) ;
41+
4042/// An issued asset ID.
4143#[ derive( Copy , Clone , PartialEq , Eq , Default , PartialOrd , Ord , Hash ) ]
4244pub struct AssetId ( sha256:: Midstate ) ;
@@ -55,7 +57,7 @@ impl AssetId {
5557 /// Generate the asset entropy from the issuance prevout and the contract hash.
5658 pub fn generate_asset_entropy (
5759 prevout : OutPoint ,
58- contract_hash : sha256 :: Hash ,
60+ contract_hash : ContractHash ,
5961 ) -> sha256:: Midstate {
6062 // E : entropy
6163 // I : prevout
@@ -226,7 +228,7 @@ mod test {
226228 let asset_id_hex = "dcd60818d863b5c026c40b2bc3ba6fdaf5018bcc8606c18adf7db4da0bcd8533" ;
227229 let token_id_hex = "c1adb114f4f87d33bf9ce90dd4f9ca523dd414d6cd010a7917903e2009689530" ;
228230
229- let contract_hash = sha256 :: Hash :: from_inner ( ZERO32 ) ;
231+ let contract_hash = ContractHash :: from_inner ( ZERO32 ) ;
230232 let prevout = OutPoint :: from_str ( prevout_str) . unwrap ( ) ;
231233 let entropy = sha256:: Midstate :: from_hex ( entropy_hex) . unwrap ( ) ;
232234 assert_eq ! ( AssetId :: generate_asset_entropy( prevout, contract_hash) , entropy) ;
0 commit comments