aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-09-08 03:52:49 +0800
committerDan Finlay <dan@danfinlay.com>2017-09-08 03:52:49 +0800
commitfadc0617df016ad1fa3d1c92e220a8e9ede6379d (patch)
tree2b028feb8c0b7d174d6d08f251673cca9b347311 /app/scripts
parent532a4040de191d455053aa11432dcb9b407c9bf4 (diff)
downloadtangerine-wallet-browser-fadc0617df016ad1fa3d1c92e220a8e9ede6379d.tar
tangerine-wallet-browser-fadc0617df016ad1fa3d1c92e220a8e9ede6379d.tar.gz
tangerine-wallet-browser-fadc0617df016ad1fa3d1c92e220a8e9ede6379d.tar.bz2
tangerine-wallet-browser-fadc0617df016ad1fa3d1c92e220a8e9ede6379d.tar.lz
tangerine-wallet-browser-fadc0617df016ad1fa3d1c92e220a8e9ede6379d.tar.xz
tangerine-wallet-browser-fadc0617df016ad1fa3d1c92e220a8e9ede6379d.tar.zst
tangerine-wallet-browser-fadc0617df016ad1fa3d1c92e220a8e9ede6379d.zip
Make tx calculations account for gas prices
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/lib/pending-balance-calculator.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/scripts/lib/pending-balance-calculator.js b/app/scripts/lib/pending-balance-calculator.js
index 8564f0134..29f1fd63a 100644
--- a/app/scripts/lib/pending-balance-calculator.js
+++ b/app/scripts/lib/pending-balance-calculator.js
@@ -32,9 +32,15 @@ class PendingBalanceCalculator {
valueFor (tx) {
const txValue = tx.txParams.value
- const normalized = normalize(txValue).substring(2)
const value = this.hexToBn(txValue)
- return value
+ const gasPrice = this.hexToBn(tx.txParams.gasPrice)
+
+ const gas = tx.txParams.gas
+ const gasLimit = tx.txParams.gasLimit
+ const gasLimitBn = this.hexToBn(gas || gasLimit)
+
+ const gasCost = gasPrice.mul(gasLimitBn)
+ return value.add(gasCost)
}
hexToBn (hex) {