Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deserializer for SafePassword #4565

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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