Merge branch 'bug302' of github.com:BlueWallet/BlueWallet into bug302

This commit is contained in:
Marcos Rodriguez Vélez 2019-02-14 18:15:57 -05:00
commit 5d4c213e15
3 changed files with 19 additions and 3 deletions

View file

@ -110,6 +110,17 @@ export class LightningCustodianWallet extends LegacyWallet {
Authorization: 'Bearer' + ' ' + this.access_token, Authorization: 'Bearer' + ' ' + this.access_token,
}, },
}); });
if (response.originalResponse && typeof response.originalResponse === 'string') {
try {
response.originalResponse = JSON.parse(response.originalResponse);
} catch (_) {}
}
if (response.originalResponse && response.originalResponse.status && response.originalResponse.status === 503) {
throw new Error('Payment is in transit');
}
let json = response.body; let json = response.body;
if (typeof json === 'undefined') { if (typeof json === 'undefined') {
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.originalResponse)); throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.originalResponse));

View file

@ -47,7 +47,7 @@ export default class LNDCreateInvoice extends Component {
renderCreateButton = () => { renderCreateButton = () => {
return ( return (
<View style={{ paddingHorizontal: 56, paddingVertical: 16, alignContent: 'center', backgroundColor: '#FFFFFF' }}> <View style={{ marginHorizontal: 56, marginVertical: 16, minHeight: 45, alignContent: 'center', backgroundColor: '#FFFFFF' }}>
{this.state.isLoading ? ( {this.state.isLoading ? (
<ActivityIndicator /> <ActivityIndicator />
) : ( ) : (

View file

@ -83,6 +83,11 @@ export default class SendDetails extends Component {
}; };
} }
/**
* TODO: refactor this mess, get rid of regexp, use https://github.com/bitcoinjs/bitcoinjs-lib/issues/890 etc etc
*
* @param data {String} Can be address or `bitcoin:xxxxxxx` uri scheme, or invalid garbage
*/
processAddressData = data => { processAddressData = data => {
this.setState( this.setState(
{ isLoading: true }, { isLoading: true },
@ -91,7 +96,7 @@ export default class SendDetails extends Component {
this.processBIP70Invoice(data); this.processBIP70Invoice(data);
} else { } else {
const dataWithoutSchema = data.replace('bitcoin:', ''); const dataWithoutSchema = data.replace('bitcoin:', '');
if (btcAddressRx.test(dataWithoutSchema) || dataWithoutSchema.indexOf('bc1') === 0) { if (btcAddressRx.test(dataWithoutSchema) || (dataWithoutSchema.indexOf('bc1') === 0 && dataWithoutSchema.indexOf('?') === -1)) {
this.setState({ this.setState({
address: dataWithoutSchema, address: dataWithoutSchema,
bip70TransactionExpiration: null, bip70TransactionExpiration: null,
@ -111,7 +116,7 @@ export default class SendDetails extends Component {
this.setState({ isLoading: false }); this.setState({ isLoading: false });
} }
console.log(options); console.log(options);
if (btcAddressRx.test(address)) { if (btcAddressRx.test(address) || address.indexOf('bc1') === 0) {
this.setState({ this.setState({
address, address,
amount: options.amount, amount: options.amount,