From: merge-script Date: Fri, 13 Nov 2026 19:24:42 +0000 (+0100) Subject: Merge bitcoindevkit/bdk-cli#367: fix(full_scan): reject `--scan-stop-gap` on rpc... X-Git-Url: http://internal-gitweb-vhost/-script/src/example_cli/scripts/-script-interface/constant.OP_GREATERTHANOREQUAL.html?a=commitdiff_plain;p=bdk-cli Merge bitcoindevkit/bdk-cli#367: fix(full_scan): reject `--scan-stop-gap` on rpc and cbf backends 12aae534965a678d7419e13dab8a235a3b751641 refactor(full_scan): share the stop-gap rejection check (emma31-dev) b6e54bf221f97a81167d33312f5305ebdca6a121 fix(full_scan): gate --scan-stop-gap to backends that use it (emma31-dev) Pull request description: ### Description `full_scan --scan-stop-gap` was accepted by every backend, but only Electrum and Esplora actually use it. RPC scans blocks through `Emitter` and CBF follows the wallet's filter lookahead, so for both backends the flag was silently ignored. This PR: - gates `--scan-stop-gap` to `electrum`/`esplora` builds at compile time, so RPC-only and CBF-only builds no longer advertise an option they cannot honour; - rejects the flag at runtime for RPC and CBF wallets in multi-backend builds, where the backend is chosen from the wallet config rather than from the build's feature set; - reads `STOP_GAP` in the handler instead of through clap, so a globally exported value no longer turns an RPC or CBF scan into an error when the flag was never passed, while supported backends keep the existing environment behaviour; - keeps the default of 20 in one place (`DEFAULT_STOP_GAP`) and documents it, together with the env var, in `--help`. Related to #340 . ### Notes to the reviewers - No behaviour change for Electrum and Esplora: same flag, same default of 20, same env var. - The RPC and CBF arms share one `reject_stop_gap` helper next to `stop_gap`, so the message and the feature gate live in a single place instead of being duplicated per arm. - The rejection happens before any network traffic, so the error is returned even when the node or server is unreachable. - This does not close the fund-discovery half of #340. RPC still only sees script pubkeys up to its lookahead (`bdk_chain` default: 25), and with the flag now gated there is no stop-gap knob at all in an RPC-only build. Fixing that needs a load-time lookahead (a persisted wallet option, default 25), since the wallet is constructed before the subcommand runs. I'd rather do that as a follow-up PR if there's agreement on the CLI surface. - Tests: a unit test asserts `--scan-stop-gap 42` parses to `Some(42)` when the Electrum or Esplora feature is on, and is rejected outright when neither is enabled. - Checked with `cargo clippy` and the test suite across the default build and`rpc`, `electrum`, `esplora`, `cbf`, `rpc,esplora,electrum`, and `rpc,esplora,electrum,cbf`. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [x] I've added tests for the new feature * [x] I've added docs for the new feature ACKs for top commit: tvpeter: ACK 12aae534965a678d7419e13dab8a235a3b751641 Tree-SHA512: 41c51b03febbe24b2a54f6335cfab1522dab1c87bd7d51999f63df61f6f19d02ddd584ac06a32de452474696ca3bd43075d65bb349940b03ca0ff6a46ac4a92e --- 546e73293f393807f833ae1050cd9e87c5ce1a90