Skip to content
Open
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 @@ -16,6 +16,7 @@ page. See [DEVELOPMENT_CYCLE.md](DEVELOPMENT_CYCLE.md) for more details.
- Fixed `warn!` messages, including the mainnet notice, being hidden unless `RUST_LOG` was set; warnings are now shown by default
- Added `hwi` feature with a hardware wallet `hwi` command to list connected devices, register a wallet policy, display a receive address, and sign PSBTs. Supports Ledger, Coldcard, BitBox02, Jade and Specter.
- Replaced plain `wallets` with `wallets list`, and added `wallets delete <wallet_name>` for unused saved wallet configurations.
- Gated full-scan `stop_gap` to Electrum and Esplora, and made the Esplora parallel-request override optional
- Removed the redundant `wallet` field from `wallets list` output; the wallet name is still available as the top-level key
- Fixed `compile` silently accepting placeholder keys/hashes instead of validating them; added `--placeholders` to opt back into the old permissive behavior
- Fixed `compile` panicking instead of returning an error when a key is valid on its own but the wrong shape for the requested script type (e.g. an x-only key under `sh`/`wsh`/`sh-wsh`, or an uncompressed key under `tr`)
Expand Down
47 changes: 44 additions & 3 deletions src/handlers/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ impl OnlineWalletSubCommand {
#[derive(Parser, Debug, PartialEq, Clone, Eq)]
pub struct FullScanCommand {
/// Stop searching addresses for transactions after finding an unused gap of this length.
#[cfg(any(feature = "electrum", feature = "esplora"))]
#[arg(env = "STOP_GAP", long = "scan-stop-gap", default_value = "20")]
stop_gap: usize,
#[clap(long, default_value = "5")]
pub parallel_request: usize,

/// Override the Esplora wallet's configured parallel request count.
#[cfg(feature = "esplora")]
#[arg(long)]
pub parallel_request: Option<usize>,
}

#[cfg(any(
Expand Down Expand Up @@ -132,7 +136,11 @@ impl AsyncAppCommand<AppContext<OnlineOperations<'_>>> for FullScanCommand {
parallel_requests,
} => {
let update = client
.full_scan(request, self.stop_gap, *parallel_requests)
.full_scan(
request,
self.stop_gap,
self.parallel_request.unwrap_or(*parallel_requests),
)
.await
.map_err(|e| *e)?;
let events = wallet.apply_update_events(update)?;
Expand Down Expand Up @@ -196,6 +204,39 @@ impl AsyncAppCommand<AppContext<OnlineOperations<'_>>> for FullScanCommand {
}
}

#[cfg(test)]
mod tests {
use super::FullScanCommand;
use clap::Parser;

#[test]
fn stop_gap_is_gated_to_supported_backends() {
#[cfg(any(feature = "electrum", feature = "esplora"))]
{
let default = FullScanCommand::try_parse_from(["bdk-cli"]).unwrap();
assert_eq!(default.stop_gap, 20);
let custom =
FullScanCommand::try_parse_from(["bdk-cli", "--scan-stop-gap", "42"]).unwrap();
assert_eq!(custom.stop_gap, 42);
}

#[cfg(not(any(feature = "electrum", feature = "esplora")))]
assert!(FullScanCommand::try_parse_from(["bdk-cli", "--scan-stop-gap", "42"]).is_err());
}

#[cfg(feature = "esplora")]
#[test]
fn parallel_request_overrides_or_uses_wallet_config() {
let configured = 7;
let default = FullScanCommand::try_parse_from(["bdk-cli"]).unwrap();
assert_eq!(default.parallel_request.unwrap_or(configured), configured);

let custom =
FullScanCommand::try_parse_from(["bdk-cli", "--parallel-request", "2"]).unwrap();
assert_eq!(custom.parallel_request.unwrap_or(configured), 2);
}
}

#[derive(Parser, Debug, PartialEq, Eq, Clone)]
pub struct SyncCommand;

Expand Down