Browse Source

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.
ppa
niftynei 4 years ago
committed by Christian Decker
parent
commit
c5e28e4746
  1. 25
      lightningd/channel_control.c
  2. 3
      lightningd/channel_control.h

25
lightningd/channel_control.c

@ -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);

3
lightningd/channel_control.h

@ -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…
Cancel
Save