From e8a480aac44546e6bd5d7457545bc951a8787814 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 2 Apr 2018 13:17:54 -0700 Subject: transactions validationt - valdate from field on txParams --- app/scripts/lib/tx-gas-utils.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/scripts/lib/tx-gas-utils.js b/app/scripts/lib/tx-gas-utils.js index 0fa9dd8d4..4be7738b0 100644 --- a/app/scripts/lib/tx-gas-utils.js +++ b/app/scripts/lib/tx-gas-utils.js @@ -100,6 +100,7 @@ module.exports = class TxGasUtil { } async validateTxParams (txParams) { + this.validateFrom(txParams) this.validateRecipient(txParams) if ('value' in txParams) { const value = txParams.value.toString() @@ -112,6 +113,12 @@ module.exports = class TxGasUtil { } } } + + validateFrom (txParams) { + if ( !(typeof txParams.from === 'string') ) throw new Error(`Invalid from address ${txParams.from} not a string`) + if (!isValidAddress(txParams.from)) throw new Error('Invalid from address') + } + validateRecipient (txParams) { if (txParams.to === '0x' || txParams.to === null ) { if (txParams.data) { @@ -124,4 +131,4 @@ module.exports = class TxGasUtil { } return txParams } -} +} \ No newline at end of file -- cgit