From: Chris Duncan Date: Tue, 15 Jul 2025 20:58:36 +0000 (-0700) Subject: Fix issue with restoring from new wallet ID format with prefix. X-Git-Tag: v0.10.5~57^2~8 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=df88826f46808c6a1c8df1f40af9be1245300db9;p=libnemo.git Fix issue with restoring from new wallet ID format with prefix. --- diff --git a/src/lib/wallets/bip44-wallet.ts b/src/lib/wallets/bip44-wallet.ts index 69a2316..f6fb518 100644 --- a/src/lib/wallets/bip44-wallet.ts +++ b/src/lib/wallets/bip44-wallet.ts @@ -201,6 +201,7 @@ export class Bip44Wallet extends Wallet { throw new TypeError('Wallet ID is required to restore') } Bip44Wallet.#isInternal = true + id = id.replace('libnemo_', '') return new this(await Entropy.import(id), '') } diff --git a/src/lib/wallets/blake2b-wallet.ts b/src/lib/wallets/blake2b-wallet.ts index 178d474..505e418 100644 --- a/src/lib/wallets/blake2b-wallet.ts +++ b/src/lib/wallets/blake2b-wallet.ts @@ -150,6 +150,7 @@ export class Blake2bWallet extends Wallet { throw new TypeError('Wallet ID is required to restore') } Blake2bWallet.#isInternal = true + id = id.replace('libnemo_', '') return new this(await Entropy.import(id)) } diff --git a/src/lib/wallets/ledger-wallet.ts b/src/lib/wallets/ledger-wallet.ts index feb0545..ec9cf03 100644 --- a/src/lib/wallets/ledger-wallet.ts +++ b/src/lib/wallets/ledger-wallet.ts @@ -210,6 +210,7 @@ export class LedgerWallet extends Wallet { throw new TypeError('Wallet ID is required to restore') } LedgerWallet.#isInternal = true + id = id.replace('libnemo_', '') const wallet = new this(await Entropy.import(id)) await wallet.init() return wallet diff --git a/test/test.import-wallet.mjs b/test/test.import-wallet.mjs index f0be098..df2423e 100644 --- a/test/test.import-wallet.mjs +++ b/test/test.import-wallet.mjs @@ -236,6 +236,7 @@ await suite('Retrieve wallets from session storage using a wallet-generated ID', await test('Bip44Wallet', async () => { const id = (await Bip44Wallet.fromMnemonic(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.MNEMONIC, NANO_TEST_VECTORS.PASSWORD)).id + debugger const wallet = await Bip44Wallet.restore(id) assert.ok('mnemonic' in wallet)