Skip to content

Commit b8b6b15

Browse files
committed
Add call to ReadyChannel in splicing flow
1 parent 6efffc6 commit b8b6b15

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

channeld/channeld.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,7 @@ static u8 *send_commit_part(struct peer *peer,
15171517
peer->channel, &peer->remote_per_commit,
15181518
peer->next_index[REMOTE], REMOTE,
15191519
splice_amnt, remote_splice_amnt);
1520+
15201521
htlc_sigs =
15211522
calc_commitsigs(tmpctx, peer, txs, funding_wscript, htlc_map,
15221523
peer->next_index[REMOTE], &commit_sig);
@@ -3450,6 +3451,39 @@ static struct inflight *inflights_new(struct peer *peer)
34503451
return inf;
34513452
}
34523453

3454+
static void update_hsmd_with_splice(struct peer *peer, struct inflight *inflight)
3455+
{
3456+
u8 *msg;
3457+
3458+
// These aren't allowed to change, so we don't need to gather them
3459+
u8 *local_upfront_shutdown_script = NULL;
3460+
u32 * local_upfront_shutdown_wallet_index = NULL;
3461+
u8 *remote_upfront_shutdown_script = NULL;
3462+
3463+
// FIXME - the push_value needs to reflect what is owed to the non-opener
3464+
struct amount_msat push_value = AMOUNT_MSAT(0);
3465+
3466+
msg = towire_hsmd_ready_channel(
3467+
NULL,
3468+
peer->channel->opener == LOCAL,
3469+
inflight->amnt,
3470+
push_value,
3471+
&inflight->outpoint.txid,
3472+
inflight->outpoint.n,
3473+
peer->channel->config[LOCAL].to_self_delay,
3474+
local_upfront_shutdown_script,
3475+
local_upfront_shutdown_wallet_index,
3476+
&peer->channel->basepoints[REMOTE],
3477+
&peer->channel->funding_pubkey[REMOTE],
3478+
peer->channel->config[REMOTE].to_self_delay,
3479+
remote_upfront_shutdown_script,
3480+
peer->channel->type);
3481+
msg = (u8 *) hsm_req(tmpctx, take(msg));
3482+
if (!fromwire_hsmd_ready_channel_reply(msg))
3483+
status_failed(STATUS_FAIL_HSM_IO, "Bad ready_channel_reply %s",
3484+
tal_hex(tmpctx, msg));
3485+
}
3486+
34533487
/* ACCEPTER side of the splice. Here we handle all the accepter's steps for the
34543488
* splice. Since the channel must be in STFU mode we block the daemon here until
34553489
* the splice is finished or aborted. */
@@ -3586,6 +3620,8 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
35863620
new_inflight->last_tx = NULL;
35873621
new_inflight->i_am_initiator = false;
35883622

3623+
update_hsmd_with_splice(peer, new_inflight);
3624+
35893625
update_view_from_inflights(peer);
35903626

35913627
peer->splice_state->count++;
@@ -3820,6 +3856,8 @@ static void splice_initiator_user_finalized(struct peer *peer)
38203856
new_inflight->last_tx = NULL;
38213857
new_inflight->i_am_initiator = true;
38223858

3859+
update_hsmd_with_splice(peer, new_inflight);
3860+
38233861
update_view_from_inflights(peer);
38243862

38253863
peer->splice_state->count++;

0 commit comments

Comments
 (0)