From ee899606e0b9c9877c89fa35add3dc2fe54be30f Mon Sep 17 00:00:00 2001 From: Andrei Gubarev <1062334+agubarev@users.noreply.github.com> Date: Tue, 30 Aug 2022 11:25:58 +0300 Subject: [PATCH] fix: deserializer for SafePassword (#4565) Description --- https://github.com/tari-project/tari/issues/4404 Motivation and Context --- console_wallet does not recognize password config setting, runtime error & exists #4404 How Has This Been Tested? --- manually (kudos to Stan) --- base_layer/wallet/src/config.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/base_layer/wallet/src/config.rs b/base_layer/wallet/src/config.rs index 8d13f1d328..9e13353a3e 100644 --- a/base_layer/wallet/src/config.rs +++ b/base_layer/wallet/src/config.rs @@ -45,6 +45,12 @@ use crate::{ pub const KEY_MANAGER_COMMS_SECRET_KEY_BRANCH_KEY: &str = "comms"; +fn deserialize_safe_password_option<'de, D>(deserializer: D) -> Result, D::Error> +where D: serde::Deserializer<'de> { + let password: Option = Deserialize::deserialize(deserializer)?; + Ok(password.map(SafePassword::from)) +} + #[derive(Clone, Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct WalletConfig { @@ -74,6 +80,7 @@ pub struct WalletConfig { /// The main wallet db sqlite database backend connection pool size for concurrent reads pub db_connection_pool_size: usize, /// The main wallet password + #[serde(deserialize_with = "deserialize_safe_password_option")] pub password: Option, /// The auto ping interval to use for contacts liveness data #[serde(with = "serializers::seconds")]