Skip to content

Commit

Permalink
splice: signer must be informed of splice params
Browse files Browse the repository at this point in the history
The signer needs to know when the splice operation starts and the
splice parameters for each splice transaction candidate.

The channel establishment v2 (dual funding) code path already
notifies the signer via the hsmd API hsmd_ready_channel calls
However, the splicing code path does not.

Link: ElementsProject#6723
Suggested-by: @devrandom
Co-Developed-by: Ken Sedgwick <[email protected]>
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Sep 29, 2023
1 parent 3a53f40 commit a40d34b
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -3444,16 +3444,17 @@ static struct inflight *inflights_new(struct peer *peer)
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
struct amount_msat push_value;
/* 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;
u32 *local_upfront_shutdown_wallet_index = NULL;

// FIXME - the push_value needs to reflect what is owed to the non-opener
struct amount_msat push_value = AMOUNT_MSAT(0);
// FIXME: handle the error
assert(amount_sat_to_msat(&push_value, inflight->amnt));

msg = towire_hsmd_setup_channel(
msg = towire_hsmd_ready_channel(
NULL,
peer->channel->opener == LOCAL,
inflight->amnt,
Expand All @@ -3468,9 +3469,11 @@ static void update_hsmd_with_splice(struct peer *peer, struct inflight *inflight
peer->channel->config[REMOTE].to_self_delay,
remote_upfront_shutdown_script,
peer->channel->type);
msg = (u8 *) hsm_req(tmpctx, take(msg));
if (!fromwire_hsmd_setup_channel_reply(msg))
status_failed(STATUS_FAIL_HSM_IO, "Bad setup_channel_reply %s",

wire_sync_write(HSM_FD, take(msg));
msg = wire_sync_read(tmpctx, HSM_FD);
if (!fromwire_hsmd_ready_channel_reply(msg))
status_failed(STATUS_FAIL_HSM_IO, "Bad ready_channel_reply %s",
tal_hex(tmpctx, msg));
}

Expand Down Expand Up @@ -5197,8 +5200,7 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)

if (depth < peer->channel->minimum_depth) {
peer->depth_togo = peer->channel->minimum_depth - depth;
}
else {
} else {
peer->depth_togo = 0;

/* For splicing we only update the short channel id on mutual
Expand Down Expand Up @@ -5243,8 +5245,7 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
peer_write(peer->pps, take(msg));

peer->channel_ready[LOCAL] = true;
}
else if(splicing && !peer->splice_state->locked_ready[LOCAL]) {
} else if(splicing && !peer->splice_state->locked_ready[LOCAL]) {
assert(scid);

msg = towire_splice_locked(NULL, &peer->channel_id);
Expand Down

0 comments on commit a40d34b

Please sign in to comment.