ld: Allow lockin despite not having a scid yet

This is needed for us to transition to CHANNELD_NORMAL for zeroconf
channels, i.e., channels where we don't have a short channel ID yet.

We'll have to call lockin_complete a second time, once we learn the
real scid.
This commit is contained in:
Christian Decker 2022-04-28 17:48:16 +02:00
parent cdedd433a4
commit 78c9c6a9e0

View file

@ -179,8 +179,13 @@ void channel_record_open(struct channel *channel)
static void lockin_complete(struct channel *channel)
{
/* We set this once we're locked in. */
assert(channel->scid);
if (!channel->scid &&
(!channel->alias[REMOTE] || !channel->alias[LOCAL])) {
log_debug(channel->log, "Attempted lockin, but neither scid "
"nor aliases are set, ignoring");
return;
}
/* We set this once they're locked in. */
assert(channel->remote_funding_locked);
@ -203,7 +208,10 @@ static void lockin_complete(struct channel *channel)
try_update_blockheight(channel->peer->ld, channel,
get_block_height(channel->peer->ld->topology));
channel_record_open(channel);
/* Only record this once we get a real confirmation. */
if (channel->scid)
channel_record_open(channel);
}
bool channel_on_funding_locked(struct channel *channel,
@ -248,8 +256,7 @@ static void peer_got_funding_locked(struct channel *channel, const u8 *msg)
/* Remember that we got the lockin */
wallet_channel_save(channel->peer->ld->wallet, channel);
if (channel->scid)
lockin_complete(channel);
lockin_complete(channel);
}
static void peer_got_announcement(struct channel *channel, const u8 *msg)