From 46971823d7300b5ff4f5be48a7f34b61d70ce059 Mon Sep 17 00:00:00 2001 From: Boris Oncev Date: Thu, 4 Jan 2024 14:46:54 +0100 Subject: [PATCH] make wallet migration recursive --- wallet/src/wallet/mod.rs | 7 ++----- wallet/wallet-controller/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/wallet/src/wallet/mod.rs b/wallet/src/wallet/mod.rs index 5fdd4631a9..3377efb376 100644 --- a/wallet/src/wallet/mod.rs +++ b/wallet/src/wallet/mod.rs @@ -367,12 +367,9 @@ impl Wallet { WALLET_VERSION_UNINITIALIZED => return Err(WalletError::WalletNotInitialized), WALLET_VERSION_V1 => { Self::migration_v2(db, chain_config.clone())?; - Self::migration_v3(db, chain_config)?; - Self::migration_v4(db)?; } WALLET_VERSION_V2 => { - Self::migration_v3(db, chain_config)?; - Self::migration_v4(db)?; + Self::migration_v3(db, chain_config.clone())?; } WALLET_VERSION_V3 => { Self::migration_v4(db)?; @@ -383,7 +380,7 @@ impl Wallet { } } - Ok(()) + Self::check_and_migrate_db(db, chain_config) } fn validate_chain_info( diff --git a/wallet/wallet-controller/src/lib.rs b/wallet/wallet-controller/src/lib.rs index 3dfb1e1004..c0e49ec625 100644 --- a/wallet/wallet-controller/src/lib.rs +++ b/wallet/wallet-controller/src/lib.rs @@ -348,11 +348,11 @@ impl Controll self.wallet.lock_wallet().map_err(ControllerError::WalletError) } - /// Locks the wallet by making the encrypted private keys inaccessible. + /// Sets the lookahead size for key generation /// /// # Returns /// - /// This method returns an error if the wallet is not encrypted. + /// This method returns an error if you try to set lookahead size to 0 pub fn set_lookahead_size(&mut self, lookahead_size: u32) -> Result<(), ControllerError> { utils::ensure!(lookahead_size > 0, ControllerError::InvalidLookaheadSize);