From 6653a354dd4f84c2c841a61792c26a6cfe4380d7 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 21 Sep 2023 15:28:26 -0400 Subject: [PATCH 1/5] ZEUS-1651: Switching nodes freezes app (Android) --- backends/LndHub.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backends/LndHub.ts b/backends/LndHub.ts index a7ebfe1325..bbe71157d5 100644 --- a/backends/LndHub.ts +++ b/backends/LndHub.ts @@ -119,12 +119,12 @@ export default class LndHub extends LND { supportsOnchainSends = () => false; supportsOnchainReceiving = () => !( - stores.settingsStore.lndhubUrl.includes('lnbank/api/lndhub') || - stores.settingsStore.lndhubUrl.includes('lntxbot') || + stores?.settingsStore?.lndhubUrl?.includes('lnbank/api/lndhub') || + stores?.settingsStore?.lndhubUrl?.includes('lntxbot') || // Alby - stores.settingsStore.lndhubUrl.includes('ln.getalby.com') || + stores?.settingsStore?.lndhubUrl?.includes('ln.getalby.com') || // LNBits - stores.settingsStore.lndhubUrl.includes('/lndhub/ext/') + stores?.settingsStore?.lndhubUrl?.includes('/lndhub/ext/') ); supportsKeysend = () => false; supportsChannelManagement = () => false; From e479a30a4a5cccdcdc652681c496497d2033ef9a Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 21 Sep 2023 20:16:31 -0400 Subject: [PATCH 2/5] Receive: get LNURLw working with LSPs --- stores/InvoicesStore.ts | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/stores/InvoicesStore.ts b/stores/InvoicesStore.ts index 4c540bfa72..11c39f70e9 100644 --- a/stores/InvoicesStore.ts +++ b/stores/InvoicesStore.ts @@ -260,11 +260,24 @@ export default class InvoicesStore { if (!unified) this.creatingInvoice = false; + let jit_bolt11: string = ''; + if ( + BackendUtils.supportsLSPs() && + this.settingsStore.settings?.enableLSP && + value !== '0' + ) { + await this.lspStore + .getZeroConfInvoice(invoice.getPaymentRequest) + .then((response: any) => { + jit_bolt11 = response; + }); + } + if (lnurl) { const u = url.parse(lnurl.callback); const qs = querystring.parse(u.query); qs.k1 = lnurl.k1; - qs.pr = invoice.getPaymentRequest; + qs.pr = jit_bolt11 || invoice.getPaymentRequest; u.search = querystring.stringify(qs); u.query = querystring.stringify(qs); @@ -301,25 +314,11 @@ export default class InvoicesStore { }); } - if ( - BackendUtils.supportsLSPs() && - this.settingsStore.settings?.enableLSP && - value !== '0' - ) { - return await this.lspStore - .getZeroConfInvoice(invoice.getPaymentRequest) - .then((response: any) => { - const jit_bolt11: string = response; - return { - rHash: invoice.getFormattedRhash, - paymentRequest: jit_bolt11 - }; - }); - } - return { rHash: invoice.getFormattedRhash, - paymentRequest: invoice.getPaymentRequest + paymentRequest: jit_bolt11 + ? jit_bolt11 + : invoice.getPaymentRequest }; }) .catch((error: any) => { From f91316a32045e13edebde369f17f362cbe49eb26 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Sat, 23 Sep 2023 12:51:24 -0400 Subject: [PATCH 3/5] Keysend patch --- utils/Base64Utils.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/utils/Base64Utils.ts b/utils/Base64Utils.ts index 9c49374432..9f76cb7aad 100644 --- a/utils/Base64Utils.ts +++ b/utils/Base64Utils.ts @@ -1,8 +1,33 @@ +const chars = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + class Base64Utils { encodeStringToBase64 = (input = '') => Buffer.from(input).toString('base64'); decodeBase64ToString = (input = '') => Buffer.from(input, 'base64').toString('utf8'); + btoa = (input = '') => { + const str = input; + let output = ''; + + for ( + let block = 0, charCode, i = 0, map = chars; + str.charAt(i | 0) || ((map = '='), i % 1); + output += map.charAt(63 & (block >> (8 - (i % 1) * 8))) + ) { + charCode = str.charCodeAt((i += 3 / 4)); + + if (charCode > 0xff) { + throw new Error( + "'btoa' failed: The string to be encoded contains characters outside of the Latin1 range." + ); + } + + block = (block << 8) | charCode; + } + + return output; + }; hexStringToByte = (str = '') => { if (!str) { @@ -24,7 +49,7 @@ class Base64Utils { for (let i = 0; i < len; i++) { binary += String.fromCharCode(bytes[i]); } - return this.encodeStringToBase64(binary); + return this.btoa(binary); }; hexToBase64 = (str = '') => this.byteToBase64(this.hexStringToByte(str)); From 6583f860b0ab0a1fb50c40828359110ac7aa35cf Mon Sep 17 00:00:00 2001 From: myxmaster Date: Sun, 24 Sep 2023 20:31:45 +0200 Subject: [PATCH 4/5] fixed unit switcher icon --- components/AmountInput.tsx | 2 +- stores/UnitsStore.ts | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/components/AmountInput.tsx b/components/AmountInput.tsx index 950dac90cb..265087946e 100644 --- a/components/AmountInput.tsx +++ b/components/AmountInput.tsx @@ -179,7 +179,7 @@ export default class AmountInput extends React.Component< onPress={() => !locked && this.onChangeUnits()} style={{ marginTop: 22, marginLeft: 15 }} > - {fiatEnabled && units !== 'fiat' ? ( + {UnitsStore!.getNextUnit() === 'fiat' ? ( { + public changeUnits = () => (this.units = this.getNextUnit()); + + public getNextUnit = () => { const { settings } = this.settingsStore; const { fiatEnabled } = settings; if (!fiatEnabled) { - this.units = this.units == 'sats' ? 'BTC' : 'sats'; + return this.units === 'sats' ? 'BTC' : 'sats'; } else { switch (this.units) { case 'sats': - this.units = 'BTC'; - break; + return 'BTC'; case 'BTC': - this.units = 'fiat'; - break; - case 'fiat': - this.units = 'sats'; - break; + return 'fiat'; + default: + return 'sats'; } } }; From 7394231532abfe3dca60dd6fd3c07e7d45c55f63 Mon Sep 17 00:00:00 2001 From: myxmaster Date: Sun, 24 Sep 2023 23:07:03 +0200 Subject: [PATCH 5/5] do not navigate to Send to handle clipboard but handle it identically to QR code handling --- components/WalletHeader.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/WalletHeader.tsx b/components/WalletHeader.tsx index 79c9f8d8cf..699070109a 100644 --- a/components/WalletHeader.tsx +++ b/components/WalletHeader.tsx @@ -22,7 +22,7 @@ import Header from './Header'; import LoadingIndicator from '../components/LoadingIndicator'; import NodeIdenticon from '../components/NodeIdenticon'; -import { isClipboardValue } from '../utils/handleAnything'; +import handleAnything, { isClipboardValue } from '../utils/handleAnything'; import { localeString } from '../utils/LocaleUtils'; import PrivacyUtils from '../utils/PrivacyUtils'; import { themeColor } from '../utils/ThemeUtils'; @@ -106,7 +106,11 @@ const ClipboardBadge = ({ clipboard: string; }) => ( navigation.navigate('Send', { destination: clipboard })} + onPress={async () => { + const response = await handleAnything(clipboard); + const [route, props] = response; + navigation.navigate(route, props); + }} >