mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
Handle bitcoin uri and open SendDetails using first wallet
This commit is contained in:
parent
a450c865df
commit
1cf2561283
1 changed files with 24 additions and 3 deletions
|
@ -50,10 +50,12 @@ export default class SendDetails extends Component {
|
|||
if (props.navigation.state.params) fromAddress = props.navigation.state.params.fromAddress;
|
||||
let fromSecret;
|
||||
if (props.navigation.state.params) fromSecret = props.navigation.state.params.fromSecret;
|
||||
let fromWallet = {};
|
||||
let fromWallet = null;
|
||||
|
||||
const wallets = BlueApp.getWallets();
|
||||
|
||||
let startTime2 = Date.now();
|
||||
for (let w of BlueApp.getWallets()) {
|
||||
for (let w of wallets) {
|
||||
if (w.getSecret() === fromSecret) {
|
||||
fromWallet = w;
|
||||
break;
|
||||
|
@ -64,6 +66,24 @@ export default class SendDetails extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
// fallback to first wallet if it exists
|
||||
if (!fromWallet && wallets[0]) fromWallet = wallets[0];
|
||||
|
||||
let amount = '';
|
||||
let parsedBitcoinUri = null;
|
||||
if (props.navigation.state.params.uri) {
|
||||
try {
|
||||
parsedBitcoinUri = bip21.decode(props.navigation.state.params.uri);
|
||||
|
||||
address = parsedBitcoinUri.address ? parsedBitcoinUri.address : address;
|
||||
amount = parsedBitcoinUri.options.amount ? parsedBitcoinUri.options.amount : amount;
|
||||
memo = parsedBitcoinUri.options.label ? parsedBitcoinUri.options.label : memo;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert('Error: Unable to decode Bitcoin address');
|
||||
}
|
||||
}
|
||||
|
||||
let endTime2 = Date.now();
|
||||
console.log('getAddress() took', (endTime2 - startTime2) / 1000, 'sec');
|
||||
console.log({ memo });
|
||||
|
@ -75,7 +95,7 @@ export default class SendDetails extends Component {
|
|||
fromSecret: fromSecret,
|
||||
isLoading: true,
|
||||
address: address,
|
||||
amount: '',
|
||||
amount,
|
||||
memo,
|
||||
fee: 1,
|
||||
networkTransactionFees: new NetworkTransactionFee(1, 1, 1),
|
||||
|
@ -601,6 +621,7 @@ SendDetails.propTypes = {
|
|||
satoshiPerByte: PropTypes.string,
|
||||
fromSecret: PropTypes.fromSecret,
|
||||
memo: PropTypes.string,
|
||||
uri: PropTypes.string,
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
|
|
Loading…
Add table
Reference in a new issue