From 4cdb4167d2e3c3052d42e1a38a0dfebef496d48a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 18 Sep 2022 09:53:50 +0930 Subject: [PATCH] gossmap: make local_addchan create private channel_announcement in correct order. Signed-off-by: Rusty Russell --- common/gossmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/gossmap.c b/common/gossmap.c index 027fcbe21..55ea115dd 100644 --- a/common/gossmap.c +++ b/common/gossmap.c @@ -771,6 +771,16 @@ bool gossmap_local_addchan(struct gossmap_localmods *localmods, if (find_localmod(localmods, scid)) return false; + /* BOLT #7: + * + * - MUST set `node_id_1` and `node_id_2` to the public keys + * of the two nodes operating the channel, such that + * `node_id_1` is the lexicographically-lesser of the two + * compressed keys sorted in ascending lexicographic order. + */ + if (node_id_cmp(n1, n2) > 0) + return gossmap_local_addchan(localmods, n2, n1, scid, features); + mod.scid = *scid; mod.updates_set[0] = mod.updates_set[1] = false;