mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-26 20:30:59 +01:00
lightningd: permit wrong-alias lookups for private channel_update.
This is wrong, but we send them for now in zeroconf! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f3b4821d36
commit
0c949dcd04
1 changed files with 27 additions and 1 deletions
|
@ -205,6 +205,30 @@ static void set_channel_remote_update(struct lightningd *ld,
|
||||||
wallet_channel_save(ld->wallet, channel);
|
wallet_channel_save(ld->wallet, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* One of the few places where we look up by *remote* id. It's not unique,
|
||||||
|
* but it is unique for a specific peer. */
|
||||||
|
static struct channel *lookup_by_peer_remote_alias(struct lightningd *ld,
|
||||||
|
const struct node_id *source,
|
||||||
|
struct short_channel_id scid)
|
||||||
|
{
|
||||||
|
const struct peer *p;
|
||||||
|
struct channel *chan;
|
||||||
|
|
||||||
|
if (!source)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
p = peer_by_id(ld, source);
|
||||||
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
list_for_each(&p->channels, chan, list) {
|
||||||
|
if (chan->alias[REMOTE]
|
||||||
|
&& short_channel_id_eq(&scid, chan->alias[REMOTE]))
|
||||||
|
return chan;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_peer_update_data(struct lightningd *ld, const u8 *msg)
|
static void handle_peer_update_data(struct lightningd *ld, const u8 *msg)
|
||||||
{
|
{
|
||||||
struct channel *channel;
|
struct channel *channel;
|
||||||
|
@ -216,8 +240,10 @@ static void handle_peer_update_data(struct lightningd *ld, const u8 *msg)
|
||||||
fatal("Gossip gave bad GOSSIPD_REMOTE_CHANNEL_UPDATE %s",
|
fatal("Gossip gave bad GOSSIPD_REMOTE_CHANNEL_UPDATE %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
channel = any_channel_by_scid(ld, &update->scid, true);
|
channel = any_channel_by_scid(ld, &update->scid, true);
|
||||||
|
if (!channel)
|
||||||
|
channel = lookup_by_peer_remote_alias(ld, source, update->scid);
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
log_unusual(ld->log, "Bad gossip: could not find channel %s for peer's "
|
log_unusual(ld->log, "Bad gossip order: could not find channel %s for peer's "
|
||||||
"channel update",
|
"channel update",
|
||||||
short_channel_id_to_str(tmpctx, &update->scid));
|
short_channel_id_to_str(tmpctx, &update->scid));
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue