api: reject a /tx response that has no txid field
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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
txidraisesMempoolAPIErrorwith "Unexpected response from /tx: ...", like the existing mismatch check (a non-string one is already rejected). - Add a test to
tests/test_opreturn.pyfor a response withouttxid. - In
fuzz/fuzz_parsers.py, set thetxidfield to the requested txid for part of the inputs that are JSON objects: today the fuzzer gets past the check mostly by leavingtxidout (a randomtxidvalue rarely equalsTXID), and after the change it would rarely get past it. - Add a line to
CHANGELOG.mdunder[Unreleased].
Acceptance
- The new test fails on the current
mainand 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.
- Dominant language
- Python
- Stars
- 2
- Forks
- 1
- Avg merge
- 1h 45m
- Merged PRs (30d)
- 23
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from devdavidejesus/btc-toolkit
-
tests: assert which API paths each command requestsPossibly taken @omarelshamy25x claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
devdavidejesus/btc-toolkit#107 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
devdavidejesus/btc-toolkit#104 ·
Maintainers usually reply within 1 day
-
test(verify): cover invalid bits, the mainnet and testnet limits, and the strong thresholdPossibly taken @omarelshamy25x claimed this 1 day ago. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
devdavidejesus/btc-toolkit#99 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement help wanted
Difficulty 3/5 1-2 days Newbie friendliness 71/100
devdavidejesus/btc-toolkit#105 ·
Maintainers usually reply within 1 day
-
cli: Ctrl+C should stop btc-toolkit without a tracebackPossibly taken @jay23606 claimed this 1 day ago. Openbug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 25/100
devdavidejesus/btc-toolkit#102 ·
Maintainers usually reply within 1 day
All issues in devdavidejesus/btc-toolkit
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day