@@ -247,60 +247,19 @@ fn arbitrary_multisig_script() -> ScriptBuf {
247247}
248248
249249#[ test]
250- #[ cfg( feature = "TODO" ) ]
251250fn raw_transactions__finalize_psbt__modelled ( ) {
252- let node = Node :: with_wallet ( Wallet :: Default , & [ "-txindex" ] ) ;
251+ let node = Node :: with_wallet ( Wallet :: Default , & [ ] ) ;
253252 node. fund_wallet ( ) ;
254253
255- let ( addr, _tx, txid, tx_out, vout) = create_utxo ( & node) ;
256-
257- // Assumes tx_out has a million sats in it.
258- let spend_amount = Amount :: from_sat ( 100_000 ) ;
259- let fee = Amount :: from_sat ( 1000 ) ;
260- let change_amount = tx_out. value - spend_amount - fee;
261-
262- let inputs = vec ! [ Input { txid, vout, sequence: None } ] ;
263-
264- let mut outputs = vec ! [ ] ;
265-
266- // Just send back to ourself.
267- let spend_address = node. client . new_address ( ) . expect ( "failed to create new address" ) ;
268- outputs. push ( Output :: new ( spend_address, spend_amount) ) ;
269-
270- let change_address = node
271- . client
272- . get_raw_change_address ( )
273- . expect ( "getrawchangeaddress" )
274- . into_model ( )
275- . expect ( "GetRawChangeAddress into model" )
276- . 0
277- . assume_checked ( ) ;
278- outputs. push ( Output :: new ( change_address, change_amount) ) ;
279-
280- let json: CreatePsbt = node. client . create_psbt ( & inputs, & outputs) . expect ( "createpsbt" ) ;
281- let res: Result < mtype:: CreatePsbt , _ > = json. clone ( ) . into_model ( ) ;
282- let psbt = res. expect ( "CreatePsbt into model" ) ;
283- let psbt = psbt. 0 ;
284-
285- let json: DumpPrivKey = node. client . dump_priv_key ( & addr) . expect ( "dumpprivkey" ) ;
286- let model: mtype:: DumpPrivKey = json. into_model ( ) . expect ( "DumpPrivKey" ) ;
287- let key = model. 0 ;
288-
289- let json: SignRawTransaction = node
290- . client
291- . sign_raw_transaction_with_key ( & psbt. unsigned_tx , & [ key] )
292- . expect ( "signrawtransactionwithkey" ) ;
293- let res: Result < mtype:: SignRawTransaction , SignRawTransactionError > = json. into_model ( ) ;
294- let model = res. expect ( "SignRawTransaction into model" ) ;
295-
296- // FIXME: Core errors here with: code: -22, message: "TX decode failed"
297- let json: ConvertToPsbt = node. client . convert_to_psbt ( & model. tx ) . expect ( "converttopsbt" ) ;
298- let model: Result < mtype:: ConvertToPsbt , _ > = json. into_model ( ) ;
299- let psbt = model. expect ( "ConvertToPsbt into model" ) . 0 ;
300-
254+ // Create a PSBT and call finalizepsbt directly without signing.
255+ // This still exercises the RPC and model; it should report complete=false and return the PSBT.
256+ let psbt = create_a_psbt ( & node) ;
301257 let json: FinalizePsbt = node. client . finalize_psbt ( & psbt) . expect ( "finalizepsbt" ) ;
302- let model: Result < mtype:: FinalizePsbt , _ > = json. into_model ( ) ;
303- let _ = model. expect ( "FinalizePsbt into model" ) ;
258+ let model: Result < mtype:: FinalizePsbt , FinalizePsbtError > = json. into_model ( ) ;
259+ let finalized = model. unwrap ( ) ;
260+
261+ assert ! ( !finalized. complete) ;
262+ assert_eq ! ( finalized. psbt, Some ( psbt) ) ;
304263}
305264
306265#[ test]
0 commit comments