From 44bffa793693b8977e96e722c12bd1be4c07e5b9 Mon Sep 17 00:00:00 2001 From: Overtorment Date: Fri, 6 Jul 2018 17:54:00 +0100 Subject: [PATCH] FIX: ints representation via BigNumber --- class/legacy-wallet.js | 7 +++++-- loc/index.js | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/class/legacy-wallet.js b/class/legacy-wallet.js index 892ab5b46..bbfa8af7c 100644 --- a/class/legacy-wallet.js +++ b/class/legacy-wallet.js @@ -97,8 +97,11 @@ export class LegacyWallet extends AbstractWallet { throw new Error('Could not fetch UTXO from API' + response.err); } - this.balance = json.final_balance / 100000000; - this.unconfirmed_balance = json.unconfirmed_balance / 100000000; + this.balance = new BigNumber(json.final_balance); + this.balance = this.balance.div(100000000).toString() * 1; + this.unconfirmed_balance = new BigNumber(json.unconfirmed_balance); + this.unconfirmed_balance = + this.unconfirmed_balance.div(100000000).toString() * 1; this._lastBalanceFetch = +new Date(); } catch (err) { console.warn(err); diff --git a/loc/index.js b/loc/index.js index 6d091ba30..1f4c43dda 100644 --- a/loc/index.js +++ b/loc/index.js @@ -2,6 +2,7 @@ import LocalizedStrings from 'react-localization'; import { AsyncStorage } from 'react-native'; import { Util } from 'expo'; import { AppStorage } from '../class'; +let BigNumber = require('bignumber.js'); let strings; // first-time loading sequence @@ -65,7 +66,8 @@ strings.transactionTimeToReadable = function(time) { strings.formatBalance = function(balance) { if (balance < 0.1 && balance !== 0) { - return balance * 1000 + ' mBTC'; + let b = new BigNumber(balance); + return b.mul(1000).toString() + ' mBTC'; } return balance + ' BTC'; };