From: Chris Duncan Date: Mon, 4 Aug 2025 13:49:20 +0000 (-0700) Subject: Validate mnemonic import to wallet more strictly. Update import paths. X-Git-Tag: v0.10.5~46^2~20 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=bd70962795f7fd486d7b7478b1855b796dbafdc5;p=libnemo.git Validate mnemonic import to wallet more strictly. Update import paths. --- diff --git a/src/lib/wallet.ts b/src/lib/wallet.ts index e50dacc..15d631c 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet.ts @@ -1,14 +1,15 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { Account, AccountList } from '#src/lib/account.js' -import { ChangeBlock, ReceiveBlock, SendBlock } from '#src/lib/block.js' -import { ADDRESS_GAP } from '#src/lib/constants.js' -import { bytes, hex, utf8 } from '#src/lib/convert.js' -import { Database } from '#src/lib/database.js' -import { Rpc } from '#src/lib/rpc.js' -import { default as SafeWorker } from '#src/lib/safe.js' -import { WorkerQueue } from '#src/lib/worker-queue.js' +import { Account, AccountList } from './account' +import { ChangeBlock, ReceiveBlock, SendBlock } from './block' +import { Bip39Mnemonic } from './bip39-mnemonic' +import { ADDRESS_GAP } from './constants' +import { bytes, hex, utf8 } from './convert' +import { Database } from './database' +import { Rpc } from './rpc' +import { default as SafeWorker } from './safe' +import { WorkerQueue } from './worker-queue' import { KeyPair, NamedData, WalletType } from '#types' /** @@ -111,7 +112,7 @@ export class Wallet { } if (/^(?:[A-F0-9]{64}){1,2}$/i.test(secret)) { data.seed = hex.toBuffer(secret) - } else if (/^([a-z]{3,8} ){11,23}[a-z]{3,8}$/i.test(secret)) { + } else if (await Bip39Mnemonic.validate(secret)) { data.mnemonicPhrase = secret.toLowerCase() if (mnemonicSalt != null) data.mnemonicSalt = mnemonicSalt } else {