ld: Add function to retrieve either the scid or the local alias
We use this in a couple of places, when we want to refer to a channel by its `short_channel_id`, I'm moving this into a separate function primarily to have a way to mark places where we do that.
This commit is contained in:
parent
7930e34da3
commit
92b891bee3
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue