@@ -17,7 +17,7 @@ use bitcoin::{
17
17
absolute, psbt, secp256k1, sighash, transaction, Amount , OutPoint , Sequence , Transaction , TxIn ,
18
18
TxOut , Txid ,
19
19
} ;
20
- use bitcoind:: bitcoincore_rpc :: { json , Client , RpcApi } ;
20
+ use bitcoind:: { AddressType , Client } ;
21
21
use miniscript:: bitcoin:: { self , ecdsa, taproot, ScriptBuf } ;
22
22
use miniscript:: psbt:: { PsbtExt , PsbtInputExt } ;
23
23
use miniscript:: { Descriptor , Miniscript , ScriptContext , ToPublicKey } ;
@@ -30,11 +30,13 @@ fn btc<F: Into<f64>>(btc: F) -> Amount { Amount::from_btc(btc.into()).unwrap() }
30
30
31
31
// Find the Outpoint by spk
32
32
fn get_vout ( cl : & Client , txid : Txid , value : Amount , spk : ScriptBuf ) -> ( OutPoint , TxOut ) {
33
- let tx = cl
34
- . get_transaction ( & txid, None )
35
- . unwrap ( )
36
- . transaction ( )
37
- . unwrap ( ) ;
33
+ let model = cl
34
+ . get_transaction ( txid)
35
+ . expect ( "rpc call failed" )
36
+ . into_model ( )
37
+ . expect ( "conversion to model type failed" ) ;
38
+ let tx = model. tx ;
39
+
38
40
for ( i, txout) in tx. output . into_iter ( ) . enumerate ( ) {
39
41
if txout. value == value && spk == txout. script_pubkey {
40
42
return ( OutPoint :: new ( txid, i as u32 ) , txout) ;
@@ -77,9 +79,9 @@ pub fn test_desc_satisfy(
77
79
let x_only_pks = & testdata. pubdata . x_only_pks ;
78
80
// Generate some blocks
79
81
let blocks = cl
80
- . generate_to_address ( 1 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
82
+ . generate_to_address ( 1 , & cl. new_address ( ) . unwrap ( ) )
81
83
. unwrap ( ) ;
82
- assert_eq ! ( blocks. len( ) , 1 ) ;
84
+ assert_eq ! ( blocks. 0 . len( ) , 1 ) ;
83
85
84
86
let definite_desc = test_util:: parse_test_desc ( descriptor, & testdata. pubdata )
85
87
. map_err ( |_| DescError :: DescParseError ) ?
@@ -92,13 +94,15 @@ pub fn test_desc_satisfy(
92
94
93
95
// Next send some btc to each address corresponding to the miniscript
94
96
let txid = cl
95
- . send_to_address ( & desc_address, btc ( 1 ) , None , None , None , None , None , None )
96
- . unwrap ( ) ;
97
+ . send_to_address ( & desc_address, btc ( 1 ) )
98
+ . expect ( "rpc call failed" )
99
+ . txid ( )
100
+ . expect ( "conversion to model failed" ) ;
97
101
// Wait for the funds to mature.
98
102
let blocks = cl
99
- . generate_to_address ( 2 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
103
+ . generate_to_address ( 2 , & cl. new_address ( ) . unwrap ( ) )
100
104
. unwrap ( ) ;
101
- assert_eq ! ( blocks. len( ) , 2 ) ;
105
+ assert_eq ! ( blocks. 0 . len( ) , 2 ) ;
102
106
// Create a PSBT for each transaction.
103
107
// Spend one input and spend one output for simplicity.
104
108
let mut psbt = Psbt {
@@ -129,10 +133,7 @@ pub fn test_desc_satisfy(
129
133
// Get a new script pubkey from the node so that
130
134
// the node wallet tracks the receiving transaction
131
135
// and we can check it by gettransaction RPC.
132
- let addr = cl
133
- . get_new_address ( None , Some ( json:: AddressType :: Bech32 ) )
134
- . unwrap ( )
135
- . assume_checked ( ) ;
136
+ let addr = cl. new_address_with_type ( AddressType :: Bech32 ) . unwrap ( ) ;
136
137
// Had to decrease 'value', so that fees can be increased
137
138
// (Was getting insufficient fees error, for deep script trees)
138
139
psbt. unsigned_tx
@@ -287,16 +288,18 @@ pub fn test_desc_satisfy(
287
288
// Check whether the node accepts the transactions
288
289
let txid = cl
289
290
. send_raw_transaction ( & tx)
290
- . unwrap_or_else ( |_| panic ! ( "send tx failed for desc {}" , definite_desc) ) ;
291
+ . unwrap_or_else ( |_| panic ! ( "send tx failed for desc {}" , definite_desc) )
292
+ . txid ( )
293
+ . expect ( "conversion to model failed" ) ;
291
294
292
295
// Finally mine the blocks and await confirmations
293
296
let _blocks = cl
294
- . generate_to_address ( 1 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
297
+ . generate_to_address ( 1 , & cl. new_address ( ) . unwrap ( ) )
295
298
. unwrap ( ) ;
296
299
// Get the required transactions from the node mined in the blocks.
297
300
// Check whether the transaction is mined in blocks
298
301
// Assert that the confirmations are > 0.
299
- let num_conf = cl. get_transaction ( & txid, None ) . unwrap ( ) . info . confirmations ;
302
+ let num_conf = cl. get_transaction ( txid) . unwrap ( ) . confirmations ;
300
303
assert ! ( num_conf > 0 ) ;
301
304
Ok ( tx. input [ 0 ] . witness . clone ( ) )
302
305
}
0 commit comments