From 27df2705eda018ada589250d993f3ac9e14ab69e Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Mon, 2 Jan 2017 23:09:45 +0200 Subject: [PATCH] !send command validation with estimatedGas --- resources/commands.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/commands.js b/resources/commands.js index d549ea2ac9..c39c5bb889 100644 --- a/resources/commands.js +++ b/resources/commands.js @@ -17,7 +17,7 @@ I18n.translations = { validation_title: 'Amount', validation_amount_specified: 'Amount must be specified', validation_invalid_number: 'Amount is not valid number', - validation_insufficient_amount: 'Not enough ETH on balance (' + validation_insufficient_amount: 'Insufficient funds for gas * price + value (balance ' }, ru: { location_title: 'Местоположение', @@ -764,7 +764,12 @@ function validateSend(params, context) { } var balance = web3.eth.getBalance(context.from); - if (bn(val).greaterThan(bn(balance))) { + var estimatedGas = web3.eth.estimateGas({ + from: context.from, + to: context.to, + value: val + }); + if (bn(val).plus(bn(estimatedGas)).greaterThan(bn(balance))) { return { errors: [ status.components.validationMessage(