config: redact RPC credentials in Config Debug impl.

This commit is contained in:
Antoine Poinsot 2023-12-21 14:27:36 +01:00
parent 21e064c50e
commit 5c3763526d
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304

View File

@ -1,6 +1,6 @@
use crate::descriptors::LianaDescriptor;
use std::{net::SocketAddr, path::PathBuf, str::FromStr, time::Duration};
use std::{fmt, net::SocketAddr, path::PathBuf, str::FromStr, time::Duration};
use miniscript::bitcoin::Network;
@ -86,7 +86,7 @@ fn default_daemon() -> bool {
}
/// RPC authentication options.
#[derive(Debug, Clone, PartialEq, Serialize)]
#[derive(Clone, PartialEq, Serialize)]
pub enum BitcoindRpcAuth {
/// Path to bitcoind's cookie file.
#[serde(rename = "cookie_path")]
@ -96,6 +96,15 @@ pub enum BitcoindRpcAuth {
UserPass(String, String),
}
impl fmt::Debug for BitcoindRpcAuth {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::CookieFile(path) => path.fmt(f),
Self::UserPass(_, _) => write!(f, "REDACTED RPC CREDENTIALS"),
}
}
}
/// Everything we need to know for talking to bitcoind serenely
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct BitcoindConfig {