@@ -998,6 +998,42 @@ static void sendpsbt_done(struct bitcoind *bitcoind UNUSED,
998998 was_pending (command_success (sending -> cmd , response ));
999999}
10001000
1001+ static struct command_result * json_dev_finalizepsbt (struct command * cmd ,
1002+ const char * buffer ,
1003+ const jsmntok_t * obj ,
1004+ const jsmntok_t * params )
1005+ {
1006+ struct wally_psbt * psbt ;
1007+ struct wally_tx * wtx ;
1008+ struct bitcoin_txid txid ;
1009+ struct json_stream * response ;
1010+
1011+ if (!param_check (cmd , buffer , params ,
1012+ p_req ("psbt" , param_psbt , & psbt ),
1013+ NULL ))
1014+ return command_param_failed ();
1015+
1016+ if (!psbt_finalize (psbt ))
1017+ return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
1018+ "PSBT not finalizeable" );
1019+
1020+ wtx = psbt_final_tx (cmd , psbt );
1021+ wally_txid (wtx , & txid );
1022+
1023+ response = json_stream_success (cmd );
1024+ json_add_psbt (response , "psbt" , psbt );
1025+ json_add_hex_talarr (response , "tx" , linearize_wtx (tmpctx , wtx ));
1026+ json_add_txid (response , "txid" , & txid );
1027+ return command_success (cmd , response );
1028+ }
1029+
1030+ static const struct json_command dev_finalizepsbt_command = {
1031+ "dev-finalizepsbt" ,
1032+ json_dev_finalizepsbt ,
1033+ true,
1034+ };
1035+ AUTODATA (json_command , & dev_finalizepsbt_command );
1036+
10011037static struct command_result * json_sendpsbt (struct command * cmd ,
10021038 const char * buffer ,
10031039 const jsmntok_t * obj ,
0 commit comments