Skip to content

Commit f3aa64d

Browse files
committed
splice: Add call to hsmd_sync_outpoint when mutual channel_ready
1 parent b005aab commit f3aa64d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

channeld/channeld.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,22 @@ static bool channel_announcement_negotiate(struct peer *peer)
681681
return sent_announcement;
682682
}
683683

684+
/* Call this method when channel_ready status are changed. */
685+
static void check_mutual_channel_ready(struct peer *peer)
686+
{
687+
const u8 *msg;
688+
if (peer->channel_ready[LOCAL] && peer->channel_ready[REMOTE]) {
689+
/* Make sure the hsmd agrees that this outpoint is
690+
* sufficiently buried. */
691+
msg = towire_hsmd_sync_outpoint(NULL, &peer->channel->funding);
692+
msg = hsm_req(tmpctx, take(msg));
693+
if (!fromwire_hsmd_sync_outpoint_reply(msg))
694+
status_failed(STATUS_FAIL_HSM_IO,
695+
"Bad hsmd_sync_outpoint_reply: %s",
696+
tal_hex(tmpctx, msg));
697+
}
698+
}
699+
684700
/* Call this method when splice_locked status are changed. If both sides have
685701
* splice_locked'ed than this function consumes the `splice_locked_ready` values
686702
* and considers the channel funding to be switched to the splice tx. */
@@ -841,6 +857,7 @@ static void handle_peer_channel_ready(struct peer *peer, const u8 *msg)
841857

842858
peer->tx_sigs_allowed = false;
843859
peer->channel_ready[REMOTE] = true;
860+
check_mutual_channel_ready(peer);
844861
if (tlvs->short_channel_id != NULL) {
845862
status_debug(
846863
"Peer told us that they'll use alias=%s for this channel",
@@ -5238,6 +5255,7 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
52385255
peer_write(peer->pps, take(msg));
52395256

52405257
peer->channel_ready[LOCAL] = true;
5258+
check_mutual_channel_ready(peer);
52415259
}
52425260
else if(splicing && !peer->splice_state->locked_ready[LOCAL]) {
52435261
assert(scid);

openingd/dualopend.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,22 @@ static void billboard_update(struct state *state)
424424
peer_billboard(false, update);
425425
}
426426

427+
/* Call this method when channel_ready status are changed. */
428+
static void check_mutual_channel_ready(struct state *state)
429+
{
430+
u8 *msg;
431+
if (state->channel_ready[LOCAL] && state->channel_ready[REMOTE]) {
432+
/* Make sure the hsmd agrees that this outpoint is
433+
* sufficiently buried. */
434+
msg = towire_hsmd_sync_outpoint(NULL, &state->channel->funding);
435+
wire_sync_write(HSM_FD, take(msg));
436+
msg = wire_sync_read(tmpctx, HSM_FD);
437+
if (!fromwire_hsmd_sync_outpoint_reply(msg))
438+
status_failed(STATUS_FAIL_HSM_IO, "Bad hsmd_sync_outpoint_reply %s",
439+
tal_hex(tmpctx, msg));
440+
}
441+
}
442+
427443
static void send_shutdown(struct state *state, const u8 *final_scriptpubkey)
428444
{
429445
u8 *msg;
@@ -1273,6 +1289,7 @@ static u8 *handle_channel_ready(struct state *state, u8 *msg)
12731289
}
12741290

12751291
state->channel_ready[REMOTE] = true;
1292+
check_mutual_channel_ready(state);
12761293
billboard_update(state);
12771294

12781295
if (state->channel_ready[LOCAL])
@@ -3824,6 +3841,7 @@ static void send_channel_ready(struct state *state)
38243841
peer_write(state->pps, take(msg));
38253842

38263843
state->channel_ready[LOCAL] = true;
3844+
check_mutual_channel_ready(state);
38273845
billboard_update(state);
38283846
}
38293847

0 commit comments

Comments
 (0)