mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
gossipd: ensure incoming timestamps are reasonable.
This is kind of orthogonal to the other changes, but makes sense: if we would instantly or never prune the message, don't accept it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7a32637b5f
commit
97bb6c5a28
1 changed files with 22 additions and 0 deletions
|
@ -1071,6 +1071,28 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update,
|
|||
}
|
||||
}
|
||||
|
||||
/* BOLT #7:
|
||||
*
|
||||
* - if the `timestamp` is unreasonably far in the future:
|
||||
* - MAY discard the `channel_announcement`.
|
||||
*/
|
||||
if (timestamp > time_now().ts.tv_sec + rstate->prune_timeout) {
|
||||
status_debug("Received channel_update for %s with far time %u",
|
||||
type_to_string(tmpctx, struct short_channel_id,
|
||||
&short_channel_id),
|
||||
timestamp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Note: we can consider old timestamps a case of "instant prune" too */
|
||||
if (timestamp < time_now().ts.tv_sec - rstate->prune_timeout) {
|
||||
status_debug("Received channel_update for %s with old time %u",
|
||||
type_to_string(tmpctx, struct short_channel_id,
|
||||
&short_channel_id),
|
||||
timestamp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
c = &chan->half[direction];
|
||||
|
||||
if (is_halfchan_defined(c) && timestamp <= c->last_timestamp) {
|
||||
|
|
Loading…
Add table
Reference in a new issue