All lessons · Other · Start here · Glossary
Range check since epoch fields instead of masking themWorkingFrom one fix
From one fix · Check: right · Checked 2026-11-21
When packing an epoch-based since value (24-bit epoch number, 16-bit index, 16-bit length), masking an out-of-range epoch silently wraps it into a much earlier deadline. This commit's packSince now throws a RangeError for any field outside its bit width, and createTranfr/renewTranfr check that tip epoch plus duration fits within 0xFFFFFF before packing.
Why it matters: Masking an epoch number above 0xFFFFFF silently wraps it into a much earlier since deadline, so the time lock can open far sooner than the caller intended with no error raised.
The existing since lesson covers the metric flag bits. This card is about range checking the epoch number, index and length fields rather than masking them.
Pattern
((epoch & NUMBER_MASK) << NUMBER_OFFSET)Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- salmansarwarr/Tranfr:
demo/e2e/wallet-mode.spec.ts,sdk/tests/client.test.ts,sdk/tests/since-cmp.test.ts,tests/src/tests.rs
- Concepts
- Since and time locks, Data encoding (molecule, hex, bigints)
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-11-20
- Last changed
- 2026-11-20
- Last checked
- 2026-11-21
- Check against the commit
- right: the lesson follows from its commit and still holds in the code today
Sources (1)
- 2026-11-20 · salmansarwarr/Tranfr · more from this project
More about Other
- Recognizing a Nervos DAO deposit cell (not a withdrawing one)
- Absolute epoch since needs the 0x20 metric flag
- Hand-encoding WitnessArgs in molecule
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Range check since epoch fields instead of masking them", CKB lessons, https://pulse.lusocryptolabs.com/learned/other/range-check-since-epoch-fields-instead-of-masking-them, CC BY 4.0, last changed 2026-11-20.