From 66c9e97eefb46ca973895648a7ca7049aea9c548 Mon Sep 17 00:00:00 2001 From: Gustavo Nunes Date: Tue, 10 Jan 2017 01:30:32 -0200 Subject: [PATCH] Prevent non-positive-number amounts for send / request commands --- resources/commands.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/resources/commands.js b/resources/commands.js index d0ef501a88..9347193054 100644 --- a/resources/commands.js +++ b/resources/commands.js @@ -752,6 +752,7 @@ function validateSend(params, context) { try { var val = web3.toWei(params.amount, "ether"); + if (val <= 0) { throw new Error(); } } catch (err) { return { errors: [ @@ -895,4 +896,19 @@ status.command({ } }; }, + validator: function(params) { + try { + var val = web3.toWei(params.amount, "ether"); + if (val <= 0) { throw new Error(); } + } catch (err) { + return { + errors: [ + status.components.validationMessage( + I18n.t('validation_title'), + I18n.t('validation_invalid_number') + ) + ] + }; + } + } });