Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

create_tx accepts recipient addresses from the wrong network

Open Beginner friendly
#360 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend, cli

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

bug

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

  1. Create a regtest wallet:
    bdk-cli --network regtest wallet -w regtest_user1 --descriptor "..." --change_descriptor "..." create
    
  2. Attempt to send to a testnet address:
    bdk-cli --network regtest wallet -w regtest_user1 create_tx --to tb1qdgxnu...:1000
    
  3. Observe: the command succeeds and returns a PSBT.
  4. 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 --version output
  • 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bitcoindevkit/bdk-cli

All issues in bitcoindevkit/bdk-cli

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.