CKB Pulse

Todas as lições · Other · Começa aqui · Glossário

Hand-encoding WitnessArgs in moleculePráticoDe uma correção

De uma correção · Verificação: em parte certa · Verificada em 2026-11-19

WitnessArgs is a molecule table of three BytesOpt fields (lock, input_type, output_type). An absent field takes zero bytes, but a present empty field still takes a 4-byte length header, so the two encode differently. The table starts with a u32le total size, then three u32le offsets, the first being 16 (4 + 4*3), each counted from the start of the table. Check any hand-written encoder byte for byte against ccc.WitnessArgs.from(...).toBytes(), including the cases lock only, all absent, and a present empty field.

Porque importa: A hand-written encoder that treats an empty field like an absent one, or gets the offsets wrong, produces witness bytes that do not match what CCC and the scripts expect.

Um teste mudou no mesmo commit

Está ao lado da correcção. Nós não o corremos.

Conceitos
Data encoding (molecule, hex, bigints), Witnesses and signatures
Evidência
De uma correção: de um projeto, verificada contra o commit
Vista pela primeira vez
2026-11-14
Última mudança
2026-11-14
Última verificação
2026-11-19
Verificação contra o commit
em parte certa: um núcleo verdadeiro, com uma parte solta ou demasiado larga

Fontes (1)

Mais sobre Other

Ver as 9 deste tema

Manténs um projeto de onde esta lição veio? Confirma ou corrige

Citar esta lição
LusoCryptoLabs, "Hand-encoding WitnessArgs in molecule", CKB lessons, https://pulse.lusocryptolabs.com/learned/other/hand-encoding-witnessargs-in-molecule, CC BY 4.0, last changed 2026-11-14.

Tiradas de commits públicos e verificadas contra o commit de onde cada uma veio e o código de hoje do projeto. Lê a fonte antes de confiar numa. Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. Queres que uma lição seja mudada ou retirada? Abre um issue.