Skip to content

Commit ce5845e

Browse files
committed
gossipd: correclty ignore channel_announcement and channel_update for other chains.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Fixed: Protocol: `gossipd` will now silently ignore gossip for other chains (rather than sending warnings).
1 parent 34586a0 commit ce5845e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

gossipd/gossmap_manage.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,13 @@ const char *gossmap_manage_channel_announcement(const tal_t *ctx,
648648
tal_hex(tmpctx, announce));
649649
}
650650

651+
/* BOLT #7:
652+
* - if the specified `chain_hash` is unknown to the receiver:
653+
* - MUST ignore the message.
654+
*/
655+
if (!bitcoin_blkid_eq(&chain_hash, &chainparams->genesis_blockhash))
656+
return NULL;
657+
651658
/* If a prior txout lookup failed there is little point it trying
652659
* again. Just drop the announcement and walk away whistling.
653660
*
@@ -1019,6 +1026,16 @@ const char *gossmap_manage_channel_update(const tal_t *ctx,
10191026
tal_hex(tmpctx, update));
10201027
}
10211028

1029+
/* BOLT #7:
1030+
* - if the specified `chain_hash` value is unknown (meaning it isn't active on
1031+
* the specified chain):
1032+
* - MUST ignore the channel update.
1033+
*/
1034+
if (!bitcoin_blkid_eq(&chain_hash, &chainparams->genesis_blockhash)) {
1035+
status_debug("wrong chain for update %s", tal_hex(tmpctx, update));
1036+
return NULL;
1037+
}
1038+
10221039
/* Don't accept ancient or far-future timestamps. */
10231040
if (!timestamp_reasonable(gm->daemon, timestamp)) {
10241041
status_debug("Unreasonable timestamp in %s", tal_hex(tmpctx, update));

0 commit comments

Comments
 (0)