]> Untitled Git - bdk-cli/commitdiff
Update with review comments
authorrajarshimaitra <rajarshi149@gmail.com>
Fri, 1 Jul 2022 11:24:52 +0000 (16:54 +0530)
committerrajarshimaitra <rajarshi149@gmail.com>
Fri, 1 Jul 2022 11:24:52 +0000 (16:54 +0530)
CHANGELOG.md
Cargo.toml
src/backend.rs [deleted file]
src/handlers.rs
src/main.rs
src/nodes.rs [new file with mode: 0644]
src/utils.rs

index 0fb4ff9b42b91e4930d527dc45caaffdd3f4cb77..41f1481c9d7ce6fcfe71f1a0baba62d351260490 100644 (file)
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ## [Unreleased]
 
 - Add distinct `key-value-db` and `sqlite-db` features, keep default as `key-value-db`
+- Reorganize existing codes in separate modules. Change crate type from lib to bin.
+- Rewrite relevant doc comments as `structopt` help document.
+- Update `bdk` and `bdk-reserves` to v0.19.0.
+- Change default database to `sqlite`.
 
 ## [0.5.0]
 
index 47e325a1bf0138b4108958547fb3ab8738ab7ab0..f9cc694403fd4fba986f3970cb8023df92418835 100644 (file)
@@ -34,11 +34,11 @@ default = ["repl", "sqlite-db"]
 # To use the app in a REPL mode
 repl = ["regex", "rustyline", "fd-lock"]
 
-# Avaialable dataabse options
+# Avaialable databse options
 key-value-db = ["bdk/key-value-db"]
 sqlite-db = ["bdk/sqlite"]
 
-# Avialable blockchain backend options
+# Avialable blockchain client options
 rpc = ["bdk/rpc"]
 electrum = ["bdk/electrum"]
 compact_filters = ["bdk/compact_filters"]
diff --git a/src/backend.rs b/src/backend.rs
deleted file mode 100644 (file)
index f965b43..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2020-2021 Bitcoin Dev Kit Developers
-//
-// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
-// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
-// You may not use this file except in accordance with one or both of these
-// licenses.
-
-//! The Backend
-//!
-//! This module defines the Backend struct and associated operations
-
-#[allow(dead_code)]
-// Different Backend types activated with `regtest-*` mode.
-// If `regtest-*` feature not activated, then default is `None`.
-pub enum Backend {
-    None,
-    Bitcoin { rpc_url: String, rpc_auth: String },
-    Electrum { electrum_url: String },
-    Esplora { esplora_url: String },
-}
index db69b04364c89329139eb51ff5336fec25302479..9e0ded0d24814914f9c9879678d85ac2fa3d2da1 100644 (file)
@@ -22,7 +22,7 @@ use crate::commands::OfflineWalletSubCommand::*;
 use crate::commands::OnlineWalletSubCommand::*;
 use crate::commands::*;
 use crate::utils::*;
-use crate::Backend;
+use crate::Nodes;
 use bdk::{database::BatchDatabase, wallet::AddressIndex, Error, FeeRate, KeychainKind, Wallet};
 
 use structopt::StructOpt;
