mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-26 08:55:56 +01:00
More changes
This commit is contained in:
parent
9da5547079
commit
6681f79be1
5 changed files with 68 additions and 42 deletions
2
App.js
2
App.js
|
@ -20,7 +20,7 @@ export default class App extends React.Component {
|
|||
}
|
||||
|
||||
handleOpenURL = event => {
|
||||
if (event.url && event.url.indexOf('bitcoin:') === 0) {
|
||||
if (event.url && event.url.toLowerCase().indexOf('bitcoin:') === 0) {
|
||||
this.navigator &&
|
||||
this.navigator.dispatch(
|
||||
NavigationActions.navigate({
|
||||
|
|
14
loc/index.js
14
loc/index.js
|
@ -76,7 +76,12 @@ strings.formatBalance = (balance, unit) => {
|
|||
} else {
|
||||
if (balance !== 0) {
|
||||
let b = new BigNumber(balance);
|
||||
if (unit === BitcoinUnit.SATS) {
|
||||
if (unit === BitcoinUnit.BTC) {
|
||||
if (!Number.isInteger(balance)) {
|
||||
return balance + ' ' + BitcoinUnit.BTC;
|
||||
}
|
||||
return b.times(conversion).toString() + ' ' + BitcoinUnit.BTC;
|
||||
} else if (unit === BitcoinUnit.SATS) {
|
||||
return (b.times(conversion).toString() + ' ' + BitcoinUnit.SATS).replace(/\./g, '');
|
||||
} else if (unit === BitcoinUnit.LOCAL_CURRENCY) {
|
||||
return currency.satoshiToLocalCurrency(b.times(conversion).toNumber());
|
||||
|
@ -91,12 +96,17 @@ strings.formatBalanceWithoutSuffix = (balance, unit) => {
|
|||
if (balance !== 0) {
|
||||
let b = new BigNumber(balance);
|
||||
if (unit === BitcoinUnit.BTC) {
|
||||
return Number(b.div(conversion));
|
||||
if (!Number.isInteger(balance)) {
|
||||
return b.times(conversion).toString();
|
||||
}
|
||||
return b.times(conversion).toString();
|
||||
} else if (unit === BitcoinUnit.SATS) {
|
||||
return b
|
||||
.times(conversion)
|
||||
.toString()
|
||||
.replace(/\./g, '');
|
||||
} else if (unit === BitcoinUnit.LOCAL_CURRENCY) {
|
||||
return currency.satoshiToLocalCurrency(b.times(conversion).toNumber());
|
||||
}
|
||||
}
|
||||
return balance;
|
||||
|
|
|
@ -108,48 +108,56 @@ export default class SendDetails extends Component {
|
|||
}
|
||||
|
||||
async componentDidMount() {
|
||||
EV(
|
||||
EV.enum.CREATE_TRANSACTION_NEW_DESTINATION_ADDRESS,
|
||||
data => {
|
||||
if (btcAddressRx.test(data) || data.indexOf('bc1') === 0) {
|
||||
this.setState({
|
||||
address: data,
|
||||
bip70TransactionExpiration: null,
|
||||
});
|
||||
} else {
|
||||
let address, options;
|
||||
try {
|
||||
const decoded = bip21.decode(data);
|
||||
address = decoded.address;
|
||||
options = decoded.options;
|
||||
} catch (Err) {
|
||||
console.log(Err);
|
||||
}
|
||||
console.log(options);
|
||||
if (btcAddressRx.test(address)) {
|
||||
EV(EV.enum.CREATE_TRANSACTION_NEW_DESTINATION_ADDRESS, data => {
|
||||
this.setState(
|
||||
{ isLoading: false },
|
||||
() => {
|
||||
if (btcAddressRx.test(data) || data.indexOf('bc1') === 0) {
|
||||
this.setState({
|
||||
address,
|
||||
amount: options.amount,
|
||||
memo: options.label || options.message,
|
||||
address: data,
|
||||
bip70TransactionExpiration: null,
|
||||
isLoading: false,
|
||||
});
|
||||
} else if (BitcoinBIP70TransactionDecode.matchesPaymentURL(data)) {
|
||||
BitcoinBIP70TransactionDecode.decode(data)
|
||||
.then(response => {
|
||||
this.setState({
|
||||
address: response.address,
|
||||
amount: loc.formatBalanceWithoutSuffix(response.amount, BitcoinUnit.BTC),
|
||||
memo: response.memo,
|
||||
fee: response.fee,
|
||||
bip70TransactionExpiration: response.expires,
|
||||
} else {
|
||||
let address, options;
|
||||
try {
|
||||
const decoded = bip21.decode(data);
|
||||
address = decoded.address;
|
||||
options = decoded.options;
|
||||
} catch (Err) {
|
||||
console.log(Err);
|
||||
}
|
||||
console.log(options);
|
||||
if (btcAddressRx.test(address)) {
|
||||
this.setState({
|
||||
address,
|
||||
amount: options.amount,
|
||||
memo: options.label || options.message,
|
||||
bip70TransactionExpiration: null,
|
||||
isLoading: false,
|
||||
});
|
||||
} else if (BitcoinBIP70TransactionDecode.matchesPaymentURL(data)) {
|
||||
BitcoinBIP70TransactionDecode.decode(data)
|
||||
.then(response => {
|
||||
this.setState({
|
||||
address: response.address,
|
||||
amount: loc.formatBalanceWithoutSuffix(response.amount),
|
||||
memo: response.memo,
|
||||
fee: response.fee,
|
||||
bip70TransactionExpiration: response.expires,
|
||||
isLoading: false,
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
this.setState({ isLoading: false });
|
||||
alert(error.errorMessage);
|
||||
});
|
||||
})
|
||||
.catch(error => alert(error.errorMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
true,
|
||||
);
|
||||
},
|
||||
true,
|
||||
);
|
||||
});
|
||||
let recommendedFees = await NetworkTransactionFees.recommendedFees().catch(response => {
|
||||
this.setState({
|
||||
fee: response.halfHourFee,
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
BlueNavigationStyle,
|
||||
} from '../../BlueComponents';
|
||||
import PropTypes from 'prop-types';
|
||||
import { BitcoinUnit } from '../../models/bitcoinUnits';
|
||||
/** @type {AppStorage} */
|
||||
let BlueApp = require('../../BlueApp');
|
||||
let loc = require('../../loc');
|
||||
|
@ -63,7 +64,6 @@ export default class TransactionsDetails extends Component {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.state = {
|
||||
isLoading: true,
|
||||
tx: foundTx,
|
||||
|
@ -140,6 +140,13 @@ export default class TransactionsDetails extends Component {
|
|||
</React.Fragment>
|
||||
)}
|
||||
|
||||
{this.state.tx.hasOwnProperty('fee') && (
|
||||
<React.Fragment>
|
||||
<BlueText style={{ fontSize: 16, fontWeight: '500', marginBottom: 4 }}>{loc.send.create.fee}</BlueText>
|
||||
<BlueText style={{ marginBottom: 26, color: 'grey' }}>{loc.formatBalance(this.state.tx.fee, BitcoinUnit.BTC)}</BlueText>
|
||||
</React.Fragment>
|
||||
)}
|
||||
|
||||
{this.state.tx.hasOwnProperty('hash') && (
|
||||
<React.Fragment>
|
||||
<View style={{ flex: 1, flexDirection: 'row', marginBottom: 4, justifyContent: 'space-between' }}>
|
||||
|
@ -160,6 +167,7 @@ export default class TransactionsDetails extends Component {
|
|||
</TouchableOpacity>
|
||||
</React.Fragment>
|
||||
)}
|
||||
|
||||
{this.state.tx.hasOwnProperty('received') && (
|
||||
<React.Fragment>
|
||||
<BlueText style={{ fontSize: 16, fontWeight: '500', marginBottom: 4 }}>Received</BlueText>
|
||||
|
|
|
@ -438,7 +438,7 @@ export default class WalletTransactions extends Component {
|
|||
containerStyle: { marginTop: 0 },
|
||||
}}
|
||||
hideChevron
|
||||
rightTitle={loc.formatBalance(
|
||||
rightTitle={loc.formatBalanceWithoutSuffix(
|
||||
new BigNumber((rowData.item.value && rowData.item.value) || 0).dividedBy(100000000),
|
||||
this.state.wallet.getPreferredBalanceUnit(),
|
||||
)}
|
||||
|
|
Loading…
Add table
Reference in a new issue