diff --git a/ironfish/src/rpc/routes/wallet/importAccount.test.ts b/ironfish/src/rpc/routes/wallet/importAccount.test.ts index cc956f7869..642f78b6aa 100644 --- a/ironfish/src/rpc/routes/wallet/importAccount.test.ts +++ b/ironfish/src/rpc/routes/wallet/importAccount.test.ts @@ -390,13 +390,14 @@ describe('Route wallet/importAccount', () => { name: testCaseFile, }) + const name = 'new-account-name' const response = await routeTest.client.wallet.importAccount({ account: testCase, - name: testCaseFile, + name, }) expect(response.status).toBe(200) - expect(response.content.name).not.toBeNull() + expect(response.content.name).toEqual(name) } }) }) diff --git a/ironfish/src/rpc/routes/wallet/importAccount.ts b/ironfish/src/rpc/routes/wallet/importAccount.ts index 9972336561..4d5b4c72ee 100644 --- a/ironfish/src/rpc/routes/wallet/importAccount.ts +++ b/ironfish/src/rpc/routes/wallet/importAccount.ts @@ -57,6 +57,7 @@ routes.register( accountImport = await tryDecodeAccountWithMultisigSecrets( context.wallet, request.data.account, + { name }, ) } diff --git a/ironfish/src/rpc/routes/wallet/utils.ts b/ironfish/src/rpc/routes/wallet/utils.ts index f850eb25a0..fca6022e1b 100644 --- a/ironfish/src/rpc/routes/wallet/utils.ts +++ b/ironfish/src/rpc/routes/wallet/utils.ts @@ -284,12 +284,13 @@ export async function serializeRpcAccountStatus( export async function tryDecodeAccountWithMultisigSecrets( wallet: Wallet, value: string, + options?: { name?: string }, ): Promise { const encoder = new Base64JsonEncoder() for await (const { name, secret } of wallet.walletDb.getMultisigSecrets()) { try { - return encoder.decode(value, { name, multisigSecret: secret }) + return encoder.decode(value, { name: options?.name ?? name, multisigSecret: secret }) } catch (e: unknown) { continue } diff --git a/ironfish/src/wallet/wallet.ts b/ironfish/src/wallet/wallet.ts index 9fb9a1e2cb..ab77eaf905 100644 --- a/ironfish/src/wallet/wallet.ts +++ b/ironfish/src/wallet/wallet.ts @@ -1526,7 +1526,7 @@ export class Wallet { async importAccount(accountValue: AccountImport): Promise { let multisigKeys = accountValue.multisigKeys - let name = accountValue.name + const name = accountValue.name if ( accountValue.multisigKeys && @@ -1539,7 +1539,6 @@ export class Wallet { throw new Error('Cannot import identity without a corresponding multisig secret') } - name = multisigSecret.name multisigKeys = { keyPackage: accountValue.multisigKeys.keyPackage, publicKeyPackage: accountValue.multisigKeys.publicKeyPackage,