CKB Pulse

All lessons · Other · Start here · Glossary

Restrict script hashType to data, type, data1, data2 when loading configWorkingFrom one fix

From one fix · Check: right · Checked 2026-11-19

CKB hash_type encodes as data=0, type=1, data1=2, data2=4 (no value 3), so a config loader should reject any hashType string outside data/type/data1/data2 rather than map it loosely. A wrong code hash or hash type makes cell discovery watch the wrong cells and silently return empty results.

Why it matters: A loosely parsed hashType can silently land on a real but wrong hash type, so discovery watches the wrong cells and returns an empty result that looks like a round that has not opened yet.

hash_type validation, not covered

Pattern

Prefer
const HASH_TYPES = Object.freeze(["data", "type", "data1", "data2"]);

Taken from the commit, shortened.

A test changed in the same commit

It sits next to the fix. We did not run it.

Concepts
Cell deps and script lookup, Data encoding (molecule, hex, bigints)
Evidence
From one fix: from one project, checked against its commit
First seen
2026-09-18
Last changed
2026-09-18
Last checked
2026-11-19
Check against the commit
right: the lesson follows from its commit and still holds in the code today

Sources (1)

More about Other

All 9 in this topic

Do you maintain a project this lesson came from? Confirm or correct it

Cite this lesson
LusoCryptoLabs, "Restrict script hashType to data, type, data1, data2 when loading config", CKB lessons, https://pulse.lusocryptolabs.com/learned/other/restrict-script-hashtype-to-data-type-data1-data2-when-loadi, CC BY 4.0, last changed 2026-09-18.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.