Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZEUS Pay: update regenerate pre-image flow #2555

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
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
Loading