Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

create_tx accepts recipient addresses from the wrong network

Abierto Apto para principiantes
#360 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
backend, cli

Línea de trabajo

Empieza por CreateTxCommand y parse_recipient, los dos lugares mencionados en el issue. Sigue cómo parse_recipient convierte el destinatario en un script y cómo execute accede a la red de la wallet; revisa las definiciones existentes de BDKCliError para InvalidNetwork. Se considerará terminado cuando create_tx rechace una dirección de otra red con ese error específico antes de generar un PSBT.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
142
Forks
103
Merge medio
2 d 9 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bitcoindevkit/bdk-cli

Todos los issues de bitcoindevkit/bdk-cli

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.