Skip to content

Commit

Permalink
Scrub bitcoin authentication from logged config
Browse files Browse the repository at this point in the history
  • Loading branch information
shesek committed Jan 6, 2021
1 parent e9b7511 commit c31def7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion contrib/nodejs-bwt-daemon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function start_bwt(options, progress_cb, done) {
, progress_cb_ffi = ffi.Callback('void', [ 'string', 'float', 'uint32', 'string' ], progress_cb)
, shutdown_ptrptr = ref.alloc(shutdownPtrPtr)

debug('starting with %O', options);
debug('starting with %O', { ...options, bitcoind_auth: '**SCRUBBED**' });
libbwt.bwt_start.async(opt_json, progress_cb_ffi, shutdown_ptrptr, function(err, code) {
if (err) return done(err)
if (code != OK) return done(new Error(`bwt failed with code ${code}`))
Expand Down
22 changes: 15 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct App {

impl App {
pub fn boot(config: Config, progress_tx: Option<mpsc::Sender<Progress>>) -> Result<Self> {
debug!("{:?}", config);
debug!("{}", scrub_config(&config));

let watcher = WalletWatcher::from_config(&config)?;

Expand Down Expand Up @@ -166,12 +166,6 @@ impl App {
Some(self.http.as_ref()?.addr())
}

pub fn test_rpc(config: &Config) -> Result<()> {
let rpc = RpcClient::new(config.bitcoind_url(), config.bitcoind_auth()?)?;
rpc.get_wallet_info()?;
Ok(())
}

// Pipe the shutdown receiver `rx` to trigger `sync_tx`. This is needed to start the next
// sync loop run immediately, which will then process the shutdown signal itself. Without
// this, the shutdown signal will only be noticed after a delay.
Expand Down Expand Up @@ -209,6 +203,12 @@ impl App {
fn default_shutdown_signal(&self) -> Option<mpsc::Receiver<()>> {
None
}

pub fn test_rpc(config: &Config) -> Result<()> {
let rpc = RpcClient::new(config.bitcoind_url(), config.bitcoind_auth()?)?;
rpc.get_wallet_info()?;
Ok(())
}
}

// Load the specified wallet, ignore "wallet is already loaded" errors
Expand Down Expand Up @@ -243,3 +243,11 @@ fn wait_bitcoind(rpc: &RpcClient, progress_tx: Option<mpsc::Sender<Progress>>) -

Ok(())
}

fn scrub_config(config: &Config) -> String {
let mut s = format!("{:?}", config);
if let Some(auth) = config.bitcoind_auth.as_deref() {
s = s.replace(auth, "**SCRUBBED**")
}
s
}

0 comments on commit c31def7

Please sign in to comment.