Skip to content

Commit 430f1eb

Browse files
committed
Use local_config when running local bitcoind node
1 parent 38d1a6e commit 430f1eb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/bitcoin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl BitcoinNode {
138138
}
139139

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

144144
info!(

src/config/bitcoin.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ impl BitcoinConfig {
4646
"-regtest".to_string(),
4747
format!("-datadir={}", self.data_dir.display()),
4848
format!("-port={}", self.p2p_port),
49-
format!("-bind=0.0.0.0:{}", self.p2p_port),
5049
format!("-rpcport={}", self.rpc_port),
51-
format!("-bind=0.0.0.0:{}", self.rpc_port),
5250
format!("-rpcuser={}", self.rpc_user),
5351
format!("-rpcpassword={}", self.rpc_password),
5452
"-server".to_string(),
@@ -68,6 +66,19 @@ impl BitcoinConfig {
6866
]
6967
.concat()
7068
}
69+
70+
/// Args to use whe running local bitcoind node
71+
/// This prevents odd port conflict when assigning rpc/p2p ports
72+
pub fn local_args(&self) -> Vec<String> {
73+
[
74+
self.base_args(),
75+
vec![
76+
format!("-bind=0.0.0.0:{}", self.p2p_port),
77+
format!("-bind=0.0.0.0:{}", self.rpc_port),
78+
],
79+
]
80+
.concat()
81+
}
7182
}
7283

7384
impl LogPathProvider for BitcoinConfig {

0 commit comments

Comments
 (0)