Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrite relevant doc comments as `structopt` help document.
- Update `bdk` and `bdk-reserves` to v0.19.0.
- Change default database to `sqlite`.
- Change the `esplora-reqwest` feature to always use async mode

## [0.5.0]

Expand Down
177 changes: 177 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fd-lock = { version = "=3.0.2", optional = true }
regex = { version = "1", optional = true }
bdk-reserves = { version = "0.19", optional = true}
electrsd = { version= "0.12", features = ["trigger", "bitcoind_22_0"], optional = true}
tokio = { version = "1", features = ["rt", "macros", "rt-multi-thread"], optional = true }

[features]
default = ["repl", "sqlite-db"]
Expand All @@ -44,7 +45,8 @@ electrum = ["bdk/electrum"]
compact_filters = ["bdk/compact_filters"]
esplora = []
esplora-ureq = ["esplora", "bdk/use-esplora-ureq"]
esplora-reqwest = ["esplora", "bdk/use-esplora-reqwest"]
async-interface = ["bdk/async-interface", "tokio"]
esplora-reqwest = ["esplora", "bdk/use-esplora-reqwest", "bdk/reqwest-default-tls", "async-interface"]

# Use this to consensus verify transactions at sync time
verify = ["bdk/verify"]
Expand All @@ -65,4 +67,4 @@ regtest-node = []
regtest-bitcoin = ["regtest-node" , "rpc", "electrsd"]
regtest-electrum = ["regtest-node", "electrum", "electrsd/electrs_0_8_10"]
regtest-esplora-ureq = ["regtest-node", "esplora-ureq", "electrsd/esplora_a33e97e1"]
regtest-esplora-reqwest = ["regtest-node", "esplora-reqwest", "electrsd/esplora_a33e97e1"]
regtest-esplora-reqwest = ["regtest-node", "esplora-reqwest", "electrsd/esplora_a33e97e1"]
14 changes: 10 additions & 4 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ use bdk::{
bitcoin::{Address, OutPoint, TxOut},
blockchain::Capability,
};
use bdk_macros::maybe_async;
#[cfg(any(
feature = "electrum",
feature = "esplora",
feature = "compact_filters",
feature = "rpc"
))]
use bdk_macros::{maybe_async, maybe_await};
use bdk_macros::maybe_await;
#[cfg(feature = "reserves")]
use bdk_reserves::reserves::verify_proof;
#[cfg(feature = "reserves")]
Expand Down Expand Up @@ -556,6 +557,7 @@ pub fn get_outpoints_for_address(
.collect()
}

#[maybe_async]
pub fn handle_command(
cli_opts: CliOpts,
network: Network,
Expand All @@ -576,7 +578,11 @@ pub fn handle_command(
let database = open_database(&wallet_opts)?;
let blockchain = new_blockchain(network, &wallet_opts, &_backend)?;
let wallet = new_wallet(network, &wallet_opts, database)?;
let result = handle_online_wallet_subcommand(&wallet, &blockchain, online_subcommand)?;
let result = maybe_await!(handle_online_wallet_subcommand(
&wallet,
&blockchain,
online_subcommand
))?;
serde_json::to_string_pretty(&result)?
}
CliSubCommand::Wallet {
Expand Down Expand Up @@ -656,11 +662,11 @@ pub fn handle_command(
))]
ReplSubCommand::OnlineWalletSubCommand(online_subcommand) => {
let blockchain = new_blockchain(network, &wallet_opts, &_backend)?;
handle_online_wallet_subcommand(
maybe_await!(handle_online_wallet_subcommand(
&wallet,
&blockchain,
online_subcommand,
)
))
}
ReplSubCommand::OfflineWalletSubCommand(offline_subcommand) => {
handle_offline_wallet_subcommand(
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ use log::{debug, error, warn};
use crate::commands::CliOpts;
use crate::handlers::*;
use bdk::{bitcoin, Error};
use bdk_macros::{maybe_async, maybe_await};
use structopt::StructOpt;

#[cfg(feature = "repl")]
const REPL_LINE_SPLIT_REGEX: &str = r#""([^"]*)"|'([^']*)'|([\w\-]+)"#;

#[maybe_async]
#[cfg_attr(feature = "async-interface", tokio::main)]
fn main() {
env_logger::init();

Expand Down Expand Up @@ -96,7 +99,7 @@ fn main() {
#[cfg(not(feature = "regtest-node"))]
let backend = Nodes::None;

match handle_command(cli_opts, network, backend) {
match maybe_await!(handle_command(cli_opts, network, backend)) {
Ok(result) => println!("{}", result),
Err(e) => {
match e {
Expand Down