Function Signature

recoverEncryptedBackupByWallet(params: {
  accountAddress: string;
  password: string;
  walletOperation: WalletOperation;
  shareCount?: number;
  storeRecoveredShares?: boolean;
}): Promise<any[]>

Description

Recovers encrypted backup for a wallet using the provided password and session. This function can optionally store the recovered shares and specify the number of shares to recover.

Parameters

Required Parameters

  • accountAddress (string) - The wallet address to recover backup for (must include 0x prefix)
  • password (string) - Password for decrypting the backup
  • walletOperation (WalletOperation) - The wallet operation for recovery

Optional Parameters

  • shareCount (number) - Number of shares to recover (defaults to 1)
  • storeRecoveredShares (boolean) - Whether to store recovered shares (defaults to false)

Returns

  • Promise<any[]> - Array of recovered shares

Example

import { authenticatedEvmClient } from './client';
import { WalletOperation } from '@dynamic-labs-wallet/node';

const evmClient = await authenticatedEvmClient();

const recoveredShares = await evmClient.recoverEncryptedBackupByWallet({
  accountAddress: '0xYourWalletAddress',
  password: 'your-backup-password',
  walletOperation: WalletOperation.SIGN_MESSAGE,
  shareCount: 1,
  storeRecoveredShares: true,
});

console.log('Recovered shares count:', recoveredShares.length);

Available Wallet Operations

  • SIGN_MESSAGE - Message signing operations
  • SIGN_TRANSACTION - Transaction signing operations
  • EXPORT_PRIVATE_KEY - Private key export operations

Error Handling

try {
  const recoveredShares = await evmClient.recoverEncryptedBackupByWallet({
    accountAddress: '0xYourWalletAddress',
    password: 'your-backup-password',
    walletOperation: WalletOperation.SIGN_MESSAGE,
  });
  console.log('Encrypted backup recovered successfully');
} catch (error) {
  console.error('Failed to recover encrypted backup:', error);
}