diff --git a/stores/LightningAddressStore.ts b/stores/LightningAddressStore.ts
index 7910f6040..950267ec3 100644
--- a/stores/LightningAddressStore.ts
+++ b/stores/LightningAddressStore.ts
@@ -44,7 +44,8 @@ export default class LightningAddressStore {
@observable public redeemingAll: boolean = false;
@observable public error: boolean = false;
@observable public error_msg: string = '';
- @observable public availableHashes: number = 0;
+ @observable public availableHashes: number = 0; // on server
+ @observable public localHashes: number = 0; // on device
@observable public paid: any = [];
@observable public preimageMap: any = {};
@observable public fees: any = {};
@@ -63,6 +64,17 @@ export default class LightningAddressStore {
this.settingsStore = settingsStore;
}
+ @action
+ public DEV_deleteLocalHashes = async () => {
+ this.loading = true;
+ await EncryptedStorage.setItem(
+ HASHES_STORAGE_STRING,
+ JSON.stringify('')
+ );
+ await this.status();
+ this.loading = false;
+ };
+
@action
public getPreimageMap = async () => {
this.loading = true;
@@ -70,11 +82,11 @@ export default class LightningAddressStore {
if (map) {
this.preimageMap = JSON.parse(map);
- this.loading = false;
- return this.preimageMap;
- } else {
- this.loading = false;
+ this.localHashes = Object.keys(this.preimageMap).length;
}
+
+ this.loading = false;
+ return this.preimageMap;
};
@action
@@ -116,7 +128,7 @@ export default class LightningAddressStore {
};
@action
- public generatePreimages = async () => {
+ public generatePreimages = async (newDevice?: boolean) => {
this.error = false;
this.error_msg = '';
this.loading = true;
@@ -207,14 +219,16 @@ export default class LightningAddressStore {
message: verification,
signature,
hashes,
- nostrSignatures
+ nostrSignatures,
+ newDevice
}
: {
pubkey: this.nodeInfoStore
.nodeInfo.identity_pubkey,
message: verification,
signature,
- hashes
+ hashes,
+ newDevice
}
)
)
@@ -572,6 +586,7 @@ export default class LightningAddressStore {
}
this.loading = false;
this.availableHashes = results || 0;
+ await this.getPreimageMap();
this.paid =
this.enhanceWithFee(paid);
this.fees = fees;
@@ -585,6 +600,11 @@ export default class LightningAddressStore {
}
if (
+ this.lightningAddress &&
+ this.localHashes === 0
+ ) {
+ this.generatePreimages(true);
+ } else if (
this.lightningAddress &&
new BigNumber(
this.availableHashes
@@ -1052,7 +1072,7 @@ export default class LightningAddressStore {
});
}
}
- this.status();
+ this.status(true);
this.redeemingAll = false;
};
@@ -1153,6 +1173,7 @@ export default class LightningAddressStore {
this.error = false;
this.error_msg = '';
this.availableHashes = 0;
+ this.localHashes = 0;
this.paid = [];
this.preimageMap = {};
this.socket = undefined;
diff --git a/views/Settings/LightningAddress/index.tsx b/views/Settings/LightningAddress/index.tsx
index 1e8fe2386..c8677a6a7 100644
--- a/views/Settings/LightningAddress/index.tsx
+++ b/views/Settings/LightningAddress/index.tsx
@@ -156,9 +156,11 @@ export default class LightningAddress extends React.Component<
create,
status,
redeemAllOpenPayments,
+ DEV_deleteLocalHashes,
lightningAddressHandle,
lightningAddressDomain,
availableHashes,
+ localHashes,
paid,
fees,
error,
@@ -350,7 +352,9 @@ export default class LightningAddress extends React.Component<
)
]}
>
- {` (${availableHashes})`}
+ {` (${
+ __DEV__ ? `${localHashes}|` : ''
+ }${availableHashes})`}
@@ -794,6 +798,17 @@ export default class LightningAddress extends React.Component<
disabled={!isReady}
/>
)}
+ {__DEV__ && (
+
+
+ )}
>
)}
>