Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

create_tx accepts recipient addresses from the wrong network

Aperta Adatta ai principianti
#360 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend, cli

Direzione di ricerca

Inizia da CreateTxCommand e parse_recipient, i due punti indicati nell’issue. Segui come parse_recipient converte il destinatario in uno script e come execute accede alla rete del wallet; controlla le definizioni esistenti di BDKCliError per InvalidNetwork. Il lavoro è completato quando create_tx rifiuta un indirizzo di un’altra rete con quello specifico errore prima di produrre un PSBT.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
142
Fork
103
Merge medio
2g 9h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bitcoindevkit/bdk-cli

Tutte le issue di bitcoindevkit/bdk-cli

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.