mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 06:52:41 +01:00
Added BTCToLocalCurrency
This commit is contained in:
parent
e24f292bbe
commit
47dc184036
5 changed files with 22 additions and 8 deletions
|
@ -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++) {
|
||||
let possibleAddress = this._getInternalAddressByIndex(c);
|
||||
if (possibleAddress === address) {
|
||||
|
|
14
currency.js
14
currency.js
|
@ -67,6 +67,19 @@ function satoshiToLocalCurrency(satoshi) {
|
|||
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) {
|
||||
let b = new BigNumber(satoshi);
|
||||
b = b.dividedBy(100000000);
|
||||
|
@ -78,3 +91,4 @@ module.exports.startUpdater = startUpdater;
|
|||
module.exports.STRUCT = STRUCT;
|
||||
module.exports.satoshiToLocalCurrency = satoshiToLocalCurrency;
|
||||
module.exports.satoshiToBTC = satoshiToBTC;
|
||||
module.exports.BTCToLocalCurrency = BTCToLocalCurrency;
|
|
@ -79,8 +79,7 @@ strings.formatBalance = (balance, toUnit) => {
|
|||
const value = new BigNumber(balance).multipliedBy(0.001);
|
||||
return parseInt(value.toString().replace('.', '')).toString() + ' sats';
|
||||
} else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) {
|
||||
const value = new BigNumber(balance).multipliedBy(0.001);
|
||||
return currency.satoshiToLocalCurrency(parseInt(value.toString().replace('.', '')));
|
||||
return currency.BTCToLocalCurrency(balance);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -485,7 +485,7 @@ export default class SendDetails extends Component {
|
|||
</View>
|
||||
<View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}>
|
||||
<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>
|
||||
</View>
|
||||
<View
|
||||
|
@ -505,7 +505,10 @@ export default class SendDetails extends Component {
|
|||
}}
|
||||
>
|
||||
<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}
|
||||
numberOfLines={1}
|
||||
value={this.state.address}
|
||||
|
|
|
@ -234,8 +234,7 @@ export default class WalletTransactions extends Component {
|
|||
>
|
||||
{loc
|
||||
.formatBalance(
|
||||
Number(this.state.wallet.getBalance()),
|
||||
this.state.walletPreviousPreferredUnit,
|
||||
this.state.wallet.getBalance(),
|
||||
this.state.wallet.getPreferredBalanceUnit(),
|
||||
)
|
||||
.toString()}
|
||||
|
@ -452,7 +451,6 @@ export default class WalletTransactions extends Component {
|
|||
rightTitle={loc
|
||||
.formatBalanceWithoutSuffix(
|
||||
(rowData.item.value && rowData.item.value) || 0,
|
||||
BitcoinUnit.SATS,
|
||||
this.state.wallet.getPreferredBalanceUnit(),
|
||||
)
|
||||
.toString()}
|
||||
|
|
Loading…
Add table
Reference in a new issue