test(rawtx): lock the txid of a real transaction with a scriptSig of 253 bytes or more
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- cli, cryptography, testing
Research direction
Start with tests/test_rawtx.py and inspect the existing _varint and non-canonical CompactSize tests; btc_toolkit/rawtx.py is cited for the behavior under test. Find a real mainnet transaction with a scriptSig of at least 253 bytes and record its txid, size, and base_size in the test. Add the requested boundary cases and check the raw transaction hex source in the PR; done when the tests detect incorrect encodings and bound changes without modifying btc_toolkit/.
Written by the indexing model from the issue text.
Description
What
decode_tx recomputes the txid by re-serializing the transaction without its witness data (rawtx.py L204). Lengths are written as CompactSize integers by _varint (L218-L225) and read by varint (L36-L44). The tests only exercise the 1-byte form of _varint (lengths below 253), and only the 3-byte form of the "non-canonical" check. A mistake in the other forms would go unnoticed: decode would print the wrong txid for such transactions, and decode --txid and verify would wrongly reject them as not hashing to their txid.
What to do
In tests/test_rawtx.py:
- Decode a real mainnet transaction whose scriptSig is 253 bytes or longer, and assert its txid,
sizeandbase_size. Large P2SH multisig spends (for example 3-of-5) are well above 253 bytes; a 2-of-3 spend can land just below, so check the length. - Test
_varintat the boundaries 252, 253, 0xFFFF, 0x10000, 0xFFFFFFFF and 0x100000000. - Test each bound of the non-canonical check at its edge:
fdfc00,feffff0000andffffffffff00000000are rejected as non-canonical;fdfd00,fe00000100andff0000000001000000are not: fed todecode_txafter a version, like the existing"01000000" + "fd0100"case, they fail later with "declares more items than it has bytes for" (_Reader(...).varint()alone accepts them). Today onlyfd0100is tested, so moving a bound by one goes unnoticed.
Acceptance
- The transaction is real and checkable: put its txid in the test, and say in the PR where the raw hex came from (for example
https://mempool.space/api/tx/<txid>/hex). - The tests fail if a branch of
_varintor a bound of the canonical check is broken (for example, writing a length of 253 to 65535 with the0xFEprefix and 4 bytes instead of0xFDand 2 bytes, or moving a bound by one). - No change under
btc_toolkit/.
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
-
api: reject a /tx response that has no txid fieldPossibly taken @pkray2012 claimed this 1 day ago. Openenhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
devdavidejesus/btc-toolkit#103 ·
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