@@ -81,7 +81,7 @@ pub fn test_desc_satisfy(
81
81
. unwrap ( ) ;
82
82
assert_eq ! ( blocks. len( ) , 1 ) ;
83
83
84
- let definite_desc = test_util:: parse_test_desc ( & descriptor, & testdata. pubdata )
84
+ let definite_desc = test_util:: parse_test_desc ( descriptor, & testdata. pubdata )
85
85
. map_err ( |_| DescError :: DescParseError ) ?
86
86
. at_derivation_index ( 0 )
87
87
. unwrap ( ) ;
@@ -104,9 +104,7 @@ pub fn test_desc_satisfy(
104
104
let mut psbt = Psbt {
105
105
unsigned_tx : Transaction {
106
106
version : transaction:: Version :: TWO ,
107
- lock_time : absolute:: LockTime :: from_time ( 1_603_866_330 )
108
- . expect ( "valid timestamp" )
109
- . into ( ) , // 10/28/2020 @ 6:25am (UTC)
107
+ lock_time : absolute:: LockTime :: from_time ( 1_603_866_330 ) . expect ( "valid timestamp" ) , // 10/28/2020 @ 6:25am (UTC)
110
108
input : vec ! [ ] ,
111
109
output : vec ! [ ] ,
112
110
} ,
@@ -118,13 +116,15 @@ pub fn test_desc_satisfy(
118
116
outputs : vec ! [ ] ,
119
117
} ;
120
118
// figure out the outpoint from the txid
121
- let ( outpoint, witness_utxo) = get_vout ( & cl, txid, btc ( 1.0 ) , derived_desc. script_pubkey ( ) ) ;
122
- let mut txin = TxIn :: default ( ) ;
123
- txin. previous_output = outpoint;
124
- // set the sequence to a non-final number for the locktime transactions to be
125
- // processed correctly.
126
- // We waited 2 blocks, keep 1 for safety
127
- txin. sequence = Sequence :: from_height ( 1 ) ;
119
+ let ( outpoint, witness_utxo) = get_vout ( cl, txid, btc ( 1.0 ) , derived_desc. script_pubkey ( ) ) ;
120
+ let txin = TxIn {
121
+ previous_output : outpoint,
122
+ // set the sequence to a non-final number for the locktime transactions to be
123
+ // processed correctly.
124
+ // We waited 2 blocks, keep 1 for safety
125
+ sequence : Sequence :: from_height ( 1 ) ,
126
+ ..Default :: default ( )
127
+ } ;
128
128
psbt. unsigned_tx . input . push ( txin) ;
129
129
// Get a new script pubkey from the node so that
130
130
// the node wallet tracks the receiving transaction
@@ -160,7 +160,7 @@ pub fn test_desc_satisfy(
160
160
let internal_key_present = x_only_pks
161
161
. iter ( )
162
162
. position ( |& x| x. to_public_key ( ) == * tr. internal_key ( ) ) ;
163
- let internal_keypair = internal_key_present. map ( |idx| xonly_keypairs[ idx] . clone ( ) ) ;
163
+ let internal_keypair = internal_key_present. map ( |idx| xonly_keypairs[ idx] ) ;
164
164
let prevouts = [ witness_utxo] ;
165
165
let prevouts = sighash:: Prevouts :: All ( & prevouts) ;
166
166
@@ -177,8 +177,7 @@ pub fn test_desc_satisfy(
177
177
rand:: thread_rng ( ) . fill_bytes ( & mut aux_rand) ;
178
178
let schnorr_sig =
179
179
secp. sign_schnorr_with_aux_rand ( & msg, & internal_keypair, & aux_rand) ;
180
- psbt. inputs [ 0 ] . tap_key_sig =
181
- Some ( taproot:: Signature { sig : schnorr_sig, hash_ty : hash_ty } ) ;
180
+ psbt. inputs [ 0 ] . tap_key_sig = Some ( taproot:: Signature { sig : schnorr_sig, hash_ty } ) ;
182
181
} else {
183
182
// No internal key
184
183
}
@@ -189,7 +188,7 @@ pub fn test_desc_satisfy(
189
188
let leaf_hash = TapLeafHash :: from_script ( & ms. encode ( ) , LeafVersion :: TapScript ) ;
190
189
ms. iter_pk ( ) . filter_map ( move |pk| {
191
190
let i = x_only_pks. iter ( ) . position ( |& x| x. to_public_key ( ) == pk) ;
192
- i. map ( |idx| ( xonly_keypairs[ idx] . clone ( ) , leaf_hash) )
191
+ i. map ( |idx| ( xonly_keypairs[ idx] , leaf_hash) )
193
192
} )
194
193
} )
195
194
. collect ( ) ;
@@ -205,14 +204,14 @@ pub fn test_desc_satisfy(
205
204
x_only_pks[ xonly_keypairs. iter ( ) . position ( |& x| x == keypair) . unwrap ( ) ] ;
206
205
psbt. inputs [ 0 ]
207
206
. tap_script_sigs
208
- . insert ( ( x_only_pk, leaf_hash) , taproot:: Signature { sig, hash_ty : hash_ty } ) ;
207
+ . insert ( ( x_only_pk, leaf_hash) , taproot:: Signature { sig, hash_ty } ) ;
209
208
}
210
209
}
211
210
_ => {
212
211
// Non-tr descriptors
213
212
// Ecdsa sigs
214
213
let sks_reqd = match derived_desc {
215
- Descriptor :: Bare ( bare) => find_sks_ms ( & bare. as_inner ( ) , testdata) ,
214
+ Descriptor :: Bare ( bare) => find_sks_ms ( bare. as_inner ( ) , testdata) ,
216
215
Descriptor :: Pkh ( pk) => find_sk_single_key ( * pk. as_inner ( ) , testdata) ,
217
216
Descriptor :: Wpkh ( pk) => find_sk_single_key ( * pk. as_inner ( ) , testdata) ,
218
217
Descriptor :: Sh ( sh) => match sh. as_inner ( ) {
@@ -221,7 +220,7 @@ pub fn test_desc_satisfy(
221
220
let ms = Miniscript :: from_ast ( smv. sorted_node ( ) ) . unwrap ( ) ;
222
221
find_sks_ms ( & ms, testdata)
223
222
}
224
- miniscript:: descriptor:: WshInner :: Ms ( ref ms) => find_sks_ms ( & ms, testdata) ,
223
+ miniscript:: descriptor:: WshInner :: Ms ( ref ms) => find_sks_ms ( ms, testdata) ,
225
224
} ,
226
225
miniscript:: descriptor:: ShInner :: Wpkh ( pk) => {
227
226
find_sk_single_key ( * pk. as_inner ( ) , testdata)
@@ -230,14 +229,14 @@ pub fn test_desc_satisfy(
230
229
let ms = Miniscript :: from_ast ( smv. sorted_node ( ) ) . unwrap ( ) ;
231
230
find_sks_ms ( & ms, testdata)
232
231
}
233
- miniscript:: descriptor:: ShInner :: Ms ( ms) => find_sks_ms ( & ms, testdata) ,
232
+ miniscript:: descriptor:: ShInner :: Ms ( ms) => find_sks_ms ( ms, testdata) ,
234
233
} ,
235
234
Descriptor :: Wsh ( wsh) => match wsh. as_inner ( ) {
236
235
miniscript:: descriptor:: WshInner :: SortedMulti ( ref smv) => {
237
236
let ms = Miniscript :: from_ast ( smv. sorted_node ( ) ) . unwrap ( ) ;
238
237
find_sks_ms ( & ms, testdata)
239
238
}
240
- miniscript:: descriptor:: WshInner :: Ms ( ref ms) => find_sks_ms ( & ms, testdata) ,
239
+ miniscript:: descriptor:: WshInner :: Ms ( ref ms) => find_sks_ms ( ms, testdata) ,
241
240
} ,
242
241
Descriptor :: Tr ( _tr) => unreachable ! ( "Tr checked earlier" ) ,
243
242
} ;
@@ -256,7 +255,7 @@ pub fn test_desc_satisfy(
256
255
assert ! ( secp. verify_ecdsa( & msg, & sig, & pk. inner) . is_ok( ) ) ;
257
256
psbt. inputs [ 0 ]
258
257
. partial_sigs
259
- . insert ( pk, ecdsa:: Signature { sig, hash_ty : hash_ty } ) ;
258
+ . insert ( pk, ecdsa:: Signature { sig, hash_ty } ) ;
260
259
}
261
260
}
262
261
}
@@ -277,7 +276,7 @@ pub fn test_desc_satisfy(
277
276
println ! ( "Testing descriptor: {}" , definite_desc) ;
278
277
// Finalize the transaction using psbt
279
278
// Let miniscript do it's magic!
280
- if let Err ( _ ) = psbt. finalize_mut ( & secp) {
279
+ if psbt. finalize_mut ( & secp) . is_err ( ) {
281
280
return Err ( DescError :: PsbtFinalizeError ) ;
282
281
}
283
282
let tx = psbt. extract ( & secp) . expect ( "Extraction error" ) ;
@@ -287,7 +286,7 @@ pub fn test_desc_satisfy(
287
286
// Check whether the node accepts the transactions
288
287
let txid = cl
289
288
. send_raw_transaction ( & tx)
290
- . expect ( & format ! ( "send tx failed for desc {}" , definite_desc) ) ;
289
+ . unwrap_or_else ( |_| panic ! ( "send tx failed for desc {}" , definite_desc) ) ;
291
290
292
291
// Finally mine the blocks and await confirmations
293
292
let _blocks = cl
@@ -298,7 +297,7 @@ pub fn test_desc_satisfy(
298
297
// Assert that the confirmations are > 0.
299
298
let num_conf = cl. get_transaction ( & txid, None ) . unwrap ( ) . info . confirmations ;
300
299
assert ! ( num_conf > 0 ) ;
301
- return Ok ( tx. input [ 0 ] . witness . clone ( ) ) ;
300
+ Ok ( tx. input [ 0 ] . witness . clone ( ) )
302
301
}
303
302
304
303
// Find all secret corresponding to the known public keys in ms
0 commit comments