CKB Pulse

Todas as lições · CCC (TypeScript SDK) · Começa aqui · Glossário

Sign each lock group with its own placeholder length and witness shapePráticoVista outra vez

Vista outra vez · Verificação: certa · Verificada em 2026-11-19

When one key controls several lock groups in a CCC transaction, call transaction.prepareSighashAllWitness(script, len, client) for each group with the final witness lock length of that lock, then getSignHashInfo and sign that group's own digest. In KeyWay's case the length is 65 bytes for secp256k1 and 85 bytes for an Omnilock owner witness holding one 65-byte signature; write the bare signature for secp256k1 and wrap it in the OmniLockWitnessLock molecule for Omnilock. A custom lock with its own witness layout needs its own length the same way.

Porque importa: If a group's digest is computed over a placeholder of the wrong length, or one group's signature is reused for another lock, the witness the lock script hashes on chain differs from what was signed and verification fails.

Padrão

Preferir
await transaction.prepareSighashAllWitness(script, witnessLockLength(kind), client);

Tirado do commit, encurtado.

Um teste mudou no mesmo commit

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

Conceitos
Witnesses and signatures, Transaction building and fees
Evidência
Vista outra vez: vista em dois ou mais projetos
Vista pela primeira vez
2026-10-23
Última mudança
2026-10-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 (2)

Mais sobre CCC (TypeScript SDK)

Ver as 33 deste tema

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

Citar esta lição
LusoCryptoLabs, "Sign each lock group with its own placeholder length and witness shape", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/sign-each-lock-group-with-its-own-placeholder-length-and-wit, CC BY 4.0, last changed 2026-10-23.

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.