Repository navigation
Description
Describe the bug
create_tx accepts a recipient address belonging to a different network than the wallet, with no warning. The address is parsed as Address<NetworkUnchecked> and converted straight to ScriptBuf via .script_pubkey(), discarding the network information before the wallet's network is known, so bdk-cli never compares the two.
This is a silent-misdirection safety issue rather than an unspendable-transaction bug: consensus validates the output scriptPubKey, not the address HRP, so a regtest node will accept a transaction paying to the witness program behind a tb1 address. Also, rust-bitcoin treats testnet, testnet4, and signet as a single network for address checks, so only mainnet/regtest (and similar) boundaries are genuinely invalid.
To Reproduce
- Set up a regtest wallet:
bdk-cli --network regtest --datadir ./dd wallet --wallet regtest_user1 config \ --ext-descriptor "<external descriptor>" \ --int-descriptor "<internal descriptor>" \ --client-type rpc --database-type sqlite --url http://127.0.0.1:18443 - Attempt to send to a testnet address:
bdk-cli --network regtest --datadir ./dd wallet --wallet regtest_user1 \ create_tx --to tb1q...:1000 - Observe: the command succeeds and returns a PSBT, with no warning about the network mismatch. (The PSBT is still broadcastable; the node does not reject it.)
Expected behavior
create_tx should reject the recipient at construction time with a specific error naming the mismatch, rather than silently building a PSBT that pays an address meant for another network. The recipient should be carried through as Address<NetworkUnchecked> and validated with require_network(wallet.network()) inside execute, immediately before conversion to ScriptBuf.
Affected commands
The same unchecked pattern exists in create_tx, create_sp_tx, create_dns_tx, and bump_fee --shrink; silent payment codes are likewise unchecked.
Build environment
- BDK-CLI tag/commit:
master - OS+version: macOS 12.7.6 (Monterey)
- Rust/Cargo version: rustc 1.97.1
- Rust/Cargo target:
x86_64-apple-darwin
Additional context
The fix touches the shared recipient parsing/validation path used by those commands; no changes to the wallet API are needed.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Progress
Activity
tvpeter commentedon Dec 3, 2026
Thank you for reporting this. While I can confirm that the bug exist, majority of the description and reproduction steps are wrong:
createsubcommand (error: unrecognized subcommand 'create'). Wallets are set up with walletconfig.--descriptorand--change_descriptordon’t exist. The flags are--ext-descriptor / -eand--int-descriptor / -i.tb1address. So steps 3–4 and the “only fails later at broadcast” claim are wrong. The real problem is that funds go silently to a script the user meant for a different network, with no warning.rust-bitcointreatstestnet,testnet4andsignetas one network for address checks.emma31-dev commentedon Dec 3, 2026
@tvpeter Thanks for the detailed review!
you're right on all counts, and I want to own the inaccuracies. I wrote the repro from memory and let AI fill in the template, which is how the wrong subcommand/flags and the broadcast claim slipped in. And i forgot to update it as scope of PR changed.
wallet -w ... --descriptor ... createdoesn't exist. Setup iswallet --wallet <name> config --ext-descriptor <desc> --int-descriptor <desc>, and I misremembered--descriptor/--change_descriptorfor--ext-descriptor/--int-descriptor. I should have verified against--helpinstead of trusting recall and then repeated the same mistake a few more times.scriptPubKey, not the HRP, so the output is spendable and a regtest node accepts it. I re-ran it end-to-end against regtest:create_txtotb1q…succeeds and the transaction broadcasts, since it pays the same witness program as thebcrt1…form. The real defect is the silent cross-network misdirection with no warning.rust-bitcointreatstestnet,testnet4, andsignetas one address network, so atb1recipient is "valid" on any of them; only mainnet/regtest boundaries are actually caught.CreateTxCommandalone. The same unchecked pattern exists increate_sp_tx,create_dns_tx, andbump_fee --shrink, so the PR covers those too.I'll update the issue description and reproduction steps to reflect the exact CLI flags and actual behavior. Thanks again for the detailed review!