Todas as lições · CCC (TypeScript SDK) · Começa aqui · Glossário
Hand-rolled Script hash: hash_type byte mapping and molecule offsets, checked against CCCPráticoReproduzida
Reproduzida · Verificação: certa · Verificada em 2026-11-19
If you serialise a CKB Script molecule yourself to compute its blake2b hash, use a 16 byte header (total size plus three u32 offsets 16, 48, 49) and map hash_type as data=0, type=1, data1=2, data2=4 (not 3). This commit cross checks the result against ccc.Script.from(...).hash() for all four hash types, and a single wrong offset or data2 mapped to 3 makes that test fail.
Porque importa: A wrong molecule offset or data2 mapped to 3 yields a plausible script hash that matches nothing, so a lock hash comparison such as entry-lock's committed participant check refuses the spend.
Padrão
const hashType = { data: 0, type: 1, data1: 2, data2: 4 }[script.hashType];Tirado do commit, encurtado.
Um teste mudou no mesmo commit
Está ao lado da correcção. Nós não o corremos.
- toastmanAu/daowow:
apps/web/test/refund-tx.test.js
Reproduzida por um teste
Um teste público corre o que esta lição diz em @ckb-ccc/core 1.23.1, sem nó. Qualquer pessoa o pode correr.
tests/ccc/script-hash.test.mjs
- Conceitos
- Data encoding (molecule, hex, bigints), Testing and devnet
- Evidência
- Reproduzida: reproduzida por um teste público
- Vista pela primeira vez
- 2026-09-23
- Última mudança
- 2026-09-23
- Última verificação
- 2026-11-19
- Verificação contra o commit
- certa: a lição sai do commit e continua a valer no código de hoje
Fontes (1)
- 2026-09-23 · toastmanAu/daowow · mais deste projeto
Mais sobre CCC (TypeScript SDK)
- CCC custom client scripts must include AnyoneCanPay for SignerCkbPrivateKey
- Convert Fiber RPC snake_case scripts to CCC camelCase ScriptLike
- Parsing snake_case JSON-RPC transactions in CCC
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
LusoCryptoLabs, "Hand-rolled Script hash: hash_type byte mapping and molecule offsets, checked against CCC", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/hand-rolled-script-hash-hash-type-byte-mapping-and-molecule, CC BY 4.0, last changed 2026-09-23.