@@ -14,7 +14,8 @@ use bitcoin::psbt::Psbt;
1414use bitcoin:: sighash:: SighashCache ;
1515use bitcoin:: taproot:: { LeafVersion , TapLeafHash } ;
1616use bitcoin:: {
17- absolute, psbt, secp256k1, sighash, Amount , OutPoint , Sequence , Transaction , TxIn , TxOut , Txid ,
17+ absolute, psbt, secp256k1, sighash, transaction, Amount , OutPoint , Sequence , Transaction , TxIn ,
18+ TxOut , Txid ,
1819} ;
1920use bitcoind:: bitcoincore_rpc:: { json, Client , RpcApi } ;
2021use miniscript:: bitcoin:: { self , ecdsa, taproot, ScriptBuf } ;
@@ -28,7 +29,7 @@ use setup::test_util::{self, TestData};
2829fn btc < F : Into < f64 > > ( btc : F ) -> Amount { Amount :: from_btc ( btc. into ( ) ) . unwrap ( ) }
2930
3031// Find the Outpoint by spk
31- fn get_vout ( cl : & Client , txid : Txid , value : u64 , spk : ScriptBuf ) -> ( OutPoint , TxOut ) {
32+ fn get_vout ( cl : & Client , txid : Txid , value : Amount , spk : ScriptBuf ) -> ( OutPoint , TxOut ) {
3233 let tx = cl
3334 . get_transaction ( & txid, None )
3435 . unwrap ( )
@@ -102,7 +103,7 @@ pub fn test_desc_satisfy(
102103 // Spend one input and spend one output for simplicity.
103104 let mut psbt = Psbt {
104105 unsigned_tx : Transaction {
105- version : 2 ,
106+ version : transaction :: Version :: TWO ,
106107 lock_time : absolute:: LockTime :: from_time ( 1_603_866_330 )
107108 . expect ( "valid timestamp" )
108109 . into ( ) , // 10/28/2020 @ 6:25am (UTC)
@@ -117,8 +118,7 @@ pub fn test_desc_satisfy(
117118 outputs : vec ! [ ] ,
118119 } ;
119120 // figure out the outpoint from the txid
120- let ( outpoint, witness_utxo) =
121- get_vout ( & cl, txid, btc ( 1.0 ) . to_sat ( ) , derived_desc. script_pubkey ( ) ) ;
121+ let ( outpoint, witness_utxo) = get_vout ( & cl, txid, btc ( 1.0 ) , derived_desc. script_pubkey ( ) ) ;
122122 let mut txin = TxIn :: default ( ) ;
123123 txin. previous_output = outpoint;
124124 // set the sequence to a non-final number for the locktime transactions to be
@@ -137,7 +137,7 @@ pub fn test_desc_satisfy(
137137 // (Was getting insufficient fees error, for deep script trees)
138138 psbt. unsigned_tx
139139 . output
140- . push ( TxOut { value : 99_997_000 , script_pubkey : addr. script_pubkey ( ) } ) ;
140+ . push ( TxOut { value : Amount :: from_sat ( 99_997_000 ) , script_pubkey : addr. script_pubkey ( ) } ) ;
141141 let mut input = psbt:: Input :: default ( ) ;
142142 input
143143 . update_with_descriptor_unchecked ( & definite_desc)
@@ -172,7 +172,7 @@ pub fn test_desc_satisfy(
172172 let sighash_msg = sighash_cache
173173 . taproot_key_spend_signature_hash ( 0 , & prevouts, hash_ty)
174174 . unwrap ( ) ;
175- let msg = secp256k1:: Message :: from_slice ( & sighash_msg[ .. ] ) . unwrap ( ) ;
175+ let msg = secp256k1:: Message :: from_digest ( sighash_msg. to_byte_array ( ) ) ;
176176 let mut aux_rand = [ 0u8 ; 32 ] ;
177177 rand:: thread_rng ( ) . fill_bytes ( & mut aux_rand) ;
178178 let schnorr_sig =
@@ -183,7 +183,7 @@ pub fn test_desc_satisfy(
183183 // No internal key
184184 }
185185 // ------------------ script spend -------------
186- let x_only_keypairs_reqd: Vec < ( secp256k1:: KeyPair , TapLeafHash ) > = tr
186+ let x_only_keypairs_reqd: Vec < ( secp256k1:: Keypair , TapLeafHash ) > = tr
187187 . iter_scripts ( )
188188 . flat_map ( |( _depth, ms) | {
189189 let leaf_hash = TapLeafHash :: from_script ( & ms. encode ( ) , LeafVersion :: TapScript ) ;
@@ -197,7 +197,7 @@ pub fn test_desc_satisfy(
197197 let sighash_msg = sighash_cache
198198 . taproot_script_spend_signature_hash ( 0 , & prevouts, leaf_hash, hash_ty)
199199 . unwrap ( ) ;
200- let msg = secp256k1:: Message :: from_slice ( & sighash_msg[ .. ] ) . unwrap ( ) ;
200+ let msg = secp256k1:: Message :: from_digest ( sighash_msg. to_byte_array ( ) ) ;
201201 let mut aux_rand = [ 0u8 ; 32 ] ;
202202 rand:: thread_rng ( ) . fill_bytes ( & mut aux_rand) ;
203203 let sig = secp. sign_schnorr_with_aux_rand ( & msg, & keypair, & aux_rand) ;
0 commit comments