Skip to content

Commit 073f1c3

Browse files
Update with review comments
1 parent 4e8f830 commit 073f1c3

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88

99
- Add distinct `key-value-db` and `sqlite-db` features, keep default as `key-value-db`
10+
- Reorganize existing codes in separate modules. Change crate type from lib to bin.
11+
- Rewrite relevant doc comments as `structopt` help document.
12+
- Update `bdk` and `bdk-reserves` to v0.19.0.
13+
- Change default database to `sqlite`.
1014

1115
## [0.5.0]
1216

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ default = ["repl", "sqlite-db"]
3434
# To use the app in a REPL mode
3535
repl = ["regex", "rustyline", "fd-lock"]
3636

37-
# Avaialable dataabse options
37+
# Avaialable databse options
3838
key-value-db = ["bdk/key-value-db"]
3939
sqlite-db = ["bdk/sqlite"]
4040

41-
# Avialable blockchain backend options
41+
# Avialable blockchain client options
4242
rpc = ["bdk/rpc"]
4343
electrum = ["bdk/electrum"]
4444
compact_filters = ["bdk/compact_filters"]

src/handlers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::commands::OfflineWalletSubCommand::*;
2222
use crate::commands::OnlineWalletSubCommand::*;
2323
use crate::commands::*;
2424
use crate::utils::*;
25-
use crate::Backend;
25+
use crate::Nodes;
2626
use bdk::{database::BatchDatabase, wallet::AddressIndex, Error, FeeRate, KeychainKind, Wallet};
2727

2828
use structopt::StructOpt;
@@ -559,7 +559,7 @@ pub fn get_outpoints_for_address(
559559
pub fn handle_command(
560560
cli_opts: CliOpts,
561561
network: Network,
562-
_backend: Backend,
562+
_backend: Nodes,
563563
) -> Result<String, Error> {
564564
let result = match cli_opts.subcommand {
565565
#[cfg(any(

src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
//!
1111
//! This module describes the app's main() function
1212
13-
mod backend;
1413
mod commands;
1514
mod handlers;
15+
mod nodes;
1616
mod utils;
1717

18-
use backend::Backend;
18+
use nodes::Nodes;
1919

2020
use bitcoin::Network;
2121

@@ -53,7 +53,7 @@ fn main() {
5353

5454
#[cfg(feature = "regtest-bitcoin")]
5555
let backend = {
56-
Backend::Bitcoin {
56+
Nodes::Bitcoin {
5757
rpc_url: bitcoind.params.rpc_socket.to_string(),
5858
rpc_auth: bitcoind
5959
.params
@@ -71,7 +71,7 @@ fn main() {
7171
let elect_exe =
7272
electrsd::downloaded_exe_path().expect("We should always have downloaded path");
7373
let electrsd = electrsd::ElectrsD::with_conf(elect_exe, &bitcoind, &elect_conf).unwrap();
74-
let backend = Backend::Electrum {
74+
let backend = Nodes::Electrum {
7575
electrum_url: electrsd.electrum_url.clone(),
7676
};
7777
(electrsd, backend)
@@ -84,17 +84,17 @@ fn main() {
8484
let elect_exe =
8585
electrsd::downloaded_exe_path().expect("Electrsd downloaded binaries not found");
8686
let electrsd = electrsd::ElectrsD::with_conf(elect_exe, &bitcoind, &elect_conf).unwrap();
87-
let backend = Backend::Esplora {
87+
let backend = Nodes::Esplora {
8888
esplora_url: electrsd
8989
.esplora_url
9090
.clone()
9191
.expect("Esplora port not open in electrum"),
9292
};
93-
(electrsd, backend)
93+
(electrsd, nodes)
9494
};
9595

9696
#[cfg(not(feature = "regtest-node"))]
97-
let backend = Backend::None;
97+
let backend = Nodes::None;
9898

9999
match handle_command(cli_opts, network, backend) {
100100
Ok(result) => println!("{}", result),

src/backend.rs renamed to src/nodes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
// You may not use this file except in accordance with one or both of these
77
// licenses.
88

9-
//! The Backend
9+
//! The Node structures
1010
//!
11-
//! This module defines the Backend struct and associated operations
11+
//! This module defines the the backend node structures for `regtest-*` features
1212
1313
#[allow(dead_code)]
14-
// Different Backend types activated with `regtest-*` mode.
14+
// Different regtest node types activated with `regtest-*` mode.
1515
// If `regtest-*` feature not activated, then default is `None`.
16-
pub enum Backend {
16+
pub enum Nodes {
1717
None,
1818
Bitcoin { rpc_url: String, rpc_auth: String },
1919
Electrum { electrum_url: String },

src/utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
use std::path::PathBuf;
1414
use std::str::FromStr;
1515

16+
use crate::commands::WalletOpts;
1617
#[cfg(any(
1718
feature = "electrum",
1819
feature = "esplora",
1920
feature = "compact_filters",
2021
feature = "rpc"
2122
))]
22-
use crate::backend::Backend;
23-
use crate::commands::WalletOpts;
23+
use crate::nodes::Nodes;
2424
use bdk::bitcoin::secp256k1::Secp256k1;
2525
use bdk::bitcoin::{Address, Network, OutPoint, Script};
2626
#[cfg(feature = "compact_filters")]
@@ -199,12 +199,12 @@ pub(crate) fn open_database(wallet_opts: &WalletOpts) -> Result<AnyDatabase, Err
199199
pub(crate) fn new_blockchain(
200200
_network: Network,
201201
wallet_opts: &WalletOpts,
202-
_backend: &Backend,
202+
_backend: &Nodes,
203203
) -> Result<AnyBlockchain, Error> {
204204
#[cfg(feature = "electrum")]
205205
let config = {
206206
let url = match _backend {
207-
Backend::Electrum { electrum_url } => electrum_url.to_owned(),
207+
Nodes::Electrum { electrum_url } => electrum_url.to_owned(),
208208
_ => wallet_opts.electrum_opts.server.clone(),
209209
};
210210

@@ -254,7 +254,7 @@ pub(crate) fn new_blockchain(
254254
#[cfg(feature = "rpc")]
255255
let config: AnyBlockchainConfig = {
256256
let (url, auth) = match _backend {
257-
Backend::Bitcoin { rpc_url, rpc_auth } => (
257+
Nodes::Bitcoin { rpc_url, rpc_auth } => (
258258
rpc_url,
259259
Auth::Cookie {
260260
file: rpc_auth.into(),

0 commit comments

Comments
 (0)