@@ -174,8 +174,11 @@ def run_test(self):
174
174
elif out ['scriptPubKey' ]['addresses' ][0 ] == p2pkh :
175
175
p2pkh_pos = out ['n' ]
176
176
177
+ inputs = [{"txid" : txid , "vout" : p2wpkh_pos }, {"txid" : txid , "vout" : p2sh_p2wpkh_pos }, {"txid" : txid , "vout" : p2pkh_pos }]
178
+ outputs = [{self .nodes [1 ].getnewaddress (): 29.99 }]
179
+
177
180
# spend single key from node 1
178
- created_psbt = self .nodes [1 ].walletcreatefundedpsbt ([{ "txid" : txid , "vout" : p2wpkh_pos },{ "txid" : txid , "vout" : p2sh_p2wpkh_pos },{ "txid" : txid , "vout" : p2pkh_pos }], { self . nodes [ 1 ]. getnewaddress (): 29.99 } )
181
+ created_psbt = self .nodes [1 ].walletcreatefundedpsbt (inputs , outputs )
179
182
walletprocesspsbt_out = self .nodes [1 ].walletprocesspsbt (created_psbt ['psbt' ])
180
183
# Make sure it has both types of UTXOs
181
184
decoded = self .nodes [1 ].decodepsbt (walletprocesspsbt_out ['psbt' ])
@@ -186,15 +189,17 @@ def run_test(self):
186
189
assert_equal (walletprocesspsbt_out ['complete' ], True )
187
190
self .nodes [1 ].sendrawtransaction (self .nodes [1 ].finalizepsbt (walletprocesspsbt_out ['psbt' ])['hex' ])
188
191
189
- # feeRate of 0.1 BTC / KB produces a total fee slightly below -maxtxfee (~0.05280000):
190
- res = self .nodes [1 ].walletcreatefundedpsbt ([{ "txid" : txid , "vout" : p2wpkh_pos },{ "txid" : txid , "vout" : p2sh_p2wpkh_pos },{ "txid" : txid , "vout" : p2pkh_pos }], { self . nodes [ 1 ]. getnewaddress (): 29.99 } , 0 , {"feeRate" : 0.1 , "add_inputs" : True })
192
+ self . log . info ( "Test walletcreatefundedpsbt feeRate of 0.1 BTC/kB produces a total fee at or slightly below -maxtxfee (~0.05290000)" )
193
+ res = self .nodes [1 ].walletcreatefundedpsbt (inputs , outputs , 0 , {"feeRate" : 0.1 , "add_inputs" : True })
191
194
assert_approx (res ["fee" ], 0.055 , 0.005 )
192
195
193
- # feeRate of 10 BTC / KB produces a total fee well above -maxtxfee
196
+ self . log . info ( "Test walletcreatefundedpsbt feeRate of 10 BTC/ KB produces total fee well above -maxtxfee and raises RPC error" )
194
197
# previously this was silently capped at -maxtxfee
195
- assert_raises_rpc_error (- 4 , "Fee exceeds maximum configured by user (e.g. -maxtxfee, maxfeerate)" , self .nodes [1 ].walletcreatefundedpsbt , [{"txid" :txid ,"vout" :p2wpkh_pos },{"txid" :txid ,"vout" :p2sh_p2wpkh_pos },{"txid" :txid ,"vout" :p2pkh_pos }], {self .nodes [1 ].getnewaddress ():29.99 }, 0 , {"feeRate" : 10 , "add_inputs" : True })
196
- assert_raises_rpc_error (- 4 , "Fee exceeds maximum configured by user (e.g. -maxtxfee, maxfeerate)" , self .nodes [1 ].walletcreatefundedpsbt , [{"txid" :txid ,"vout" :p2wpkh_pos },{"txid" :txid ,"vout" :p2sh_p2wpkh_pos },{"txid" :txid ,"vout" :p2pkh_pos }], {self .nodes [1 ].getnewaddress ():1 }, 0 , {"feeRate" : 10 , "add_inputs" : False })
198
+ for bool_add , outputs_array in {True : outputs , False : [{self .nodes [1 ].getnewaddress (): 1 }]}.items ():
199
+ assert_raises_rpc_error (- 4 , "Fee exceeds maximum configured by user (e.g. -maxtxfee, maxfeerate)" ,
200
+ self .nodes [1 ].walletcreatefundedpsbt , inputs , outputs_array , 0 , {"feeRate" : 10 , "add_inputs" : bool_add })
197
201
202
+ self .log .info ("Test various PSBT operations" )
198
203
# partially sign multisig things with node 1
199
204
psbtx = wmulti .walletcreatefundedpsbt (inputs = [{"txid" :txid ,"vout" :p2wsh_pos },{"txid" :txid ,"vout" :p2sh_pos },{"txid" :txid ,"vout" :p2sh_p2wsh_pos }], outputs = {self .nodes [1 ].getnewaddress ():29.99 }, options = {'changeAddress' : self .nodes [1 ].getrawchangeaddress ()})['psbt' ]
200
205
walletprocesspsbt_out = self .nodes [1 ].walletprocesspsbt (psbtx )
0 commit comments