Skip to content

Commit fe2501a

Browse files
committed
Downgrade hot wallets with missing keys to watch-only instead of cold
Watch-only wallets can be upgraded back via xpub or seed word import, while cold wallets cannot. This makes recovery possible when a hot wallet loses its private key from the keychain.
1 parent c16128b commit fe2501a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

rust/src/manager/wallet_manager.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ impl Drop for RustWalletManager {
13511351
}
13521352

13531353
/// If a hot wallet's private key is missing from the keychain, downgrade it to
1354-
/// cold and queue a `HotWalletKeyMissing` notification so the UI can alert the user
1354+
/// watch-only and queue a `HotWalletKeyMissing` notification so the UI can alert the user
13551355
fn downgrade_and_notify_if_needed(
13561356
metadata: &mut WalletMetadata,
13571357
deferred: &mut DeferredSender<Message>,
@@ -1373,12 +1373,15 @@ fn downgrade_and_notify_if_needed(
13731373
return;
13741374
}
13751375

1376-
warn!("hot wallet {} is missing private key in keychain, downgrading to cold", metadata.id);
1377-
metadata.wallet_type = WalletType::Cold;
1376+
warn!(
1377+
"hot wallet {} is missing private key in keychain, downgrading to watch-only",
1378+
metadata.id
1379+
);
1380+
metadata.wallet_type = WalletType::WatchOnly;
13781381
metadata.hardware_metadata = None;
13791382

13801383
if let Err(error) = Database::global().wallets.update_wallet_metadata(metadata.clone()) {
1381-
error!("failed to persist cold-wallet downgrade for {}: {error}", metadata.id);
1384+
error!("failed to persist watch-only downgrade for {}: {error}", metadata.id);
13821385
}
13831386

13841387
deferred.queue(Message::HotWalletKeyMissing(metadata.id.clone()));

rust/src/wallet/metadata.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ pub enum WalletType {
132132
Hot,
133133
Cold,
134134
XpubOnly,
135-
136-
/// deprecated, use XpubOnly instead
137135
WatchOnly,
138136
}
139137

0 commit comments

Comments
 (0)