@@ -14,7 +14,8 @@ use bitcoin::psbt::Psbt;
14
14
use bitcoin:: sighash:: SighashCache ;
15
15
use bitcoin:: taproot:: { LeafVersion , TapLeafHash } ;
16
16
use 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 ,
18
19
} ;
19
20
use bitcoind:: bitcoincore_rpc:: { json, Client , RpcApi } ;
20
21
use miniscript:: bitcoin:: { self , ecdsa, taproot, ScriptBuf } ;
@@ -28,7 +29,7 @@ use setup::test_util::{self, TestData};
28
29
fn btc < F : Into < f64 > > ( btc : F ) -> Amount { Amount :: from_btc ( btc. into ( ) ) . unwrap ( ) }
29
30
30
31
// 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 ) {
32
33
let tx = cl
33
34
. get_transaction ( & txid, None )
34
35
. unwrap ( )
@@ -102,7 +103,7 @@ pub fn test_desc_satisfy(
102
103
// Spend one input and spend one output for simplicity.
103
104
let mut psbt = Psbt {
104
105
unsigned_tx : Transaction {
105
- version : 2 ,
106
+ version : transaction :: Version :: TWO ,
106
107
lock_time : absolute:: LockTime :: from_time ( 1_603_866_330 )
107
108
. expect ( "valid timestamp" )
108
109
. into ( ) , // 10/28/2020 @ 6:25am (UTC)
@@ -117,8 +118,7 @@ pub fn test_desc_satisfy(
117
118
outputs : vec ! [ ] ,
118
119
} ;
119
120
// 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 ( ) ) ;
122
122
let mut txin = TxIn :: default ( ) ;
123
123
txin. previous_output = outpoint;
124
124
// set the sequence to a non-final number for the locktime transactions to be
@@ -137,7 +137,7 @@ pub fn test_desc_satisfy(
137
137
// (Was getting insufficient fees error, for deep script trees)
138
138
psbt. unsigned_tx
139
139
. 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 ( ) } ) ;
141
141
let mut input = psbt:: Input :: default ( ) ;
142
142
input
143
143
. update_with_descriptor_unchecked ( & definite_desc)
@@ -172,7 +172,7 @@ pub fn test_desc_satisfy(
172
172
let sighash_msg = sighash_cache
173
173
. taproot_key_spend_signature_hash ( 0 , & prevouts, hash_ty)
174
174
. unwrap ( ) ;
175
- let msg = secp256k1:: Message :: from_slice ( & sighash_msg[ .. ] ) . unwrap ( ) ;
175
+ let msg = secp256k1:: Message :: from_digest ( sighash_msg. to_byte_array ( ) ) ;
176
176
let mut aux_rand = [ 0u8 ; 32 ] ;
177
177
rand:: thread_rng ( ) . fill_bytes ( & mut aux_rand) ;
178
178
let schnorr_sig =
@@ -183,7 +183,7 @@ pub fn test_desc_satisfy(
183
183
// No internal key
184
184
}
185
185
// ------------------ script spend -------------
186
- let x_only_keypairs_reqd: Vec < ( secp256k1:: KeyPair , TapLeafHash ) > = tr
186
+ let x_only_keypairs_reqd: Vec < ( secp256k1:: Keypair , TapLeafHash ) > = tr
187
187
. iter_scripts ( )
188
188
. flat_map ( |( _depth, ms) | {
189
189
let leaf_hash = TapLeafHash :: from_script ( & ms. encode ( ) , LeafVersion :: TapScript ) ;
@@ -197,7 +197,7 @@ pub fn test_desc_satisfy(
197
197
let sighash_msg = sighash_cache
198
198
. taproot_script_spend_signature_hash ( 0 , & prevouts, leaf_hash, hash_ty)
199
199
. unwrap ( ) ;
200
- let msg = secp256k1:: Message :: from_slice ( & sighash_msg[ .. ] ) . unwrap ( ) ;
200
+ let msg = secp256k1:: Message :: from_digest ( sighash_msg. to_byte_array ( ) ) ;
201
201
let mut aux_rand = [ 0u8 ; 32 ] ;
202
202
rand:: thread_rng ( ) . fill_bytes ( & mut aux_rand) ;
203
203
let sig = secp. sign_schnorr_with_aux_rand ( & msg, & keypair, & aux_rand) ;
0 commit comments