@@ -559,7 +559,7 @@ pub fn get_outpoints_for_address(
 pub fn handle_command(
     cli_opts: CliOpts,
     network: Network,
-    _backend: Backend,
+    _backend: Nodes,
 ) -> Result<String, Error> {
     let result = match cli_opts.subcommand {
         #[cfg(any(
index 154b42a747762f59369fa35d459ed0b639ff3ffe..edb3e4df74941366de465597cc4c0bd9c5a4930a 100644 (file)
 //!
 //! This module describes the app's main() function
 
-mod backend;
 mod commands;
 mod handlers;
+mod nodes;
 mod utils;
 
-use backend::Backend;
+use nodes::Nodes;
 
 use bitcoin::Network;
 
@@ -53,7 +53,7 @@ fn main() {
 
     #[cfg(feature = "regtest-bitcoin")]
     let backend = {
-        Backend::Bitcoin {
+        Nodes::Bitcoin {
             rpc_url: bitcoind.params.rpc_socket.to_string(),
             rpc_auth: bitcoind
                 .params
@@ -71,7 +71,7 @@ fn main() {
         let elect_exe =
             electrsd::downloaded_exe_path().expect("We should always have downloaded path");
         let electrsd = electrsd::ElectrsD::with_conf(elect_exe, &bitcoind, &elect_conf).unwrap();
-        let backend = Backend::Electrum {
+        let backend = Nodes::Electrum {
             electrum_url: electrsd.electrum_url.clone(),
         };
         (electrsd, backend)
@@ -84,17 +84,17 @@ fn main() {
         let elect_exe =
             electrsd::downloaded_exe_path().expect("Electrsd downloaded binaries not found");
         let electrsd = electrsd::ElectrsD::with_conf(elect_exe, &bitcoind, &elect_conf).unwrap();
-        let backend = Backend::Esplora {
+        let backend = Nodes::Esplora {
             esplora_url: electrsd
                 .esplora_url
                 .clone()
                 .expect("Esplora port not open in electrum"),
         };
-        (electrsd, backend)
+        (electrsd, nodes)
     };
 
     #[cfg(not(feature = "regtest-node"))]
-    let backend = Backend::None;
+    let backend = Nodes::None;
 
     match handle_command(cli_opts, network, backend) {
         Ok(result) => println!("{}", result),
diff --git a/src/nodes.rs b/src/nodes.rs
new file mode 100644 (file)
index 0000000..f3873e8
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright (c) 2020-2021 Bitcoin Dev Kit Developers
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+//! The Node structures
+//!
+//! This module defines the the backend node structures for `regtest-*` features
+
+#[allow(dead_code)]
+// Different regtest node types activated with `regtest-*` mode.
+// If `regtest-*` feature not activated, then default is `None`.
+pub enum Nodes {
+    None,
+    Bitcoin { rpc_url: String, rpc_auth: String },
+    Electrum { electrum_url: String },
+    Esplora { esplora_url: String },
+}
index 46815b48fd3c1d0cc2ba7b63ac602dc2509a9940..a8fb8572dfbc1fd6d94a0302e7b364a24033120b 100644 (file)
 use std::path::PathBuf;
 use std::str::FromStr;
 
+use crate::commands::WalletOpts;
 #[cfg(any(
     feature = "electrum",
     feature = "esplora",
     feature = "compact_filters",
     feature = "rpc"
 ))]
-use crate::backend::Backend;
-use crate::commands::WalletOpts;
+use crate::nodes::Nodes;
 use bdk::bitcoin::secp256k1::Secp256k1;
 use bdk::bitcoin::{Address, Network, OutPoint, Script};
 #[cfg(feature = "compact_filters")]
@@ -199,12 +199,12 @@ pub(crate) fn open_database(wallet_opts: &WalletOpts) -> Result<AnyDatabase, Err
 pub(crate) fn new_blockchain(
     _network: Network,
     wallet_opts: &WalletOpts,
-    _backend: &Backend,
+    _backend: &Nodes,
 ) -> Result<AnyBlockchain, Error> {
     #[cfg(feature = "electrum")]
     let config = {
         let url = match _backend {
-            Backend::Electrum { electrum_url } => electrum_url.to_owned(),
+            Nodes::Electrum { electrum_url } => electrum_url.to_owned(),
             _ => wallet_opts.electrum_opts.server.clone(),
         };
 
@@ -254,7 +254,7 @@ pub(crate) fn new_blockchain(
     #[cfg(feature = "rpc")]
     let config: AnyBlockchainConfig = {
         let (url, auth) = match _backend {
-            Backend::Bitcoin { rpc_url, rpc_auth } => (
+            Nodes::Bitcoin { rpc_url, rpc_auth } => (
                 rpc_url,
                 Auth::Cookie {
                     file: rpc_auth.into(),