Skip to content

Commit

Permalink
fix: deserializer for SafePassword (#4565)
Browse files Browse the repository at this point in the history
Description
---
#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)
  • Loading branch information
agubarev authored Aug 30, 2022
1 parent a5d5133 commit ee89960
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base_layer/wallet/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<SafePassword>, D::Error>
where D: serde::Deserializer<'de> {
let password: Option<String> = Deserialize::deserialize(deserializer)?;
Ok(password.map(SafePassword::from))
}

#[derive(Clone, Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct WalletConfig {
Expand Down Expand Up @@ -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<SafePassword>,
/// The auto ping interval to use for contacts liveness data
#[serde(with = "serializers::seconds")]
Expand Down

0 comments on commit ee89960

Please sign in to comment.