1919//! https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
2020
2121use bdk:: bitcoin:: blockdata:: opcodes;
22- use bdk:: bitcoin:: blockdata:: script:: { Builder , Script } ;
23- use bdk:: bitcoin:: blockdata:: transaction:: { EcdsaSighashType , OutPoint , TxIn , TxOut } ;
22+ use bdk:: bitcoin:: blockdata:: script:: { Builder , Script , ScriptBuf } ;
23+ use bdk:: bitcoin:: blockdata:: transaction:: { OutPoint , TxIn , TxOut } ;
2424use bdk:: bitcoin:: consensus:: encode:: serialize;
2525use bdk:: bitcoin:: hash_types:: { PubkeyHash , Txid } ;
2626use bdk:: bitcoin:: hashes:: { hash160, sha256d, Hash } ;
27- use bdk:: bitcoin:: util:: psbt:: { Input , PartiallySignedTransaction as PSBT } ;
27+ use bdk:: bitcoin:: psbt:: { Input , PartiallySignedTransaction as PSBT } ;
28+ use bdk:: bitcoin:: sighash:: EcdsaSighashType ;
2829use bdk:: bitcoin:: { Network , Sequence } ;
2930use bdk:: database:: BatchDatabase ;
3031use bdk:: wallet:: tx_builder:: TxOrdering ;
@@ -113,12 +114,12 @@ where
113114 value : 0 ,
114115 script_pubkey : Builder :: new ( ) . push_opcode ( opcodes:: OP_TRUE ) . into_script ( ) ,
115116 } ) ,
116- final_script_sig : Some ( Script :: default ( ) ) , /* "finalize" the input with an empty scriptSig */
117+ final_script_sig : Some ( Script :: empty ( ) . into ( ) ) , /* "finalize" the input with an empty scriptSig */
117118 ..Default :: default ( )
118119 } ;
119120
120- let pkh = PubkeyHash :: from_hash ( hash160:: Hash :: hash ( & [ 0 ] ) ) ;
121- let out_script_unspendable = Script :: new_p2pkh ( & pkh) ;
121+ let pkh = PubkeyHash :: from_raw_hash ( hash160:: Hash :: hash ( & [ 0 ] ) ) ;
122+ let out_script_unspendable = ScriptBuf :: new_p2pkh ( & pkh) ;
122123
123124 let mut builder = self . build_tx ( ) ;
124125 builder
@@ -252,8 +253,8 @@ pub fn verify_proof(
252253 }
253254
254255 // verify the unspendable output
255- let pkh = PubkeyHash :: from_hash ( hash160:: Hash :: hash ( & [ 0 ] ) ) ;
256- let out_script_unspendable = Script :: new_p2pkh ( & pkh) ;
256+ let pkh = PubkeyHash :: from_raw_hash ( hash160:: Hash :: hash ( & [ 0 ] ) ) ;
257+ let out_script_unspendable = ScriptBuf :: new_p2pkh ( & pkh) ;
257258
258259 if tx. output [ 0 ] . script_pubkey != out_script_unspendable {
259260 return Err ( ProofError :: InvalidOutput ) ;
@@ -303,7 +304,7 @@ fn challenge_txin(message: &str) -> TxIn {
303304 let message = "Proof-of-Reserves: " . to_string ( ) + message;
304305 let message = sha256d:: Hash :: hash ( message. as_bytes ( ) ) ;
305306 TxIn {
306- previous_output : OutPoint :: new ( Txid :: from_hash ( message) , 0 ) ,
307+ previous_output : OutPoint :: new ( Txid :: from_raw_hash ( message) , 0 ) ,
307308 sequence : Sequence ( 0xFFFFFFFF ) ,
308309 ..Default :: default ( )
309310 }
@@ -313,7 +314,7 @@ fn challenge_txin(message: &str) -> TxIn {
313314mod test {
314315 use super :: * ;
315316 use bdk:: bitcoin:: secp256k1:: ecdsa:: { SerializedSignature , Signature } ;
316- use bdk:: bitcoin:: { EcdsaSighashType , Network , Witness } ;
317+ use bdk:: bitcoin:: { Network , Witness } ;
317318 use bdk:: wallet:: get_funded_wallet;
318319 use std:: str:: FromStr ;
319320
@@ -506,8 +507,8 @@ mod test {
506507 let message = "This belongs to me." ;
507508 let mut psbt = get_signed_proof ( ) ;
508509
509- let pkh = PubkeyHash :: from_hash ( hash160:: Hash :: hash ( & [ 0 , 1 , 2 , 3 ] ) ) ;
510- let out_script_unspendable = Script :: new_p2pkh ( & pkh) ;
510+ let pkh = PubkeyHash :: from_raw_hash ( hash160:: Hash :: hash ( & [ 0 , 1 , 2 , 3 ] ) ) ;
511+ let out_script_unspendable = ScriptBuf :: new_p2pkh ( & pkh) ;
511512 psbt. unsigned_tx . output [ 0 ] . script_pubkey = out_script_unspendable;
512513
513514 wallet. verify_proof ( & psbt, message, None ) . unwrap ( ) ;
0 commit comments