]> git.codecow.com Git - libnemo.git/commitdiff
Handle BIP-44 errors and remove keys that failed.
authorChris Duncan <chris@zoso.dev>
Fri, 4 Jul 2025 00:45:36 +0000 (17:45 -0700)
committerChris Duncan <chris@zoso.dev>
Fri, 4 Jul 2025 00:45:36 +0000 (17:45 -0700)
src/lib/wallets/bip44-wallet.ts
src/lib/workers/bip44-ckd.ts

index dcbf72b9b9f140584dc28d2a738c909a6f4bbc79..9df7fc65795fba2aeedb426dac25e24ea565685d 100644 (file)
@@ -204,6 +204,11 @@ export class Bip44Wallet extends Wallet {
                const data: any = []\r
                indexes.forEach(i => data.push({ seed: this.seed, index: i }))\r
                const privateKeys: KeyPair[] = await this.#poolBip44Ckd.assign(data)\r
+               for (let i = 0; i < privateKeys.length; i++) {\r
+                       if (privateKeys[i].privateKey == null) {\r
+                               privateKeys.splice(i, 1)\r
+                       }\r
+               }\r
                return privateKeys\r
        }\r
 }\r
index cf2acbe92d8cd41da19449ee4fe4a87b43962bd0..47287e0dda190af7b7c34ffac6d2b5fbe9968910 100644 (file)
@@ -19,10 +19,14 @@ export class Bip44Ckd extends WorkerInterface {
 
        static async work (data: any[]): Promise<any[]> {
                for (const d of data) {
-                       if (d.coin != null && d.coin !== this.BIP44_PURPOSE) {
-                               d.privateKey = await this.ckd(d.seed, d.coin, d.index)
-                       } else {
-                               d.privateKey = await this.nanoCKD(d.seed, d.index)
+                       try {
+                               if (d.coin != null && d.coin !== this.BIP44_PURPOSE) {
+                                       d.privateKey = await this.ckd(d.seed, d.coin, d.index)
+                               } else {
+                                       d.privateKey = await this.nanoCKD(d.seed, d.index)
+                               }
+                       } catch (err) {
+                               d.privateKey = null
                        }
                }
                return data