From f278df31a9c6a003fa67d11d82142859948bac86 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Mon, 8 Jul 2024 13:52:11 +0000 Subject: [PATCH] mixpool: Reject KEs submitted too early --- mixing/mixpool/mixpool.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mixing/mixpool/mixpool.go b/mixing/mixpool/mixpool.go index a16268289..117d8a6b9 100644 --- a/mixing/mixpool/mixpool.go +++ b/mixing/mixpool/mixpool.go @@ -28,6 +28,7 @@ import ( const minconf = 1 const feeRate = 0.0001e8 +const clientTimeoutDuration = 30 * time.Second type idPubKey = [33]byte @@ -1394,6 +1395,12 @@ func (p *Pool) checkAcceptKE(ke *wire.MsgMixKeyExchange) error { return ruleError(ErrPeerPositionOutOfBounds) } + keEpoch := time.Unix(int64(ke.Epoch), 0) + if keEpoch.Add(clientTimeoutDuration).Before(time.Now()) { + err := fmt.Errorf("KE received too early for stated epoch") + return ruleError(err) + } + return nil }