Skip to content

Commit 2b196f3

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 879ec7c commit 2b196f3

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
@@ -3485,6 +3485,12 @@ static void resume_splice_negotiation(struct peer *peer,
34853485
"Splicing bad tx_signatures msg %s",
34863486
tal_hex(msg, msg));
34873487

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

@@ -3501,8 +3507,8 @@ static void resume_splice_negotiation(struct peer *peer,
35013507
/* BOLT-a8b9f495cac28124c69cc5ee429f9ef2bacb9921 #2:
35023508
* Both nodes:
35033509
* - MUST sign the transaction using SIGHASH_ALL */
3504-
their_sig.sighash_type = SIGHASH_ALL;
3505-
their_sig.s = *their_txsigs_tlvs->shared_input_signature;
3510+
their_sig->sighash_type = SIGHASH_ALL;
3511+
their_sig->s = *their_txsigs_tlvs->shared_input_signature;
35063512

35073513
/* Set the commit_sig on the commitment tx psbt */
35083514
if (!psbt_input_set_signature(current_psbt,
@@ -3727,7 +3733,7 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
37273733
peer_failed_warn(peer->pps, &peer->channel_id,
37283734
"Splice internal error: mismatched channelid");
37293735

3730-
if (!pubkey_eq(&splice_remote_pubkey,
3736+
if (!pubkey_eq(&peer->splicing->remote_funding_pubkey,
37313737
&peer->channel->funding_pubkey[REMOTE]))
37323738
peer_failed_warn(peer->pps, &peer->channel_id,
37333739
"Splice doesnt support changing pubkeys");
@@ -3758,6 +3764,11 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
37583764
ictx->desired_psbt = NULL;
37593765
ictx->pause_when_complete = false;
37603766

3767+
ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint);
3768+
*ictx->shared_outpoint = peer->channel->funding;
3769+
ictx->funding_tx = bitcoin_tx_from_txid(peer,
3770+
peer->channel->funding.txid);
3771+
37613772
error = process_interactivetx_updates(tmpctx, ictx,
37623773
&peer->splicing->received_tx_complete,
37633774
&abort_msg);
@@ -3845,6 +3856,7 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg)
38453856
u32 sequence = 0;
38463857
u8 *scriptPubkey;
38473858

3859+
/* DTODO: Remove ictx from this function as its no longer used. */
38483860
ictx = new_interactivetx_context(tmpctx, TX_INITIATOR,
38493861
peer->pps, peer->channel_id);
38503862

@@ -3860,7 +3872,7 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg)
38603872
peer_failed_warn(peer->pps, &peer->channel_id,
38613873
"Splice[ACK] internal error: mismatched channelid");
38623874

3863-
if (!pubkey_eq(&splice_remote_pubkey,
3875+
if (!pubkey_eq(&peer->splicing->remote_funding_pubkey,
38643876
&peer->channel->funding_pubkey[REMOTE]))
38653877
peer_failed_warn(peer->pps, &peer->channel_id,
38663878
"Splice[ACK] doesnt support changing pubkeys");
@@ -3926,6 +3938,10 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg)
39263938

39273939
psbt_add_serials(ictx->desired_psbt, ictx->our_role);
39283940

3941+
ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint);
3942+
*ictx->shared_outpoint = peer->channel->funding;
3943+
ictx->funding_tx = prev_tx;
3944+
39293945
peer->splicing->tx_add_input_count = 0;
39303946
peer->splicing->tx_add_output_count = 0;
39313947

@@ -3949,6 +3965,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
39493965
{
39503966
u8 *outmsg;
39513967
struct interactivetx_context *ictx;
3968+
struct bitcoin_tx *prev_tx;
39523969
bool sign_first;
39533970
char *error;
39543971
u32 chan_output_index, splice_funding_index;
@@ -3961,6 +3978,9 @@ static void splice_initiator_user_finalized(struct peer *peer)
39613978
const enum tx_role our_role = TX_INITIATOR;
39623979
u8 *abort_msg;
39633980

3981+
/* We must loading the funding tx as our previous utxo */
3982+
prev_tx = bitcoin_tx_from_txid(peer, peer->channel->funding.txid);
3983+
39643984
ictx = new_interactivetx_context(tmpctx, our_role,
39653985
peer->pps, peer->channel_id);
39663986

@@ -3970,6 +3990,10 @@ static void splice_initiator_user_finalized(struct peer *peer)
39703990
ictx->tx_add_input_count = peer->splicing->tx_add_input_count;
39713991
ictx->tx_add_output_count = peer->splicing->tx_add_output_count;
39723992

3993+
ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint);
3994+
*ictx->shared_outpoint = peer->channel->funding;
3995+
ictx->funding_tx = prev_tx;
3996+
39733997
error = process_interactivetx_updates(tmpctx, ictx,
39743998
&peer->splicing->received_tx_complete,
39753999
&abort_msg);

0 commit comments

Comments
 (0)