@@ -885,6 +885,7 @@ static void onfunding_channel_tx_hook_serialize(struct onfunding_channel_tx_hook
885885 json_object_start (stream , "onfunding_channel_tx" );
886886 json_add_tx (stream , "tx" , payload -> tx );
887887 json_add_txid (stream , "txid" , & txid );
888+ json_add_psbt (stream , "psbt" , payload -> tx -> psbt );
888889 json_add_channel_id (stream , "channel_id" , payload -> cid );
889890 json_object_end (stream );
890891}
@@ -893,9 +894,9 @@ static bool onfunding_channel_tx_hook_deserialize(struct onfunding_channel_tx_ho
893894 const char * buffer ,
894895 const jsmntok_t * toks )
895896{
896- const jsmntok_t * result_tok , * error_tok , * tx_tok ;
897+ const jsmntok_t * result_tok , * error_tok ,
898+ * tx_tok , * psbt_tok ;
897899
898- log_info (payload -> openingd -> log , "buffer %s" , buffer );
899900 if ((error_tok = json_get_member (buffer , toks , "error" )) != NULL )
900901 fatal ("Plugin returned an error inside the response to the"
901902 " onfunding_channel_tx hook: %.*s" ,
@@ -911,12 +912,17 @@ static bool onfunding_channel_tx_hook_deserialize(struct onfunding_channel_tx_ho
911912 " onfunding_channel_tx hook: %.*s" ,
912913 toks [0 ].end - toks [0 ].start , buffer + toks [0 ].start );
913914
914- payload -> tx = NULL ;
915+ if ((psbt_tok = json_get_member (buffer , result_tok , "psbt" )) == NULL )
916+ fatal ("Plugin returned an invalid response (missing psbt) to the"
917+ " onfunding_channel_tx hook: %.*s" ,
918+ toks [0 ].end - toks [0 ].start , buffer + toks [0 ].start );
919+
915920 if (!json_to_tx (buffer , tx_tok , & payload -> tx ))
916921 fatal ("Plugin returned an invalid (json to tx) response to the"
917922 " onfunding_channel_tx hook: %.*s" ,
918923 tx_tok [0 ].end - tx_tok [0 ].start , buffer + tx_tok [0 ].start );
919- log_info (payload -> openingd -> log , "hook return the following tx: %s" , fmt_bitcoin_tx (tmpctx , payload -> tx ));
924+
925+ payload -> tx -> psbt = json_to_psbt (buffer , buffer , psbt_tok );
920926 return true;
921927}
922928
0 commit comments