]> git.codecow.com Git - libnemo.git/commitdiff
Do not store mnemonic if it does not exist.
authorChris Duncan <chris@zoso.dev>
Tue, 15 Jul 2025 18:43:14 +0000 (11:43 -0700)
committerChris Duncan <chris@zoso.dev>
Tue, 15 Jul 2025 18:43:14 +0000 (11:43 -0700)
src/lib/wallets/wallet.ts

index 5a1574da2eec36eebbe8a80273ead4185102fb1a..4834b5a56c15d643b5a4755cb071482f72f81730 100644 (file)
@@ -7,7 +7,7 @@ import { ADDRESS_GAP } from '#src/lib/constants.js'
 import { bytes, utf8 } from '#src/lib/convert.js'\r
 import { Entropy } from '#src/lib/entropy.js'\r
 import { Rpc } from '#src/lib/rpc.js'\r
-import { SafeWorker } from '#workers'\r
+import { Data, SafeWorker } from '#workers'\r
 \r
 export type KeyPair = {\r
        publicKey?: string,\r
@@ -161,12 +161,14 @@ export abstract class Wallet {
                                method: 'set',\r
                                name: this.id\r
                        }\r
-                       const data = {\r
+                       const data: Data = {\r
                                password: new Uint8Array(password).buffer,\r
                                id: new Uint8Array(this.#id.bytes).buffer,\r
-                               mnemonic: utf8.toBytes(this.#m?.phrase ?? '').buffer,\r
                                seed: this.#s.buffer\r
                        }\r
+                       if (this.#m != null) {\r
+                               data.mnemonic = utf8.toBytes(this.#m?.phrase ?? '').buffer\r
+                       }\r
                        const response = await SafeWorker.add(headers, data)\r
                        const success = response[0].result\r
                        if (!success) {\r