mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 23:08:07 +01:00
FIX: failed to decode simple address from URL scheme? #190
FIX: Paid Invoice UI errors.
This commit is contained in:
parent
bba840d2bf
commit
39deff924e
4 changed files with 66 additions and 44 deletions
|
@ -33,7 +33,7 @@
|
|||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>197</string>
|
||||
<string>200</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
|
|
@ -27,7 +27,7 @@ export default class LNDViewInvoice extends Component {
|
|||
invoice,
|
||||
fromWallet,
|
||||
isLoading: typeof invoice === 'string',
|
||||
addressText: typeof invoice === 'object' ? invoice.payment_request : invoice,
|
||||
addressText: typeof invoice === 'object' && invoice.hasOwnProperty('payment_request') ? invoice.payment_request : invoice,
|
||||
isFetchingInvoices: true,
|
||||
};
|
||||
this.fetchInvoiceInterval = undefined;
|
||||
|
@ -81,7 +81,7 @@ export default class LNDViewInvoice extends Component {
|
|||
|
||||
copyToClipboard = () => {
|
||||
this.setState({ addressText: loc.receive.details.copiedToClipboard }, () => {
|
||||
Clipboard.setString('lightning:' + this.state.invoice.payment_request);
|
||||
Clipboard.setString(this.state.invoice.payment_request);
|
||||
setTimeout(() => this.setState({ addressText: this.state.invoice.payment_request }), 1000);
|
||||
});
|
||||
};
|
||||
|
@ -97,7 +97,7 @@ export default class LNDViewInvoice extends Component {
|
|||
const now = (currentDate.getTime() / 1000) | 0;
|
||||
const invoiceExpiration = invoice.timestamp + invoice.expire_time;
|
||||
|
||||
if (invoice.ispaid) {
|
||||
if (invoice.ispaid || invoice.type === 'paid_invoice') {
|
||||
return (
|
||||
<SafeBlueArea style={{ flex: 1 }}>
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
|
@ -124,6 +124,20 @@ export default class LNDViewInvoice extends Component {
|
|||
return (
|
||||
<SafeBlueArea style={{ flex: 1 }}>
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: '#ccddf9',
|
||||
width: 120,
|
||||
height: 120,
|
||||
borderRadius: 60,
|
||||
alignSelf: 'center',
|
||||
justifyContent: 'center',
|
||||
marginTop: 43,
|
||||
marginBottom: 53,
|
||||
}}
|
||||
>
|
||||
<Icon name="times" size={50} type="font-awesome" color="#0f5cc0" />
|
||||
</View>
|
||||
<BlueText>This invoice was not paid for and has expired</BlueText>
|
||||
</View>
|
||||
</SafeBlueArea>
|
||||
|
@ -144,49 +158,47 @@ export default class LNDViewInvoice extends Component {
|
|||
// Invoice has not expired, nor has it been paid for.
|
||||
return (
|
||||
<SafeBlueArea style={{ flex: 1 }}>
|
||||
<ScrollView>
|
||||
<ScrollView contentContainerStyle={{ flex: 1, justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<QRFast
|
||||
value={typeof this.state.invoice === 'object' ? invoice.payment_request : invoice}
|
||||
size={width}
|
||||
size={width - 40}
|
||||
fgColor={BlueApp.settings.brandingColor}
|
||||
bgColor={BlueApp.settings.foregroundColor}
|
||||
/>
|
||||
<View style={{ flex: 1, justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 16 }}>
|
||||
{invoice && invoice.amt && <BlueText>Please pay {invoice.amt} sats</BlueText>}
|
||||
{invoice && invoice.description && <BlueText>For: {invoice.description}</BlueText>}
|
||||
<TouchableOpacity onPress={this.copyToClipboard}>
|
||||
<Animated.Text style={styles.address} numberOfLines={0}>
|
||||
{this.state.addressText}
|
||||
</Animated.Text>
|
||||
</TouchableOpacity>
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 16 }}>
|
||||
{invoice && invoice.amt && <BlueText>Please pay {invoice.amt} sats</BlueText>}
|
||||
{invoice && invoice.description && <BlueText>For: {invoice.description}</BlueText>}
|
||||
<TouchableOpacity onPress={this.copyToClipboard}>
|
||||
<Animated.Text style={styles.address} numberOfLines={0}>
|
||||
{this.state.addressText}
|
||||
</Animated.Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<BlueButton
|
||||
icon={{
|
||||
name: 'share-alternative',
|
||||
type: 'entypo',
|
||||
color: BlueApp.settings.buttonTextColor,
|
||||
}}
|
||||
onPress={async () => {
|
||||
Share.share({
|
||||
message: 'lightning:' + invoice.payment_request,
|
||||
});
|
||||
}}
|
||||
title={loc.receive.details.share}
|
||||
/>
|
||||
<BlueButton
|
||||
buttonStyle={{ backgroundColor: 'white' }}
|
||||
icon={{
|
||||
name: 'info',
|
||||
type: 'entypo',
|
||||
color: BlueApp.settings.buttonTextColor,
|
||||
}}
|
||||
onPress={() => this.props.navigation.navigate('LNDViewAdditionalInvoiceInformation', { fromWallet: this.state.fromWallet })}
|
||||
title="Additional Information"
|
||||
/>
|
||||
</View>
|
||||
<View style={{ marginBottom: 24 }} />
|
||||
<BlueButton
|
||||
icon={{
|
||||
name: 'share-alternative',
|
||||
type: 'entypo',
|
||||
color: BlueApp.settings.buttonTextColor,
|
||||
}}
|
||||
onPress={async () => {
|
||||
Share.share({
|
||||
message: 'lightning:' + invoice.payment_request,
|
||||
});
|
||||
}}
|
||||
title={loc.receive.details.share}
|
||||
/>
|
||||
<BlueButton
|
||||
buttonStyle={{ backgroundColor: 'white' }}
|
||||
icon={{
|
||||
name: 'info',
|
||||
type: 'entypo',
|
||||
color: BlueApp.settings.buttonTextColor,
|
||||
}}
|
||||
onPress={() => this.props.navigation.navigate('LNDViewAdditionalInvoiceInformation', { fromWallet: this.state.fromWallet })}
|
||||
title="Additional Information"
|
||||
/>
|
||||
</View>
|
||||
<View style={{ marginBottom: 24 }} />
|
||||
</ScrollView>
|
||||
</SafeBlueArea>
|
||||
);
|
||||
|
|
|
@ -146,9 +146,15 @@ export default class SendDetails extends Component {
|
|||
let memo = '';
|
||||
|
||||
parsedBitcoinUri = bip21.decode(this.props.navigation.state.params.uri);
|
||||
address = parsedBitcoinUri.address || address;
|
||||
amount = parsedBitcoinUri.options.amount.toString() || amount;
|
||||
memo = parsedBitcoinUri.options.label || memo;
|
||||
address = parsedBitcoinUri.hasOwnProperty('address') ? parsedBitcoinUri.address : address;
|
||||
if (parsedBitcoinUri.hasOwnProperty('options')) {
|
||||
if (parsedBitcoinUri.options.hasOwnProperty('amount')) {
|
||||
amount = parsedBitcoinUri.options.amount.toString();
|
||||
}
|
||||
if (parsedBitcoinUri.options.hasOwnProperty('label')) {
|
||||
memo = parsedBitcoinUri.options.label || memo;
|
||||
}
|
||||
}
|
||||
this.setState({ address, amount, memo });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
|
@ -518,7 +518,11 @@ export default class WalletTransactions extends Component {
|
|||
navigate('TransactionDetails', {
|
||||
hash: rowData.item.hash,
|
||||
});
|
||||
} else if (rowData.item.type === 'user_invoice' || rowData.item.type === 'payment_request') {
|
||||
} else if (
|
||||
rowData.item.type === 'user_invoice' ||
|
||||
rowData.item.type === 'payment_request' ||
|
||||
rowData.item.type === 'paid_invoice'
|
||||
) {
|
||||
this.props.navigation.navigate('LNDViewExistingInvoice', {
|
||||
invoice: rowData.item,
|
||||
fromWallet: this.state.wallet,
|
||||
|
|
Loading…
Add table
Reference in a new issue