Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

create_tx accepts recipient addresses from the wrong network

Aberta Para iniciantes
#360 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
82/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
rust
Domínio
backend, cli

Direção de pesquisa

Comece por CreateTxCommand e parse_recipient, os dois pontos mencionados na issue. Acompanhe como parse_recipient transforma o destinatário em um script e como execute acessa a rede da carteira; confira as definições existentes de BDKCliError para InvalidNetwork. O trabalho estará concluído quando create_tx rejeitar um endereço de outra rede com esse erro específico antes de produzir um PSBT.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Rust
Estrelas
142
Forks
103
Merge médio
2d 9h
PRs com merge (30d)
5

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de bitcoindevkit/bdk-cli

Todas as issues de bitcoindevkit/bdk-cli

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.