Browse Source

FIX: Satoshis are now human-readable

zigzag
Marcos Rodriguez Vélez 6 years ago
parent
commit
94eb3ddd84
  1. 4
      loc/index.js
  2. 2
      screen/lnd/lndCreateInvoice.js
  3. 9
      screen/wallets/list.js
  4. 3
      screen/wallets/transactions.js

4
loc/index.js

@ -104,7 +104,7 @@ strings.formatBalance = (balance, toUnit) => {
return balance + ' ' + BitcoinUnit.BTC;
} else if (toUnit === BitcoinUnit.SATS) {
const value = new BigNumber(balance).multipliedBy(100000000);
return value.toString() + ' ' + BitcoinUnit.SATS;
return new Intl.NumberFormat().format(value.toString()) + ' ' + BitcoinUnit.SATS;
} else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) {
return currency.BTCToLocalCurrency(balance);
}
@ -125,7 +125,7 @@ strings.formatBalanceWithoutSuffix = (balance, toUnit) => {
const value = new BigNumber(balance).dividedBy(100000000).toFixed(8);
return removeTrailingZeros(value);
} else if (toUnit === BitcoinUnit.SATS) {
return balance;
return new Intl.NumberFormat().format(balance);
} else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) {
return currency.satoshiToLocalCurrency(balance);
}

2
screen/lnd/lndCreateInvoice.js

@ -51,7 +51,7 @@ export default class LNDCreateInvoice extends Component {
<ActivityIndicator />
) : (
<BlueButton
disabled={!(this.state.description.length > 0)}
disabled={!(this.state.description.length > 0 && this.state.amount > 0)}
onPress={() => this.createInvoice()}
title={loc.send.details.create}
/>

9
screen/wallets/list.js

@ -232,21 +232,24 @@ export default class WalletsList extends Component {
rowTitle = item => {
if (item.type === 'user_invoice' || item.type === 'payment_request') {
if (isNaN(item.value)) {
item.value = "0"
}
const currentDate = new Date();
const now = (currentDate.getTime() / 1000) | 0;
const invoiceExpiration = item.timestamp + item.expire_time;
if (invoiceExpiration > now) {
return loc.formatBalanceWithoutSuffix(item.value && item.value, BitcoinUnit.BTC);
return loc.formatBalanceWithoutSuffix(item.value && item.value, BitcoinUnit.BTC).toString();
} else if (invoiceExpiration < now) {
if (item.ispaid) {
return loc.formatBalanceWithoutSuffix(item.value && item.value, BitcoinUnit.BTC);
return loc.formatBalanceWithoutSuffix(item.value && item.value, BitcoinUnit.BTC).toString();
} else {
return loc.lnd.expired;
}
}
} else {
return loc.formatBalanceWithoutSuffix(item.value && item.value, BitcoinUnit.BTC);
return loc.formatBalanceWithoutSuffix(item.value && item.value, BitcoinUnit.BTC).toString();
}
};

3
screen/wallets/transactions.js

@ -303,6 +303,9 @@ export default class WalletTransactions extends Component {
rowTitle = item => {
if (item.type === 'user_invoice' || item.type === 'payment_request') {
if (isNaN(item.value)) {
item.value = 0
}
const currentDate = new Date();
const now = (currentDate.getTime() / 1000) | 0;
const invoiceExpiration = item.timestamp + item.expire_time;

Loading…
Cancel
Save