From c290ab974406c5c7d787e2220bcc7d8ea11909a6 Mon Sep 17 00:00:00 2001 From: Philip Robinson Date: Thu, 24 Mar 2022 07:41:48 +0000 Subject: [PATCH] fix: fix Tor ID deserialization issue (#3950) Description --- Due to an issue with excluding the private key from the TorIdentity serialization that was fixed in https://github.com/tari-project/tari/pull/3946 any console wallets that ran the old code would crash on startup with a serialization error. This PR adds some resilience to the startup process that if it cannot deserialize the old Tor Id it will log the issue and then use a newly generated one. How Has This Been Tested? --- Manually --- .../tari_console_wallet/src/init/mod.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/applications/tari_console_wallet/src/init/mod.rs b/applications/tari_console_wallet/src/init/mod.rs index 650e3cf271..e7b2fd5fed 100644 --- a/applications/tari_console_wallet/src/init/mod.rs +++ b/applications/tari_console_wallet/src/init/mod.rs @@ -365,10 +365,19 @@ pub async fn init_wallet( } let transport_type = create_transport_type(config); - let transport_type = match transport_type { - Tor(mut tor_config) => { - tor_config.identity = wallet_db.get_tor_id().await?.map(Box::new); - Tor(tor_config) + let transport_type = match transport_type.clone() { + Tor(mut tor_config) => match wallet_db.get_tor_id().await { + Ok(identity) => { + tor_config.identity = identity.map(Box::new); + Tor(tor_config) + }, + Err(e) => { + warn!( + target: LOG_TARGET, + "Error reading stored Tor Identity, using default: {}", e + ); + transport_type + }, }, _ => transport_type, };