Skip to content

Commit

Permalink
Merge pull request #2555 from kaloudis/zeus-pay-regenerate-flow
Browse files Browse the repository at this point in the history
ZEUS Pay: update regenerate pre-image flow
  • Loading branch information
kaloudis authored Nov 24, 2024
2 parents f177245 + 7b42c85 commit beeb6b7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,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.",
Expand Down Expand Up @@ -1134,6 +1134,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",
Expand Down
10 changes: 10 additions & 0 deletions stores/LightningAddressStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 19 additions & 4 deletions views/Settings/LightningAddress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ export default class LightningAddress extends React.Component<
localHashes,
paid,
fees,
error,
error_msg,
loading,
redeeming,
redeemingAll,
readyToAutomaticallyAccept,
prepareToAutomaticallyAcceptStart
prepareToAutomaticallyAcceptStart,
deleteAndGenerateNewPreimages
} = LightningAddressStore;

const { fontScale } = Dimensions.get('window');
Expand Down Expand Up @@ -254,8 +254,8 @@ export default class LightningAddress extends React.Component<
rightComponent={
!loading && !redeeming && !redeemingAll ? (
<Row>
{fees && !error && <InfoButton />}
{lightningAddressHandle && !error && (
{fees && <InfoButton />}
{lightningAddressHandle && (
<SettingsButton />
)}
</Row>
Expand All @@ -272,6 +272,21 @@ export default class LightningAddress extends React.Component<
{!loading && !redeeming && !!error_msg && (
<ErrorMessage message={error_msg} dismissable />
)}
{!loading &&
!redeeming &&
error_msg ===
localeString(
'stores.LightningAddressStore.preimageNotFound'
) && (
<Button
title={localeString(
'views.Settings.LightningAddress.generateNew'
)}
onPress={() =>
deleteAndGenerateNewPreimages()
}
/>
)}
{!loading &&
!redeemingAll &&
!redeeming &&
Expand Down

0 comments on commit beeb6b7

Please sign in to comment.