@@ -1440,10 +1440,21 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1440
1440
if chan. capacity_sats . is_some ( ) {
1441
1441
// If we'd previously looked up the channel on-chain and checked the script
1442
1442
// against what appears on-chain, ignore the duplicate announcement.
1443
- return Err ( LightningError {
1444
- err : "Already have chain-validated channel" . to_owned ( ) ,
1445
- action : ErrorAction :: IgnoreDuplicateGossip
1446
- } ) ;
1443
+ //
1444
+ // Because a reorg could replace one channel with another at the same SCID, if
1445
+ // the channel appears to be different, we re-validate. This doesn't expose us
1446
+ // to any more DoS risk than not, as a peer can always flood us with
1447
+ // randomly-generated SCID values anyway.
1448
+ //
1449
+ // We use the Node IDs rather than the bitcoin_keys to check for "equivalence"
1450
+ // as we didn't (necessarily) store the bitcoin keys, and we only really care
1451
+ // if the peers on the channel changed anyway.
1452
+ if NodeId :: from_pubkey ( & msg. node_id_1 ) == chan. node_one && NodeId :: from_pubkey ( & msg. node_id_2 ) == chan. node_two {
1453
+ return Err ( LightningError {
1454
+ err : "Already have chain-validated channel" . to_owned ( ) ,
1455
+ action : ErrorAction :: IgnoreDuplicateGossip
1456
+ } ) ;
1457
+ }
1447
1458
} else if chain_access. is_none ( ) {
1448
1459
// Similarly, if we can't check the chain right now anyway, ignore the
1449
1460
// duplicate announcement without bothering to take the channels write lock.
0 commit comments