Browse Source

Added BTCToLocalCurrency

localNotifications
Marcos Rodriguez Vélez 6 years ago
parent
commit
47dc184036
  1. 2
      class/abstract-hd-wallet.js
  2. 14
      currency.js
  3. 3
      loc/index.js
  4. 7
      screen/send/details.js
  5. 4
      screen/wallets/transactions.js

2
class/abstract-hd-wallet.js

@ -324,7 +324,7 @@ export class AbstractHDWallet extends LegacyWallet {
} }
} }
// no luck - lets iterate over all addressess we have up to first unused address index // no luck - lets iterate over all addresses we have up to first unused address index
for (let c = 0; c <= this.next_free_change_address_index + 3; c++) { for (let c = 0; c <= this.next_free_change_address_index + 3; c++) {
let possibleAddress = this._getInternalAddressByIndex(c); let possibleAddress = this._getInternalAddressByIndex(c);
if (possibleAddress === address) { if (possibleAddress === address) {

14
currency.js

@ -67,6 +67,19 @@ function satoshiToLocalCurrency(satoshi) {
return '$' + b; return '$' + b;
} }
function BTCToLocalCurrency(bitcoin) {
if (!lang[STRUCT.BTC_USD]) return bitcoin;
let b = new BigNumber(bitcoin);
b = b
.multipliedBy(1)
.multipliedBy(lang[STRUCT.BTC_USD])
.toString(10);
b = parseFloat(b).toFixed(2);
return '$' + b;
}
function satoshiToBTC(satoshi) { function satoshiToBTC(satoshi) {
let b = new BigNumber(satoshi); let b = new BigNumber(satoshi);
b = b.dividedBy(100000000); b = b.dividedBy(100000000);
@ -78,3 +91,4 @@ module.exports.startUpdater = startUpdater;
module.exports.STRUCT = STRUCT; module.exports.STRUCT = STRUCT;
module.exports.satoshiToLocalCurrency = satoshiToLocalCurrency; module.exports.satoshiToLocalCurrency = satoshiToLocalCurrency;
module.exports.satoshiToBTC = satoshiToBTC; module.exports.satoshiToBTC = satoshiToBTC;
module.exports.BTCToLocalCurrency = BTCToLocalCurrency;

3
loc/index.js

@ -79,8 +79,7 @@ strings.formatBalance = (balance, toUnit) => {
const value = new BigNumber(balance).multipliedBy(0.001); const value = new BigNumber(balance).multipliedBy(0.001);
return parseInt(value.toString().replace('.', '')).toString() + ' sats'; return parseInt(value.toString().replace('.', '')).toString() + ' sats';
} else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) { } else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) {
const value = new BigNumber(balance).multipliedBy(0.001); return currency.BTCToLocalCurrency(balance);
return currency.satoshiToLocalCurrency(parseInt(value.toString().replace('.', '')));
} }
}; };

7
screen/send/details.js

@ -485,7 +485,7 @@ export default class SendDetails extends Component {
</View> </View>
<View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}> <View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}>
<Text style={{ fontSize: 18, color: '#d4d4d4', fontWeight: '600' }}> <Text style={{ fontSize: 18, color: '#d4d4d4', fontWeight: '600' }}>
{loc.formatBalance(Number(this.state.amount || 0), BitcoinUnit.BTC, BitcoinUnit.LOCAL_CURRENCY)} {loc.formatBalance(this.state.amount || 0, BitcoinUnit.LOCAL_CURRENCY)}
</Text> </Text>
</View> </View>
<View <View
@ -505,7 +505,10 @@ export default class SendDetails extends Component {
}} }}
> >
<TextInput <TextInput
onChangeText={text => () => this.processBIP70Invoice(text)} onChangeText={text => {
if (!this.processBIP70Invoice(text)) {
this.setState({ address: text.replace(' ', ''), isLoading: false, bip70TransactionExpiration: null });
}}}
placeholder={loc.send.details.address} placeholder={loc.send.details.address}
numberOfLines={1} numberOfLines={1}
value={this.state.address} value={this.state.address}

4
screen/wallets/transactions.js

@ -234,8 +234,7 @@ export default class WalletTransactions extends Component {
> >
{loc {loc
.formatBalance( .formatBalance(
Number(this.state.wallet.getBalance()), this.state.wallet.getBalance(),
this.state.walletPreviousPreferredUnit,
this.state.wallet.getPreferredBalanceUnit(), this.state.wallet.getPreferredBalanceUnit(),
) )
.toString()} .toString()}
@ -452,7 +451,6 @@ export default class WalletTransactions extends Component {
rightTitle={loc rightTitle={loc
.formatBalanceWithoutSuffix( .formatBalanceWithoutSuffix(
(rowData.item.value && rowData.item.value) || 0, (rowData.item.value && rowData.item.value) || 0,
BitcoinUnit.SATS,
this.state.wallet.getPreferredBalanceUnit(), this.state.wallet.getPreferredBalanceUnit(),
) )
.toString()} .toString()}

Loading…
Cancel
Save