FIX: ints representation via BigNumber

This commit is contained in:
Overtorment 2018-07-06 17:54:00 +01:00
parent eefb095a2c
commit 44bffa7936
2 changed files with 8 additions and 3 deletions

View File

@ -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);

View File

@ -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';
};