@@ -49,6 +49,8 @@ struct splice_command {
4949 struct channel_id * * channel_ids ;
5050 /* For multi-channel stfu command: the pending result */
5151 struct stfu_result * * results ;
52+ /* The user provided PSBT's version */
53+ u32 user_psbt_ver ;
5254};
5355
5456void channel_update_feerates (struct lightningd * ld , const struct channel * channel )
@@ -409,6 +411,13 @@ static void handle_splice_confirmed_init(struct lightningd *ld,
409411 return ;
410412 }
411413
414+ if (psbt -> version != cc -> user_psbt_ver
415+ && !psbt_set_version (psbt , cc -> user_psbt_ver ))
416+ channel_internal_error (channel , "Splice failed to convert from"
417+ " internal version " PRIu32 " to user"
418+ " version " PRIu32 , psbt -> version ,
419+ cc -> user_psbt_ver );
420+
412421 struct json_stream * response = json_stream_success (cc -> cmd );
413422 json_add_string (response , "psbt" , fmt_wally_psbt (tmpctx , psbt ));
414423
@@ -443,6 +452,13 @@ static void handle_splice_confirmed_update(struct lightningd *ld,
443452 return ;
444453 }
445454
455+ if (psbt -> version != cc -> user_psbt_ver
456+ && !psbt_set_version (psbt , cc -> user_psbt_ver ))
457+ channel_internal_error (channel , "Splice failed to convert from"
458+ " internal version " PRIu32 " to user"
459+ " version " PRIu32 , psbt -> version ,
460+ cc -> user_psbt_ver );
461+
446462 struct json_stream * response = json_stream_success (cc -> cmd );
447463 json_add_string (response , "psbt" , fmt_wally_psbt (tmpctx , psbt ));
448464 json_add_bool (response , "commitments_secured" , commitments_secured );
@@ -2271,6 +2287,12 @@ static struct command_result *json_splice_init(struct command *cmd,
22712287 cc -> channel = channel ;
22722288 cc -> channel_ids = NULL ;
22732289 cc -> results = NULL ;
2290+ cc -> user_psbt_ver = initialpsbt -> version ;
2291+
2292+ if (initialpsbt -> version != 2 && !psbt_set_version (initialpsbt , 2 ))
2293+ return command_fail (cmd ,
2294+ SPLICE_INPUT_ERROR ,
2295+ "Splice failed to convert to v2" );
22742296
22752297 msg = towire_channeld_splice_init (NULL , initialpsbt , * relative_amount ,
22762298 * feerate_per_kw , * force_feerate ,
@@ -2317,6 +2339,12 @@ static struct command_result *json_splice_update(struct command *cmd,
23172339 cc -> channel = channel ;
23182340 cc -> channel_ids = NULL ;
23192341 cc -> results = NULL ;
2342+ cc -> user_psbt_ver = psbt -> version ;
2343+
2344+ if (psbt -> version != 2 && !psbt_set_version (psbt , 2 ))
2345+ return command_fail (cmd ,
2346+ SPLICE_INPUT_ERROR ,
2347+ "Splice failed to convert to v2" );
23202348
23212349 subd_send_msg (channel -> owner ,
23222350 take (towire_channeld_splice_update (NULL , psbt )));
@@ -2347,6 +2375,12 @@ static struct command_result *single_splice_signed(struct command *cmd,
23472375 cc -> channel = channel ;
23482376 cc -> channel_ids = NULL ;
23492377 cc -> results = NULL ;
2378+ cc -> user_psbt_ver = psbt -> version ;
2379+
2380+ if (psbt -> version != 2 && !psbt_set_version (psbt , 2 ))
2381+ return command_fail (cmd ,
2382+ SPLICE_INPUT_ERROR ,
2383+ "Splice failed to convert to v2" );
23502384
23512385 msg = towire_channeld_splice_signed (tmpctx , psbt , sign_first );
23522386 subd_send_msg (channel -> owner , take (msg ));
@@ -2378,6 +2412,9 @@ static struct command_result *json_splice_signed(struct command *cmd,
23782412 return command_fail (cmd , SPLICE_INPUT_ERROR ,
23792413 "PSBT failed to validate." );
23802414
2415+ log_debug (cmd -> ld -> log , "splice_signed input PSBT version %d" ,
2416+ psbt -> version );
2417+
23812418 /* If a single channel is specified, we do that and finish. */
23822419 if (channel ) {
23832420 if (command_check_only (cmd ))
0 commit comments