From 30d34064be5ab74cf35362aa42d83c7a77a5ff9a Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 21 Nov 2024 23:36:16 -0500 Subject: [PATCH 1/2] ZEUS Pay: update regenerate pre-image flow --- locales/en.json | 3 ++- stores/LightningAddressStore.ts | 10 ++++++++++ views/Settings/LightningAddress/index.tsx | 18 +++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/locales/en.json b/locales/en.json index f47e0ac48..a652dd135 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1071,7 +1071,7 @@ "stores.SettingsStore.lncConnectError": "Failed to connect the LNC client to the proxy server", "stores.LSPStore.error": "LSP error", "stores.LSPStore.connectionError": "Could not connect to LSP. Please check your LSP settings or try again later.", - "stores.LightningAddressStore.preimageNotFound": "Pre-image not found on your device. Did you recently change devices? Shuffle your Nostr keys in settings to regenerate and resubmit hashes.", + "stores.LightningAddressStore.preimageNotFound": "Pre-image not found on your device. Did you recently change devices?", "error.connectionRefused": "Host unreachable. Try restarting your node or its Tor process.", "error.hostUnreachable": "Host unreachable. Try restarting your node or its Tor process.", "error.torBootstrap": "Error starting up Tor on your phone. Try restarting Zeus. If the problem persists consider using the Orbot app to connect to Tor, or using an alternative connection method like Lightning Node Connect or Tailscale.", @@ -1128,6 +1128,7 @@ "views.Settings.LightningAddress.explainer2": "The easiest way to do so is to purchase a 0-conf channel from our LSP, OLYMPUS by ZEUS. Just generate an invoice and pay yourself from another lightning wallet.", "views.Settings.LightningAddress.explainer3": "For best results, open up a channel with our node, OLYMPUS by ZEUS.", "views.Settings.LightningAddress.get0ConfChan": "Get 0-conf channel", + "views.Settings.LightningAddress.generateNew": "Generate new pre-images", "views.Settings.LightningAddressSettings.title": "Lightning address settings", "views.Settings.LightningAddressSettings.automaticallyAccept": "Automatically accept payments on startup", "views.Settings.LightningAddressSettings.automaticallyAcceptAttestationLevel": "Attestation level for automatic acceptance", diff --git a/stores/LightningAddressStore.ts b/stores/LightningAddressStore.ts index 41d653627..1882c302a 100644 --- a/stores/LightningAddressStore.ts +++ b/stores/LightningAddressStore.ts @@ -62,6 +62,16 @@ export default class LightningAddressStore { this.settingsStore = settingsStore; } + @action + public deleteAndGenerateNewPreimages = async () => { + this.loading = true; + await EncryptedStorage.setItem( + HASHES_STORAGE_STRING, + JSON.stringify('') + ); + this.generatePreimages(true); + }; + @action public DEV_deleteLocalHashes = async () => { this.loading = true; diff --git a/views/Settings/LightningAddress/index.tsx b/views/Settings/LightningAddress/index.tsx index c8677a6a7..bb81dc131 100644 --- a/views/Settings/LightningAddress/index.tsx +++ b/views/Settings/LightningAddress/index.tsx @@ -169,7 +169,8 @@ export default class LightningAddress extends React.Component< redeeming, redeemingAll, readyToAutomaticallyAccept, - prepareToAutomaticallyAcceptStart + prepareToAutomaticallyAcceptStart, + deleteAndGenerateNewPreimages } = LightningAddressStore; const { fontScale } = Dimensions.get('window'); @@ -272,6 +273,21 @@ export default class LightningAddress extends React.Component< {!loading && !redeeming && !!error_msg && ( )} + {!loading && + !redeeming && + error_msg === + localeString( + 'stores.LightningAddressStore.preimageNotFound' + ) && ( +