create_tx accepts recipient addresses from the wrong network
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start with CreateTxCommand and parse_recipient, the two locations named in the issue. Trace how parse_recipient turns the recipient into a script and how execute accesses the wallet network; check the existing BDKCliError definitions for InvalidNetwork. Done when create_tx rejects an address from another network with that specific error before producing a PSBT.
Written by the indexing model from the issue text.
Description
Describe the bug
create_tx accepts a recipient address belonging to a different network than the wallet. The transaction is built successfully, but the resulting PSBT is unspendable on the target network and only fails later at broadcast time with a node-side rejection. The cause is in parse_recipient: it calls Address::from_str (which yields Address<NetworkUnchecked>) and immediately converts to ScriptBuf via .script_pubkey(), discarding the network information before the wallet's network is known. bdk-cli therefore never compares the two.
To Reproduce
- Create a regtest wallet:
bdk-cli --network regtest wallet -w regtest_user1 --descriptor "..." --change_descriptor "..." create - Attempt to send to a testnet address:
bdk-cli --network regtest wallet -w regtest_user1 create_tx --to tb1qdgxnu...:1000 - Observe: the command succeeds and returns a PSBT.
- Broadcasting that PSBT against the regtest node fails with an address/script error, because
tb1...does not belong to the regtest network.
Expected behavior
create_tx should reject the recipient at construction time with a specific error naming the mismatch, rather than producing a PSBT that can never be spent. BDKCliError::InvalidNetwork { requested, found } should be created for this purpose. The recipient should be carried through as Address<NetworkUnchecked> and validated with require_network(ctx.state.wallet.network()) inside execute, immediately before conversion to ScriptBuf.
Build environment
- BDK-CLI tag/commit:
main - OS+version: macOS 12.7.6 (Monterey)
- Rust/Cargo version:
rustc --versionoutput - Rust/Cargo target:
x86_64-apple-darwin
Additional context
The fix is confined to CreateTxCommand and parse_recipient; no changes to the wallet API are needed.
- Dominant language
- Rust
- Stars
- 142
- Forks
- 103
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bitcoindevkit/bdk-cli
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bitcoindevkit/bdk-cli#358 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bitcoindevkit/bdk-cli#357 ·
Maintainers usually reply within 2 days
-
Remove "wallet" field from `WalletConfigInner`Possibly taken @Jennycj claimed this 7 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bitcoindevkit/bdk-cli#332 · 2 comments ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 55/100
bitcoindevkit/bdk-cli#359 ·
Maintainers usually reply within 2 days
-
`warn!` output is invisible unless `RUST_LOG` is setPossibly taken @chukwudiikeh claimed this 5 days ago. Open
bitcoindevkit/bdk-cli#352 · 1 comment · 1 assignee ·
Maintainers usually reply within 2 days
All issues in bitcoindevkit/bdk-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Zellij doesn't validate hex colors correctly and crashesPossibly taken @ymcx claimed this today. Opensuspected bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zellij-org/zellij#5732 ·
Maintainers usually reply within 1 day
-
bug(api): E_DOSE_ATTR_NONFINITE for a modeled D/R still says the value "never reaches you as a NaN"Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100