Skip to content

Commit

Permalink
Use local_config when running local bitcoind node
Browse files Browse the repository at this point in the history
  • Loading branch information
jfldde committed Jan 31, 2025
1 parent 38d1a6e commit 430f1eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl BitcoinNode {
}

fn spawn(config: &BitcoinConfig) -> Result<SpawnOutput> {
let args = config.args();
let args = config.local_args();
debug!("Running bitcoind with args : {args:?}");

info!(
Expand Down
15 changes: 13 additions & 2 deletions src/config/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ impl BitcoinConfig {
"-regtest".to_string(),
format!("-datadir={}", self.data_dir.display()),
format!("-port={}", self.p2p_port),
format!("-bind=0.0.0.0:{}", self.p2p_port),
format!("-rpcport={}", self.rpc_port),
format!("-bind=0.0.0.0:{}", self.rpc_port),
format!("-rpcuser={}", self.rpc_user),
format!("-rpcpassword={}", self.rpc_password),
"-server".to_string(),
Expand All @@ -68,6 +66,19 @@ impl BitcoinConfig {
]
.concat()
}

/// Args to use whe running local bitcoind node
/// This prevents odd port conflict when assigning rpc/p2p ports
pub fn local_args(&self) -> Vec<String> {
[
self.base_args(),
vec![
format!("-bind=0.0.0.0:{}", self.p2p_port),
format!("-bind=0.0.0.0:{}", self.rpc_port),
],
]
.concat()
}
}

impl LogPathProvider for BitcoinConfig {
Expand Down

0 comments on commit 430f1eb

Please sign in to comment.