Skip to content

Commit be52416

Browse files
committed
Add call to SetupChannel in splicing flow
1 parent fc59bc4 commit be52416

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

channeld/channeld.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,6 +3450,39 @@ static struct inflight *inflights_new(struct peer *peer)
34503450
return inf;
34513451
}
34523452

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

3622+
update_hsmd_with_splice(peer, new_inflight);
3623+
35893624
update_view_from_inflights(peer);
35903625

35913626
peer->splice_state->count++;
@@ -3820,6 +3855,8 @@ static void splice_initiator_user_finalized(struct peer *peer)
38203855
new_inflight->last_tx = NULL;
38213856
new_inflight->i_am_initiator = true;
38223857

3858+
update_hsmd_with_splice(peer, new_inflight);
3859+
38233860
update_view_from_inflights(peer);
38243861

38253862
peer->splice_state->count++;

0 commit comments

Comments
 (0)