]> git.codecow.com Git - libnemo.git/commitdiff
Destroy wallet on error during create or import.
authorChris Duncan <chris@zoso.dev>
Mon, 4 Aug 2025 22:20:30 +0000 (15:20 -0700)
committerChris Duncan <chris@zoso.dev>
Mon, 4 Aug 2025 22:20:30 +0000 (15:20 -0700)
src/lib/wallet.ts

index 15d631c8044d0663881ceec2b7ceb08d9ef17d18..54b5ce67e1e5f815e4ea5f6a79c606e389a1ad31 100644 (file)
@@ -63,6 +63,7 @@ export class Wallet {
                        await Database.add({ [self.id]: record }, Wallet.DB_NAME)\r
                        return self\r
                } catch (err) {\r
+                       await self.destroy()\r
                        throw new Error('Error creating new Wallet', { cause: err })\r
                }\r
        }\r
@@ -130,6 +131,7 @@ export class Wallet {
                        await Database.add({ [self.id]: record }, Wallet.DB_NAME)\r
                        return self\r
                } catch (err) {\r
+                       await self.destroy()\r
                        throw new Error('Error creating new Wallet', { cause: err })\r
                }\r
        }\r
@@ -137,7 +139,7 @@ export class Wallet {
        /**\r
        * Retrieves an existing wallet from the database using its UUID.\r
        *\r
-       * @param {string} id - Entered by user when the wallet was initially created\r
+       * @param {string} id - Generated when the wallet was created or imported\r
        * @returns {Wallet} Restored locked Wallet\r
        */\r
        static async restore (id: string): Promise<Wallet> {\r