Fix the REPL example to have optional esplora
This commit is contained in:
parent
7d7b78534a
commit
c9a05c0deb
@ -35,6 +35,7 @@ use rustyline::Editor;
|
|||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
use bdk::bitcoin;
|
use bdk::bitcoin;
|
||||||
|
#[cfg(feature = "esplora")]
|
||||||
use bdk::blockchain::esplora::EsploraBlockchainConfig;
|
use bdk::blockchain::esplora::EsploraBlockchainConfig;
|
||||||
use bdk::blockchain::{
|
use bdk::blockchain::{
|
||||||
AnyBlockchain, AnyBlockchainConfig, ConfigurableBlockchain, ElectrumBlockchainConfig,
|
AnyBlockchain, AnyBlockchainConfig, ConfigurableBlockchain, ElectrumBlockchainConfig,
|
||||||
@ -87,18 +88,28 @@ fn main() {
|
|||||||
let tree = database.open_tree(cli_opt.wallet).unwrap();
|
let tree = database.open_tree(cli_opt.wallet).unwrap();
|
||||||
debug!("database opened successfully");
|
debug!("database opened successfully");
|
||||||
|
|
||||||
let config = match cli_opt.esplora {
|
// Try to use Esplora config if "esplora" feature is enabled
|
||||||
Some(base_url) => AnyBlockchainConfig::Esplora(EsploraBlockchainConfig {
|
#[cfg(feature = "esplora")]
|
||||||
|
let config_esplora: Option<AnyBlockchainConfig> = {
|
||||||
|
let esplora_concurrency = cli_opt.esplora_concurrency;
|
||||||
|
cli_opt.esplora.map(|base_url| {
|
||||||
|
AnyBlockchainConfig::Esplora(EsploraBlockchainConfig {
|
||||||
base_url: base_url.to_string(),
|
base_url: base_url.to_string(),
|
||||||
concurrency: Some(cli_opt.esplora_concurrency),
|
concurrency: Some(esplora_concurrency),
|
||||||
}),
|
})
|
||||||
None => AnyBlockchainConfig::Electrum(ElectrumBlockchainConfig {
|
})
|
||||||
|
};
|
||||||
|
#[cfg(not(feature = "esplora"))]
|
||||||
|
let config_esplora = None;
|
||||||
|
|
||||||
|
// Fall back to Electrum config if Esplora config isn't provided
|
||||||
|
let config =
|
||||||
|
config_esplora.unwrap_or(AnyBlockchainConfig::Electrum(ElectrumBlockchainConfig {
|
||||||
url: cli_opt.electrum,
|
url: cli_opt.electrum,
|
||||||
socks5: cli_opt.proxy,
|
socks5: cli_opt.proxy,
|
||||||
retry: 10,
|
retry: 10,
|
||||||
timeout: 10,
|
timeout: 10,
|
||||||
}),
|
}));
|
||||||
};
|
|
||||||
|
|
||||||
let wallet = Wallet::new(
|
let wallet = Wallet::new(
|
||||||
descriptor,
|
descriptor,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user