diff --git a/lightningd/channel.c b/lightningd/channel.c index 123ca84a5..e0bffb768 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -956,3 +956,13 @@ void channel_fail_reconnect(struct channel *channel, const char *fmt, ...) err_and_reconnect(channel, tal_vfmt(tmpctx, fmt, ap), 1); va_end(ap); } + +const struct short_channel_id * +channel_scid_or_local_alias(const struct channel *chan) +{ + assert(chan->scid != NULL || chan->alias[LOCAL] != NULL); + if (chan->scid != NULL) + return chan->scid; + else + return chan->alias[LOCAL]; +} diff --git a/lightningd/channel.h b/lightningd/channel.h index aabbcf1ff..afd72e4a7 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -476,6 +476,16 @@ static inline bool channel_has(const struct channel *channel, int f) return channel_type_has(channel->type, f); } +/** + * Either returns the short_channel_id if it is known or the local alias. + * + * This is used to refer to a channel by its scid. But sometimes we + * don't have a scid yet, e.g., for `zeroconf` channels, so we resort + * to referencing it by the local alias, which we have in that case. + */ +const struct short_channel_id * +channel_scid_or_local_alias(const struct channel *chan); + void get_channel_basepoints(struct lightningd *ld, const struct node_id *peer_id, const u64 dbid,