Skip to content

Commit

Permalink
Merge pull request #984 from kaloudis/spark-fixes
Browse files Browse the repository at this point in the history
Spark fixes
  • Loading branch information
kaloudis committed May 20, 2022
2 parents 9ab640e + e8472ab commit 4de55e6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
2 changes: 2 additions & 0 deletions backends/Spark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ export default class Spark {
supportsCoinControl = () => false;
supportsHopPicking = () => false;
supportsRouting = () => true;
supportsNodeInfo = () => true;
supportsAccounts = () => false;
singleFeesEarnedTotal = () => false;
supportsAddressTypeSelection = () => false;
supportsTaproot = () => false;
Expand Down
2 changes: 2 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@
"backends.LND.wsReq.warning": "You may have to enable Certificate Verification to make these kind of calls",
"utils.handleAnything.lightningAddressError": "Error fetching Lightning Address data",
"utils.handleAnything.notValid": "Value provided was not a valid Bitcoin address or Lightning Invoice",
"utils.handleAnything.lnurlAuthNotSupported": "LnurlAuth not supported by your node implementation",
"utils.handleAnything.unsupportedLnurlType": "Unsupported lnurl type",
"stores.InvoicesStore.errorCreatingInvoice": "Error creating invoice",
"stores.InvoicesStore.errorGeneratingAddress": "Error generating new address",
"stores.SettingsStore.btcPayImplementationSupport": "Sorry, we currently only support BTCPay instances using lnd or c-lightning",
Expand Down
3 changes: 2 additions & 1 deletion stores/InvoicesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ export default class InvoicesStore {
this.onChainAddress = null;
return RESTUtils.getNewAddress(params)
.then((data: any) => {
this.onChainAddress = data.address || data[0].address;
this.onChainAddress =
data.address || data.bech32 || data[0].address;
this.loading = false;
})
.catch((error: any) => {
Expand Down
51 changes: 42 additions & 9 deletions utils/handleAnything.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Alert } from 'react-native';
import { getParams as getlnurlParams, findlnurl } from 'js-lnurl';
import ReactNativeBlobUtil from 'react-native-blob-util';
import stores from '../stores/Stores';
import AddressUtils from './../utils/AddressUtils';
import LndConnectUtils from './../utils/LndConnectUtils';
import NodeUriUtils from './../utils/NodeUriUtils';
import { localeString } from './../utils/LocaleUtils';
import RESTUtils from './../utils/RESTUtils';

const { nodeInfoStore, invoicesStore } = stores;

Expand Down Expand Up @@ -143,22 +145,53 @@ export default async function (data: string): Promise<any> {
];
break;
case 'login':
return [
'LnurlAuth',
{
lnurlParams: params
}
];
if (RESTUtils.supportsMessageSigning()) {
return [
'LnurlAuth',
{
lnurlParams: params
}
];
} else {
Alert.alert(
localeString('general.error'),
localeString(
'utils.handleAnything.lnurlAuthNotSupported'
),
[
{
text: localeString('general.ok'),
onPress: () => void 0
}
],
{ cancelable: false }
);
}
break;
default:
throw new Error(
Alert.alert(
localeString('general.error'),
params.status === 'ERROR'
? `${params.domain} says: ${params.reason}`
: `Unsupported lnurl type: ${params.tag}`
: `${localeString(
'utils.handleAnything.unsupportedLnurlType'
)}: ${params.tag}`,
[
{
text: localeString('general.ok'),
onPress: () => void 0
}
],
{ cancelable: false }
);
}
});
} else {
throw new Error(localeString('utils.handleAnything.notValid'));
Alert.alert(
localeString('general.error'),
localeString('utils.handleAnything.notValid'),
[{ text: localeString('general.ok'), onPress: () => void 0 }],
{ cancelable: false }
);
}
}

0 comments on commit 4de55e6

Please sign in to comment.