Skip to content

Commit 7b76ddf

Browse files
ksedgwicvincenzopalazzo
authored andcommitted
splice: signer must be informed of splice params
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]>
1 parent 77e3c3a commit 7b76ddf

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

channeld/channeld.c

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,6 +3441,42 @@ static struct inflight *inflights_new(struct peer *peer)
34413441
return inf;
34423442
}
34433443

3444+
static void update_hsmd_with_splice(struct peer *peer, struct inflight *inflight)
3445+
{
3446+
u8 *msg;
3447+
struct amount_msat push_value;
3448+
/* These aren't allowed to change, so we
3449+
* don't need to gather them */
3450+
u8 *local_upfront_shutdown_script = NULL;
3451+
u8 *remote_upfront_shutdown_script = NULL;
3452+
u32 *local_upfront_shutdown_wallet_index = NULL;
3453+
3454+
// FIXME: handle the error
3455+
assert(amount_sat_to_msat(&push_value, inflight->amnt));
3456+
3457+
msg = towire_hsmd_ready_channel(
3458+
NULL,
3459+
peer->channel->opener == LOCAL,
3460+
inflight->amnt,
3461+
push_value,
3462+
&inflight->outpoint.txid,
3463+
inflight->outpoint.n,
3464+
peer->channel->config[LOCAL].to_self_delay,
3465+
local_upfront_shutdown_script,
3466+
local_upfront_shutdown_wallet_index,
3467+
&peer->channel->basepoints[REMOTE],
3468+
&peer->channel->funding_pubkey[REMOTE],
3469+
peer->channel->config[REMOTE].to_self_delay,
3470+
remote_upfront_shutdown_script,
3471+
peer->channel->type);
3472+
3473+
wire_sync_write(HSM_FD, take(msg));
3474+
msg = wire_sync_read(tmpctx, HSM_FD);
3475+
if (!fromwire_hsmd_ready_channel_reply(msg))
3476+
status_failed(STATUS_FAIL_HSM_IO, "Bad ready_channel_reply %s",
3477+
tal_hex(tmpctx, msg));
3478+
}
3479+
34443480
/* ACCEPTER side of the splice. Here we handle all the accepter's steps for the
34453481
* splice. Since the channel must be in STFU mode we block the daemon here until
34463482
* the splice is finished or aborted. */
@@ -3577,6 +3613,8 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
35773613
new_inflight->last_tx = NULL;
35783614
new_inflight->i_am_initiator = false;
35793615

3616+
update_hsmd_with_splice(peer, new_inflight);
3617+
35803618
update_view_from_inflights(peer);
35813619

35823620
peer->splice_state->count++;
@@ -3811,6 +3849,8 @@ static void splice_initiator_user_finalized(struct peer *peer)
38113849
new_inflight->last_tx = NULL;
38123850
new_inflight->i_am_initiator = true;
38133851

3852+
update_hsmd_with_splice(peer, new_inflight);
3853+
38143854
update_view_from_inflights(peer);
38153855

38163856
peer->splice_state->count++;
@@ -5160,8 +5200,7 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
51605200

51615201
if (depth < peer->channel->minimum_depth) {
51625202
peer->depth_togo = peer->channel->minimum_depth - depth;
5163-
}
5164-
else {
5203+
} else {
51655204
peer->depth_togo = 0;
51665205

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

52085247
peer->channel_ready[LOCAL] = true;
5209-
}
5210-
else if(splicing && !peer->splice_state->locked_ready[LOCAL]) {
5248+
} else if(splicing && !peer->splice_state->locked_ready[LOCAL]) {
52115249
assert(scid);
52125250

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

0 commit comments

Comments
 (0)