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