mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 09:50:15 +01:00
Merge branch 'master' of github.com:BlueWallet/BlueWallet
This commit is contained in:
commit
01b5661748
@ -2076,7 +2076,7 @@ export class BlueAddressInput extends Component {
|
|||||||
value={this.props.address}
|
value={this.props.address}
|
||||||
style={{ flex: 1, marginHorizontal: 8, minHeight: 33 }}
|
style={{ flex: 1, marginHorizontal: 8, minHeight: 33 }}
|
||||||
editable={!this.props.isLoading}
|
editable={!this.props.isLoading}
|
||||||
onSubmitEditing={() => Keyboard.dismiss()}
|
onSubmitEditing={Keyboard.dismiss}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
|
@ -39,7 +39,6 @@ class DeeplinkSchemaMatch {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
console.warn(isBothBitcoinAndLightning)
|
|
||||||
if (isBothBitcoinAndLightning) {
|
if (isBothBitcoinAndLightning) {
|
||||||
completionHandler({
|
completionHandler({
|
||||||
routeName: 'HandleOffchainAndOnChain',
|
routeName: 'HandleOffchainAndOnChain',
|
||||||
|
@ -80,10 +80,51 @@ export default class ScanLndInvoice extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
static getDerivedStateFromProps(props, state) {
|
||||||
if (this.props.navigation.state.params.uri) {
|
if (props.navigation.state.params.uri) {
|
||||||
this.processTextForInvoice(this.props.navigation.getParam('uri'));
|
let data = props.navigation.state.params.uri;
|
||||||
|
// handling BIP21 w/BOLT11 support
|
||||||
|
let ind = data.indexOf('lightning=');
|
||||||
|
if (ind !== -1) {
|
||||||
|
data = data.substring(ind + 10).split('&')[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
data = data.replace('LIGHTNING:', '').replace('lightning:', '');
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {LightningCustodianWallet}
|
||||||
|
*/
|
||||||
|
let w = state.fromWallet;
|
||||||
|
let decoded;
|
||||||
|
try {
|
||||||
|
decoded = w.decodeInvoice(data);
|
||||||
|
|
||||||
|
let expiresIn = (decoded.timestamp * 1 + decoded.expiry * 1) * 1000; // ms
|
||||||
|
if (+new Date() > expiresIn) {
|
||||||
|
expiresIn = 'expired';
|
||||||
|
} else {
|
||||||
|
expiresIn = Math.round((expiresIn - +new Date()) / (60 * 1000)) + ' min';
|
||||||
|
}
|
||||||
|
Keyboard.dismiss();
|
||||||
|
props.navigation.setParams({ uri: undefined });
|
||||||
|
return {
|
||||||
|
invoice: data,
|
||||||
|
decoded,
|
||||||
|
expiresIn,
|
||||||
|
destination: data,
|
||||||
|
isAmountInitiallyEmpty: decoded.num_satoshis === '0',
|
||||||
|
isLoading: false,
|
||||||
|
};
|
||||||
|
} catch (Err) {
|
||||||
|
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
|
||||||
|
Keyboard.dismiss();
|
||||||
|
props.navigation.setParams({ uri: undefined });
|
||||||
|
setTimeout(() => alert(Err.message), 10);
|
||||||
|
return { ...state, isLoading: false };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@ -100,52 +141,7 @@ export default class ScanLndInvoice extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
processInvoice = data => {
|
processInvoice = data => {
|
||||||
this.setState({ isLoading: true }, async () => {
|
this.props.navigation.setParams({ uri: data });
|
||||||
if (!this.state.fromWallet) {
|
|
||||||
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
|
|
||||||
alert('Before paying a Lightning invoice, you must first add a Lightning wallet.');
|
|
||||||
return this.props.navigation.goBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
// handling BIP21 w/BOLT11 support
|
|
||||||
let ind = data.indexOf('lightning=');
|
|
||||||
if (ind !== -1) {
|
|
||||||
data = data.substring(ind + 10).split('&')[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
data = data.replace('LIGHTNING:', '').replace('lightning:', '');
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {LightningCustodianWallet}
|
|
||||||
*/
|
|
||||||
let w = this.state.fromWallet;
|
|
||||||
let decoded;
|
|
||||||
try {
|
|
||||||
decoded = w.decodeInvoice(data);
|
|
||||||
|
|
||||||
let expiresIn = (decoded.timestamp * 1 + decoded.expiry * 1) * 1000; // ms
|
|
||||||
if (+new Date() > expiresIn) {
|
|
||||||
expiresIn = 'expired';
|
|
||||||
} else {
|
|
||||||
expiresIn = Math.round((expiresIn - +new Date()) / (60 * 1000)) + ' min';
|
|
||||||
}
|
|
||||||
Keyboard.dismiss();
|
|
||||||
this.setState({
|
|
||||||
invoice: data,
|
|
||||||
decoded,
|
|
||||||
expiresIn,
|
|
||||||
destination: data,
|
|
||||||
isAmountInitiallyEmpty: decoded.num_satoshis === '0',
|
|
||||||
isLoading: false,
|
|
||||||
});
|
|
||||||
} catch (Err) {
|
|
||||||
Keyboard.dismiss();
|
|
||||||
this.setState({ isLoading: false });
|
|
||||||
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
|
|
||||||
alert(Err.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async pay() {
|
async pay() {
|
||||||
@ -295,7 +291,7 @@ export default class ScanLndInvoice extends React.Component {
|
|||||||
<BlueCard>
|
<BlueCard>
|
||||||
<BlueAddressInput
|
<BlueAddressInput
|
||||||
onChangeText={text => {
|
onChangeText={text => {
|
||||||
this.setState({ destination: text });
|
text = text.trim();
|
||||||
this.processTextForInvoice(text);
|
this.processTextForInvoice(text);
|
||||||
}}
|
}}
|
||||||
onBarScanned={this.processInvoice}
|
onBarScanned={this.processInvoice}
|
||||||
@ -355,6 +351,7 @@ ScanLndInvoice.propTypes = {
|
|||||||
navigate: PropTypes.func,
|
navigate: PropTypes.func,
|
||||||
pop: PropTypes.func,
|
pop: PropTypes.func,
|
||||||
getParam: PropTypes.func,
|
getParam: PropTypes.func,
|
||||||
|
setParams: PropTypes.func,
|
||||||
dismiss: PropTypes.func,
|
dismiss: PropTypes.func,
|
||||||
state: PropTypes.shape({
|
state: PropTypes.shape({
|
||||||
routeName: PropTypes.string,
|
routeName: PropTypes.string,
|
||||||
|
@ -62,7 +62,7 @@ const ScanQRCode = ({
|
|||||||
right: 16,
|
right: 16,
|
||||||
top: 64,
|
top: 64,
|
||||||
}}
|
}}
|
||||||
onPress={() => launchedBy ? navigate(launchedBy) : goBack(null) }
|
onPress={() => (launchedBy ? navigate(launchedBy) : goBack(null))}
|
||||||
>
|
>
|
||||||
<Image style={{ alignSelf: 'center' }} source={require('../../img/close-white.png')} />
|
<Image style={{ alignSelf: 'center' }} source={require('../../img/close-white.png')} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/* global alert */
|
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
@ -68,7 +67,7 @@ export default class WalletsList extends Component {
|
|||||||
console.log('fetch all wallet txs took', (end - start) / 1000, 'sec');
|
console.log('fetch all wallet txs took', (end - start) / 1000, 'sec');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
noErr = false;
|
noErr = false;
|
||||||
alert(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
if (noErr) this.redrawScreen();
|
if (noErr) this.redrawScreen();
|
||||||
});
|
});
|
||||||
@ -111,7 +110,6 @@ export default class WalletsList extends Component {
|
|||||||
console.log('fetch tx took', (end - start) / 1000, 'sec');
|
console.log('fetch tx took', (end - start) / 1000, 'sec');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
noErr = false;
|
noErr = false;
|
||||||
alert(err);
|
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
}
|
}
|
||||||
if (noErr) await BlueApp.saveToDisk(); // caching
|
if (noErr) await BlueApp.saveToDisk(); // caching
|
||||||
@ -262,7 +260,6 @@ export default class WalletsList extends Component {
|
|||||||
}
|
}
|
||||||
} catch (Err) {
|
} catch (Err) {
|
||||||
noErr = false;
|
noErr = false;
|
||||||
alert(Err);
|
|
||||||
console.warn(Err);
|
console.warn(Err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user