From d5514d9dcbbdd35cb5abc6fc5c999657780f30d9 Mon Sep 17 00:00:00 2001 From: kilpatty Date: Tue, 30 Apr 2019 21:43:48 -0500 Subject: [PATCH] node-http: add check for height being below tip This commit simply adds an enforce line to check that the height being requested to reset to is below the chain tip. This way we return a bad request error rather than a internal server error. --- lib/node/http.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node/http.js b/lib/node/http.js index dc25f8ff..2c9b4dfa 100644 --- a/lib/node/http.js +++ b/lib/node/http.js @@ -339,6 +339,8 @@ class HTTP extends Server { const height = valid.u32('height'); enforce(height != null, 'Height is required.'); + enforce(height <= this.chain.height, + 'Height cannot be greater than chain tip.'); await this.chain.reset(height);