Skip to content

Commit 3539d0f

Browse files
committed
splice: Enable shared tx on interactivetx
By placing the funding tx into `interactivetx`, the message will be compressed by only sending the txid via tlvs. Changelog-None
1 parent 319c615 commit 3539d0f

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

channeld/channeld.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3483,6 +3483,12 @@ static void resume_splice_negotiation(struct peer *peer,
34833483
"Splicing bad tx_signatures msg %s",
34843484
tal_hex(msg, msg));
34853485

3486+
if (!their_txsigs_tlvs->shared_input_signature)
3487+
peer_failed_warn(peer->pps, &peer->channel_id,
3488+
"tx_signatures msg must include"
3489+
" `shared_input_signature`. Msg: %s",
3490+
tal_hex(msg, msg));
3491+
34863492
if (peer->splicing)
34873493
peer->splicing->inws = tal_steal(peer->splicing, inws);
34883494

@@ -3499,8 +3505,8 @@ static void resume_splice_negotiation(struct peer *peer,
34993505
/* BOLT-a8b9f495cac28124c69cc5ee429f9ef2bacb9921 #2:
35003506
* Both nodes:
35013507
* - MUST sign the transaction using SIGHASH_ALL */
3502-
their_sig.sighash_type = SIGHASH_ALL;
3503-
their_sig.s = *their_txsigs_tlvs->shared_input_signature;
3508+
their_sig->sighash_type = SIGHASH_ALL;
3509+
their_sig->s = *their_txsigs_tlvs->shared_input_signature;
35043510

35053511
/* Set the commit_sig on the commitment tx psbt */
35063512
if (!psbt_input_set_signature(current_psbt,
@@ -3725,7 +3731,7 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
37253731
peer_failed_warn(peer->pps, &peer->channel_id,
37263732
"Splice internal error: mismatched channelid");
37273733

3728-
if (!pubkey_eq(&splice_remote_pubkey,
3734+
if (!pubkey_eq(&peer->splicing->remote_funding_pubkey,
37293735
&peer->channel->funding_pubkey[REMOTE]))
37303736
peer_failed_warn(peer->pps, &peer->channel_id,
37313737
"Splice doesnt support changing pubkeys");
@@ -3756,6 +3762,11 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
37563762
ictx->desired_psbt = NULL;
37573763
ictx->pause_when_complete = false;
37583764

3765+
ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint);
3766+
*ictx->shared_outpoint = peer->channel->funding;
3767+
ictx->funding_tx = bitcoin_tx_from_txid(peer,
3768+
peer->channel->funding.txid);
3769+
37593770
error = process_interactivetx_updates(tmpctx, ictx,
37603771
&peer->splicing->received_tx_complete,
37613772
&abort_msg);
@@ -3842,6 +3853,7 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg)
38423853
u32 sequence = 0;
38433854
u8 *scriptPubkey;
38443855

3856+
/* DTODO: Remove ictx from this function as its no longer used. */
38453857
ictx = new_interactivetx_context(tmpctx, TX_INITIATOR,
38463858
peer->pps, peer->channel_id);
38473859

@@ -3857,7 +3869,7 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg)
38573869
peer_failed_warn(peer->pps, &peer->channel_id,
38583870
"Splice[ACK] internal error: mismatched channelid");
38593871

3860-
if (!pubkey_eq(&splice_remote_pubkey,
3872+
if (!pubkey_eq(&peer->splicing->remote_funding_pubkey,
38613873
&peer->channel->funding_pubkey[REMOTE]))
38623874
peer_failed_warn(peer->pps, &peer->channel_id,
38633875
"Splice[ACK] doesnt support changing pubkeys");
@@ -3923,6 +3935,10 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg)
39233935

39243936
psbt_add_serials(ictx->desired_psbt, ictx->our_role);
39253937

3938+
ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint);
3939+
*ictx->shared_outpoint = peer->channel->funding;
3940+
ictx->funding_tx = prev_tx;
3941+
39263942
peer->splicing->tx_add_input_count = 0;
39273943
peer->splicing->tx_add_output_count = 0;
39283944

@@ -3946,6 +3962,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
39463962
{
39473963
u8 *outmsg;
39483964
struct interactivetx_context *ictx;
3965+
struct bitcoin_tx *prev_tx;
39493966
bool sign_first;
39503967
char *error;
39513968
u32 chan_output_index, splice_funding_index;
@@ -3958,6 +3975,9 @@ static void splice_initiator_user_finalized(struct peer *peer)
39583975
const enum tx_role our_role = TX_INITIATOR;
39593976
u8 *abort_msg;
39603977

3978+
/* We must loading the funding tx as our previous utxo */
3979+
prev_tx = bitcoin_tx_from_txid(peer, peer->channel->funding.txid);
3980+
39613981
ictx = new_interactivetx_context(tmpctx, our_role,
39623982
peer->pps, peer->channel_id);
39633983

@@ -3967,6 +3987,10 @@ static void splice_initiator_user_finalized(struct peer *peer)
39673987
ictx->tx_add_input_count = peer->splicing->tx_add_input_count;
39683988
ictx->tx_add_output_count = peer->splicing->tx_add_output_count;
39693989

3990+
ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint);
3991+
*ictx->shared_outpoint = peer->channel->funding;
3992+
ictx->funding_tx = prev_tx;
3993+
39703994
error = process_interactivetx_updates(tmpctx, ictx,
39713995
&peer->splicing->received_tx_complete,
39723996
&abort_msg);

0 commit comments

Comments
 (0)