Skip to content

Commit 37e2142

Browse files
committed
Allow reading BITCOIN_EXE/ELECTRS_EXE env
1 parent e390c20 commit 37e2142

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,28 @@ mod test {
205205
};
206206
use electrum_client::ElectrumApi;
207207
use lazy_static::lazy_static;
208+
use std::env;
208209
use std::sync::{Mutex, Once};
209210
use std::time::Duration;
210211

211212
lazy_static! {
212213
static ref BITCOIND: BitcoinD = {
213-
let bitcoind_exe =
214-
bitcoind::downloaded_exe_path().expect("bitcoind version feature must be enabled");
214+
let bitcoind_exe = env::var("BITCOIND_EXE")
215+
.ok()
216+
.or(bitcoind::downloaded_exe_path().ok())
217+
.expect(
218+
"you should provide env var BITCOIND_EXE or specifiy a bitcoind version feature",
219+
);
215220
let conf = bitcoind::Conf::default();
216221
BitcoinD::with_conf(bitcoind_exe, &conf).unwrap()
217222
};
218223
static ref ELECTRSD: ElectrsD = {
219-
let electrs_exe =
220-
electrsd::downloaded_exe_path().expect("electrs version feature must be enabled");
224+
let electrs_exe = env::var("ELECTRS_EXE")
225+
.ok()
226+
.or(electrsd::downloaded_exe_path())
227+
.expect(
228+
"you should provide env var ELECTRS_EXE or specifiy a electrsd version feature",
229+
);
221230
let mut conf = electrsd::Conf::default();
222231
conf.http_enabled = true;
223232
ElectrsD::with_conf(electrs_exe, &BITCOIND, &conf).unwrap()

0 commit comments

Comments
 (0)