]> git.codecow.com Git - libnemo.git/commitdiff
Destroy wallet safe asynchronously.
authorChris Duncan <chris@zoso.dev>
Thu, 3 Jul 2025 19:51:54 +0000 (12:51 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 3 Jul 2025 19:51:54 +0000 (12:51 -0700)
src/lib/wallets/bip44-wallet.ts
src/lib/wallets/wallet.ts

index 2f5d9aa5316eac3351d5a6dbd76cd3aed6db2111..dcbf72b9b9f140584dc28d2a738c909a6f4bbc79 100644 (file)
@@ -47,8 +47,8 @@ export class Bip44Wallet extends Wallet {
        * Removes encrypted secrets in storage and releases variable references to\r
        * allow garbage collection.\r
        */\r
-       destroy () {\r
-               super.destroy()\r
+       async destroy (): Promise<void> {\r
+               await super.destroy()\r
                this.#poolBip44Ckd.terminate()\r
        }\r
 \r
index 4113fd467e94222a6577504d38f1d124dbd4b452..726d20af4a6d77562b54da5ea8490b0f8e167f65 100644 (file)
@@ -65,7 +65,7 @@ export abstract class Wallet {
        * Removes encrypted secrets in storage and releases variable references to\r
        * allow garbage collection.\r
        */\r
-       destroy (): void {\r
+       async destroy (): Promise<void> {\r
                let i = 0\r
                for (const a in this.#accounts) {\r
                        this.#accounts[a].destroy()\r
@@ -75,10 +75,11 @@ export abstract class Wallet {
                this.#mnemonic = null\r
                this.#seed = null\r
                this.#poolNanoNacl.terminate()\r
-               this.#poolSafe.assign({\r
+               await this.#poolSafe.assign({\r
                        method: 'destroy',\r
                        name: this.id\r
-               }).finally(this.#poolSafe.terminate)\r
+               })\r
+               this.#poolSafe.terminate()\r
        }\r
 \r
        /**\r
@@ -276,11 +277,13 @@ export abstract class Wallet {
                        password = utf8.toBytes(password)\r
                }\r
                try {\r
-                       const { id, mnemonic, seed } = await this.#poolSafe.assign({\r
+                       const data = await this.#poolSafe.assign({\r
                                method: 'get',\r
                                name: this.id,\r
                                password\r
                        })\r
+                       console.log(data[0].result)\r
+                       const { id, mnemonic, seed } = data[0].result\r
                        if (id !== this.id) {\r
                                throw null\r
                        }\r