@@ -4315,6 +4315,8 @@ static void splice_initiator_user_finalized(struct peer *peer)
4315
4315
u8 * outmsg ;
4316
4316
struct interactivetx_context * ictx ;
4317
4317
struct bitcoin_tx * prev_tx ;
4318
+ struct bitcoin_tx * bitcoin_tx ;
4319
+ struct bitcoin_signature splice_sig ;
4318
4320
bool sign_first ;
4319
4321
char * error ;
4320
4322
u32 chan_output_index , splice_funding_index ;
@@ -4326,6 +4328,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
4326
4328
struct amount_msat current_push_val ;
4327
4329
const enum tx_role our_role = TX_INITIATOR ;
4328
4330
u8 * abort_msg ;
4331
+ const u8 * msg ;
4329
4332
4330
4333
/* We must loading the funding tx as our previous utxo */
4331
4334
prev_tx = bitcoin_tx_from_txid (peer , peer -> channel -> funding .txid );
@@ -4374,6 +4377,44 @@ static void splice_initiator_user_finalized(struct peer *peer)
4374
4377
4375
4378
psbt_elements_normalize_fees (ictx -> current_psbt );
4376
4379
4380
+ /* We have to sign the shared output early (here) for cases where we are
4381
+ * splicing between multiple channels simultaneously. This is so the
4382
+ * we can build a complete `tx_signatures` message when there are two
4383
+ * or more shared outputs between mulitple peers */
4384
+
4385
+ splice_sig .sighash_type = SIGHASH_ALL ;
4386
+
4387
+ bitcoin_tx = bitcoin_tx_with_psbt (tmpctx , ictx -> current_psbt );
4388
+
4389
+ status_info ("Splice pre-signing tx: %s" ,
4390
+ tal_hex (tmpctx , linearize_tx (tmpctx , bitcoin_tx )));
4391
+
4392
+ msg = towire_hsmd_sign_splice_tx (tmpctx , bitcoin_tx ,
4393
+ & peer -> channel -> funding_pubkey [REMOTE ],
4394
+ splice_funding_index );
4395
+
4396
+ msg = hsm_req (tmpctx , take (msg ));
4397
+ if (!fromwire_hsmd_sign_tx_reply (msg , & splice_sig ))
4398
+ status_failed (STATUS_FAIL_HSM_IO ,
4399
+ "Reading sign_splice_tx reply: %s" ,
4400
+ tal_hex (tmpctx , msg ));
4401
+
4402
+ /* Set the splice_sig on the splice funding tx psbt */
4403
+ if (!psbt_input_set_signature (ictx -> current_psbt , splice_funding_index ,
4404
+ & peer -> channel -> funding_pubkey [LOCAL ],
4405
+ & splice_sig ))
4406
+ status_failed (STATUS_FAIL_INTERNAL_ERROR ,
4407
+ "Unable to pre-set signature internally "
4408
+ "funding_index: %d "
4409
+ "my pubkey: %s "
4410
+ "my signature: %s "
4411
+ "psbt: %s" ,
4412
+ splice_funding_index ,
4413
+ fmt_pubkey (tmpctx ,
4414
+ & peer -> channel -> funding_pubkey [LOCAL ]),
4415
+ fmt_bitcoin_signature (tmpctx , & splice_sig ),
4416
+ fmt_wally_psbt (tmpctx , ictx -> current_psbt ));
4417
+
4377
4418
status_debug ("Splice adding inflight: %s" ,
4378
4419
fmt_wally_psbt (tmpctx , ictx -> current_psbt ));
4379
4420
0 commit comments