From 83466ce415ab23e7bbbca68a5d45eccce5435ec2 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:02:34 +0100 Subject: [PATCH] better restore --- .github/workflows/docker.yaml | 1 + src/components/RestoreView.vue | 26 ++++++++++++++- src/components/SettingsView.vue | 57 +++++++++++++++++---------------- src/stores/restore.ts | 16 ++++----- 4 files changed, 62 insertions(+), 38 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 00ab0840..34834fed 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -1,6 +1,7 @@ name: Docker Build on: + push: pull_request: types: [opened, synchronize, reopened] release: diff --git a/src/components/RestoreView.vue b/src/components/RestoreView.vue index c10120a6..e2006321 100644 --- a/src/components/RestoreView.vue +++ b/src/components/RestoreView.vue @@ -9,7 +9,8 @@ Restore from Seed Phrase - Enter your seed phrase to restore your wallet. + Enter your seed phrase to restore your wallet. Before you restore, + make sure you have added all the mints that you have used before.
@@ -39,6 +40,26 @@
+ +
+ + + + + Information + + + The wizard will only restore ecash from another seed + phrase, you will not be able to use this seed phrase or change the + seed phrase of the wallet that you're currently using. This means + that restored ecash will not be protected by your current seed + phrase as long as you don't send the ecash to yourself once. + + + + +
+
@@ -196,10 +217,13 @@ export default defineComponent({ return; } try { + this.restoreAllMintsText = "Restoring mint ..."; await this.restoreMint(mintUrl); } catch (error) { console.error("Error restoring mint:", error); notifyError(`Error restoring mint: ${error.message || error}`); + } finally { + this.restoreAllMintsText = "Restore All Mints"; } }, async pasteMnemonic() { diff --git a/src/components/SettingsView.vue b/src/components/SettingsView.vue index 8843fdac..65e1afd6 100644 --- a/src/components/SettingsView.vue +++ b/src/components/SettingsView.vue @@ -48,6 +48,35 @@
+ +
+ + + + Restore ecash + The restore wizard lets you recover lost ecash from a mnemonic + seed phrase. The seed phrase of your current wallet will remain + unaffected, the wizard will only allow you to restore ecash + from another seed phrase. + + + + Restore + + +
@@ -672,34 +701,6 @@ - -
- - - - Restore ecash - The restore wizard lets you recover lost ecash from a - mnemonic seed phrase. - - - - Restore - - -
- ({ @@ -62,8 +62,8 @@ export const useRestoreStore = defineStore("restore", { let restoredSomething = false; // Calculate total steps for progress calculation - let totalSteps = keysets.length * MAX_GAP * 2; - let currentStep = 1; + let totalSteps = keysets.length * MAX_GAP; + let currentStep = 0; for (const keyset of keysets) { console.log(`Restoring keyset ${keyset.id} with unit ${keyset.unit}`); @@ -93,8 +93,8 @@ export const useRestoreStore = defineStore("restore", { ); restoreProofs = restoreProofs.concat(proofs); emptyBatchCount = 0; - totalSteps += MAX_GAP * 2; this.restoreCounter += proofs.length; + totalSteps += 1; } this.restoreStatus = `Restored ${this.restoreCounter} proofs for keyset ${keyset.id}`; start += BATCH_SIZE; @@ -105,9 +105,8 @@ export const useRestoreStore = defineStore("restore", { let restoredProofs: Proof[] = []; for (let i = 0; i < restoreProofs.length; i += BATCH_SIZE) { - this.restoreStatus = `Checking proofs ${i} to ${ - i + BATCH_SIZE - } for keyset ${keyset.id}`; + this.restoreStatus = `Checking proofs ${i} to ${i + BATCH_SIZE + } for keyset ${keyset.id}`; const checkRestoreProofs = restoreProofs.slice(i, i + BATCH_SIZE); const proofStates = await wallet.checkProofsStates( checkRestoreProofs @@ -121,8 +120,7 @@ export const useRestoreStore = defineStore("restore", { ); if (unspentProofs.length > 0) { console.log( - `Found ${ - unspentProofs.length + `Found ${unspentProofs.length } unspent proofs with sum ${unspentProofs.reduce( (s, p) => s + p.amount, 0