diff --git a/bin/cli.js b/bin/cli.js index 970de72351..d9dec51352 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -144,7 +144,7 @@ async function run () { process.on('SIGINT', async () => { logger.info('Caught interrupt signal. Shutting down...') - if (server) await server.stop() + if (server) server.http().close() await node.stop() logger.info('Exiting.') process.exit() diff --git a/lib/rpc/validation.js b/lib/rpc/validation.js index 2b71e3696e..5075a61857 100644 --- a/lib/rpc/validation.js +++ b/lib/rpc/validation.js @@ -43,6 +43,13 @@ module.exports = { */ hex (params, index) { let err + if (typeof params[index] !== 'string') { + return { + code: INVALID_PARAMS, + message: `invalid argument ${index}: argument must be a hex string` + } + } + if (params[index].substr(0, 2) !== '0x') { err = { code: INVALID_PARAMS, @@ -60,6 +67,14 @@ module.exports = { */ blockHash (params, index) { let err + + if (typeof params[index] !== 'string') { + return { + code: INVALID_PARAMS, + message: `invalid argument ${index}: argument must be a hex string` + } + } + let blockHash = params[index].substring(2) if (!/^[0-9a-fA-F]+$/.test(blockHash) | blockHash.length !== 64) {