mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 13:25:43 +01:00
channel_control: break out function for on_funding_locked
We're about to move channel-locking over to dualopend, and will want to reuse this.
This commit is contained in:
parent
b2bb80cb1b
commit
c5e28e4746
@ -149,6 +149,22 @@ static void lockin_complete(struct channel *channel)
|
||||
record_channel_open(channel);
|
||||
}
|
||||
|
||||
bool channel_on_funding_locked(struct channel *channel,
|
||||
struct pubkey *next_per_commitment_point)
|
||||
{
|
||||
if (channel->remote_funding_locked) {
|
||||
channel_internal_error(channel,
|
||||
"channel_got_funding_locked twice");
|
||||
return false;
|
||||
}
|
||||
update_per_commit_point(channel, next_per_commitment_point);
|
||||
|
||||
log_debug(channel->log, "Got funding_locked");
|
||||
channel->remote_funding_locked = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* We were informed by channeld that it announced the channel and sent
|
||||
* an update, so we can now start sending a node_announcement. The
|
||||
* first step is to build the provisional announcement and ask the HSM
|
||||
@ -166,15 +182,8 @@ static void peer_got_funding_locked(struct channel *channel, const u8 *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
if (channel->remote_funding_locked) {
|
||||
channel_internal_error(channel,
|
||||
"channel_got_funding_locked twice");
|
||||
if (!channel_on_funding_locked(channel, &next_per_commitment_point))
|
||||
return;
|
||||
}
|
||||
update_per_commit_point(channel, &next_per_commitment_point);
|
||||
|
||||
log_debug(channel->log, "Got funding_locked");
|
||||
channel->remote_funding_locked = true;
|
||||
|
||||
if (channel->scid)
|
||||
lockin_complete(channel);
|
||||
|
@ -29,6 +29,9 @@ void channel_notify_new_block(struct lightningd *ld,
|
||||
struct command_result *cancel_channel_before_broadcast(struct command *cmd,
|
||||
struct peer *peer);
|
||||
|
||||
/* Update the channel info on funding locked */
|
||||
bool channel_on_funding_locked(struct channel *channel,
|
||||
struct pubkey *next_per_commitment_point);
|
||||
/* Forget a channel. Deletes the channel and handles all
|
||||
* associated waiting commands, if present. Notifies peer if available */
|
||||
void forget_channel(struct channel *channel, const char *err_msg);
|
||||
|
Loading…
Reference in New Issue
Block a user