forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
1 parent
77e3c3a
commit 7b76ddf
Showing
1 changed file
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3441,6 +3441,42 @@ static struct inflight *inflights_new(struct peer *peer) | |
return inf; | ||
} | ||
|
||
static void update_hsmd_with_splice(struct peer *peer, struct inflight *inflight) | ||
{ | ||
u8 *msg; | ||
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; | ||
u8 *remote_upfront_shutdown_script = NULL; | ||
u32 *local_upfront_shutdown_wallet_index = NULL; | ||
|
||
// FIXME: handle the error | ||
assert(amount_sat_to_msat(&push_value, inflight->amnt)); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
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); | ||
|
||
wire_sync_write(HSM_FD, take(msg)); | ||
msg = wire_sync_read(tmpctx, HSM_FD); | ||
This comment has been minimized.
Sorry, something went wrong.
vincenzopalazzo
Owner
|
||
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. */ | ||
|
@@ -3577,6 +3613,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++; | ||
|
@@ -3811,6 +3849,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++; | ||
|
@@ -5160,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 | ||
|
@@ -5206,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); | ||
|
1 comment
on commit 7b76ddf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise looks good
I'm not sure this is the right amount value for
push_value
. devrandom suggested:lightning-signer#95 (comment)