Skip to content

Commit

Permalink
splice: Add support for out-of-bound tx_sig
Browse files Browse the repository at this point in the history
If the peer isn’t required to send signatures first but does while we are awaiting the next user RPC action — we should be caching the message and using it later.

Before we would leave the message cached in the socket itself, but tx_abort semantics require us to check the socket more often.
  • Loading branch information
ddustin authored and cdecker committed Feb 11, 2024
1 parent b8a2c39 commit b011453
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
26 changes: 22 additions & 4 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -3363,6 +3363,13 @@ static void resume_splice_negotiation(struct peer *peer,
their_pubkey = &peer->channel->funding_pubkey[REMOTE];

if (recv_signature) {
if (peer->splicing && peer->splicing->tx_sig_msg) {
msg_received = tal_steal(tmpctx,
peer->splicing->tx_sig_msg);
peer->splicing->tx_sig_msg = NULL;
status_debug("Splice is using cached tx_sig_msg");
}

if (fromwire_peektype(msg_received) == WIRE_TX_SIGNATURES)
msg = msg_received;
else
Expand Down Expand Up @@ -4229,10 +4236,21 @@ static void peer_in(struct peer *peer, const u8 *msg)

/* If we're in STFU mode and aren't waiting for a STFU mode
* specific message, the only valid message was tx_abort */
if (is_stfu_active(peer) && !peer->stfu_wait_single_msg)
peer_failed_warn(peer->pps, &peer->channel_id,
"Received message %s when only TX_ABORT was"
" valid", peer_wire_name(type));
if (is_stfu_active(peer) && !peer->stfu_wait_single_msg) {
if (peer->splicing && type == WIRE_TX_SIGNATURES) {
if (peer->splicing->tx_sig_msg)
peer_failed_warn(peer->pps, &peer->channel_id,
"Received TX_SIGNATURES while"
" we already have one cached");
peer->splicing->tx_sig_msg = tal_steal(peer->splicing,
msg);
return;
} else {
peer_failed_warn(peer->pps, &peer->channel_id,
"Received message %s when only TX_ABORT was"
" valid", peer_wire_name(type));
}
}

/* Must get channel_ready before almost anything. */
if (!peer->channel_ready[REMOTE]) {
Expand Down
1 change: 1 addition & 0 deletions channeld/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct splicing *splicing_new(const tal_t *ctx)
splicing->current_psbt = NULL;
splicing->received_tx_complete = false;
splicing->sent_tx_complete = false;
splicing->tx_sig_msg = NULL;

return splicing;
}
2 changes: 2 additions & 0 deletions channeld/splice.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct splicing {
bool received_tx_complete;
/* If, in the last splice_update, we sent tx_complete */
bool sent_tx_complete;
/* If our peer signs early, we allow that and cache it here */
const u8 *tx_sig_msg;
};

/* Sets `splice` items to default values */
Expand Down

0 comments on commit b011453

Please sign in to comment.