]> Untitled Git - bdk-cli/commitdiff
feat(hwi): Add hwi feature to dispatch and routing
authorVihiga Tyonum <withtvpeter@gmail.com>
Mon, 3 Aug 2026 14:28:19 +0000 (15:28 +0100)
committerVihiga Tyonum <withtvpeter@gmail.com>
Mon, 19 Oct 2026 09:24:07 +0000 (10:24 +0100)
src/commands.rs
src/handlers/mod.rs
src/handlers/offline.rs
src/main.rs
src/utils/mod.rs

index d921e7ce1632a9ef9252ffd791f24e13535df524..e4f9dce460eb89a0dd437dbe241d79257c1c7008 100644 (file)
@@ -60,6 +60,9 @@ use crate::handlers::dns::{CreateDnsTxCommand, ResolveDnsRecipientCommand};
 #[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc"))]
 use crate::utils::parse_proxy_auth;
 
+#[cfg(feature = "hwi")]
+use crate::handlers::hwi::HwiCommand;
+
 /// The BDK Command Line Wallet App
 ///
 /// bdk-cli is a lightweight command line bitcoin wallet, powered by BDK.
@@ -207,6 +210,12 @@ pub enum CliSubCommand {
     /// Resolves BIP-353 DNS payment instructions for a human-readable name.
     #[cfg(feature = "dns_payment")]
     ResolveDnsRecipient(ResolveDnsRecipientCommand),
+    /// Hardware wallet (HWI) operations.
+    ///
+    /// List connected devices, register a wallet policy, display a receive
+    /// address for verification, or sign a PSBT with a hardware wallet.
+    #[cfg(feature = "hwi")]
+    Hwi(HwiCommand),
 }
 
 /// Wallet operation subcommands.
index 0dd871a08abb639f61ed1d7bef890664b4361f08..7d3d7f8cb3dda7dbffcc3be2a6d8ead0e95eb8b1 100644 (file)
@@ -2,6 +2,8 @@ pub mod config;
 pub mod descriptor;
 #[cfg(feature = "dns_payment")]
 pub mod dns;
+#[cfg(feature = "hwi")]
+pub mod hwi;
 pub mod key;
 pub mod offline;
 pub mod online;
@@ -13,9 +15,6 @@ pub mod online;
 ))]
 pub mod payjoin;
 pub mod repl;
-#[cfg(feature = "hwi")]
-pub mod hwi;
-
 
 #[cfg(any(
     feature = "electrum",
@@ -117,7 +116,8 @@ pub trait AppCommand<C> {
     feature = "esplora",
     feature = "rpc",
     feature = "cbf",
-    feature = "dns_payment"
+    feature = "dns_payment",
+    feature = "hwi"
 ))]
 pub trait AsyncAppCommand<C> {
     type Output: FormatOutput;
index 15cdd26b2cb97001434154df4e18a892fe6a8dc6..6f86ca3a7ee40a9ccda2340823ce770fe6d689bc 100644 (file)
@@ -35,6 +35,14 @@ use {
     bdk_message_signer::{MessageProof, MessageSigner},
 };
 
+/// When built with hardware wallet support, `create_tx` produces a
+/// PSBT that offline signers and hardware wallets can consume.
+#[cfg(feature = "hwi")]
+const DEFAULT_OFFLINE_SIGNER: bool = true;
+#[cfg(not(feature = "hwi"))]
+const DEFAULT_OFFLINE_SIGNER: bool = false;
+
+
 impl OfflineWalletSubCommand {
     pub fn execute(&self, ctx: &mut AppContext<OfflineOperations<'_>>) -> Result<(), Error> {
         match self {
@@ -543,7 +551,7 @@ pub struct BumpFeeCommand {
     pub shrink_address: Option<Address>,
 
     /// Make a PSBT that can be signed by offline signers and hardware wallets. Forces the addition of `non_witness_utxo` and more details to let the signer identify the change output.
-    #[arg(long = "offline_signer")]
+    #[arg(long = "offline_signer", default_value_t = DEFAULT_OFFLINE_SIGNER))]
     pub offline_signer: bool,
 
     /// Selects which utxos *must* be added to the tx. Unconfirmed utxos cannot be used.
index d13bf8a9ac1486dc13b4f2892cce456d566cd33b..b0b528d80b41ef2db8916a5012a4ecd1aed5af02 100644 (file)
@@ -23,7 +23,7 @@ use log::{debug, warn};
 
 use crate::commands::{CliOpts, CliSubCommand, WalletSubCommand};
 use crate::error::BDKCliError as Error;
-#[cfg(feature = "dns_payment")]
+#[cfg(any(feature = "dns_payment", feature = "hwi"))]
 use crate::handlers::AsyncAppCommand;
 use crate::handlers::{AppCommand, AppContext};
 use crate::utils::output::FormatOutput;
@@ -218,6 +218,11 @@ async fn run(cli_opts: CliOpts) -> Result<(), Error> {
             let mut ctx = AppContext::new(cli_opts.network, home_dir);
             cmd.execute(&mut ctx).await?.write_out(std::io::stdout())?;
         }
+        #[cfg(feature = "hwi")]
+        CliSubCommand::Hwi(cmd) => {
+            let mut ctx = AppContext::new(cli_opts.network, home_dir);
+            cmd.execute(&mut ctx).await?.write_out(std::io::stdout())?;
+        }
     }
 
     Ok(())
index 17a6dec5e7a326ff42f89dc9350afca1f16f149d..15138df5e7c033df626856181c53005e04e8543b 100644 (file)
@@ -2,7 +2,7 @@ pub mod common;
 pub mod descriptors;
 pub mod output;
 pub use common::*;
-pub mod runtime;
-pub mod types;
 #[cfg(feature = "hwi")]
 pub mod hwi;
+pub mod runtime;
+pub mod types;