Skip to content

Commit

Permalink
Add call to ReadyChannel in splicing flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ksedgwic committed Sep 6, 2023
1 parent 6efffc6 commit b8b6b15
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ static u8 *send_commit_part(struct peer *peer,
peer->channel, &peer->remote_per_commit,
peer->next_index[REMOTE], REMOTE,
splice_amnt, remote_splice_amnt);

htlc_sigs =
calc_commitsigs(tmpctx, peer, txs, funding_wscript, htlc_map,
peer->next_index[REMOTE], &commit_sig);
Expand Down Expand Up @@ -3450,6 +3451,39 @@ static struct inflight *inflights_new(struct peer *peer)
return inf;
}

static void update_hsmd_with_splice(struct peer *peer, struct inflight *inflight)
{
u8 *msg;

// These aren't allowed to change, so we don't need to gather them
u8 *local_upfront_shutdown_script = NULL;
u32 * local_upfront_shutdown_wallet_index = NULL;
u8 *remote_upfront_shutdown_script = NULL;

// FIXME - the push_value needs to reflect what is owed to the non-opener
struct amount_msat push_value = AMOUNT_MSAT(0);

msg = towire_hsmd_ready_channel(
NULL,
peer->channel->opener == LOCAL,
inflight->amnt,
push_value,
&inflight->outpoint.txid,
inflight->outpoint.n,
peer->channel->config[LOCAL].to_self_delay,
local_upfront_shutdown_script,
local_upfront_shutdown_wallet_index,
&peer->channel->basepoints[REMOTE],
&peer->channel->funding_pubkey[REMOTE],
peer->channel->config[REMOTE].to_self_delay,
remote_upfront_shutdown_script,
peer->channel->type);
msg = (u8 *) hsm_req(tmpctx, take(msg));
if (!fromwire_hsmd_ready_channel_reply(msg))
status_failed(STATUS_FAIL_HSM_IO, "Bad ready_channel_reply %s",
tal_hex(tmpctx, msg));
}

/* ACCEPTER side of the splice. Here we handle all the accepter's steps for the
* splice. Since the channel must be in STFU mode we block the daemon here until
* the splice is finished or aborted. */
Expand Down Expand Up @@ -3586,6 +3620,8 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
new_inflight->last_tx = NULL;
new_inflight->i_am_initiator = false;

update_hsmd_with_splice(peer, new_inflight);

update_view_from_inflights(peer);

peer->splice_state->count++;
Expand Down Expand Up @@ -3820,6 +3856,8 @@ static void splice_initiator_user_finalized(struct peer *peer)
new_inflight->last_tx = NULL;
new_inflight->i_am_initiator = true;

update_hsmd_with_splice(peer, new_inflight);

update_view_from_inflights(peer);

peer->splice_state->count++;
Expand Down

0 comments on commit b8b6b15

Please sign in to comment.