api: reject a /tx response that has no txid field

Aperta
#103 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@pkray2012 ci sta già lavorando.

Dal 3/12/2026.

  • #115 di @pkray2012 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
api, backend, testing

Direzione di ricerca

Read btc_toolkit/opreturn.py around lines 69–79, then inspect tests/test_opreturn.py and fuzz/fuzz_parsers.py. Add the missing-txid case to the tests, update the fuzzer inputs and add a [Unreleased] entry in CHANGELOG.md. Done means the missing field raises MempoolAPIError and the stated test, lint, type-check and full suite pass; an open linked pull request (#115) indicates work is already underway.

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

Descrizione

enhancement good first issue

What

fetch_transaction in opreturn.py, which tx, opreturn and inscription all use, checks that the API's answer describes the transaction that was asked for. It only does so when the answer has a txid field: data.get("txid", txid) falls back to the requested txid, so a response with no txid at all is accepted (opreturn.py L69-L79).

Mempool.space and Esplora always include txid, so a missing field means the response is not the one that was asked for. Other modules already read their fields with the helpers in btc_toolkit/api.py, where a field is required unless a default is given.

What to do

  • Require the field: a missing txid raises MempoolAPIError with "Unexpected response from /tx: ...", like the existing mismatch check (a non-string one is already rejected).
  • Add a test to tests/test_opreturn.py for a response without txid.
  • In fuzz/fuzz_parsers.py, set the txid field to the requested txid for part of the inputs that are JSON objects: today the fuzzer gets past the check mostly by leaving txid out (a random txid value rarely equals TXID), and after the change it would rarely get past it.
  • Add a line to CHANGELOG.md under [Unreleased].

Acceptance

  • The new test fails on the current main and passes with the change.
  • The full test suite passes; today no other test relies on a missing txid.

See CONTRIBUTING.md for the test, lint and type-check commands. Comment below before starting, so two people don't take the same issue.

Lingua principale
Python
Stelle
2
Fork
1
Merge medio
1h 45m
PR unite (30g)
23

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 devdavidejesus/btc-toolkit

Tutte le issue di devdavidejesus/btc-toolkit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.