Todas as lições · CCC (TypeScript SDK) · Começa aqui · Glossário
Locate the signing witness slot instead of hardcoding its indexPráticoDe uma correção
De uma correção · Verificação: em parte certa · Verificada em 2026-11-19
The signing witness of a lock group sits at the index of the first input that uses that lock, so it differs between transaction shapes (in QuotaCell, 1 for payments and most owner actions, 0 for a deposit). In CCC, take the position from tx.getSignHashInfo(lock, client).position and assert it matches the position you set, instead of hardcoding 1. A wallet or test mock that has no lock available can look for the placeholder witness, but a bare "first non-empty witness" search is only safe when no other input carries a witness.
Porque importa: A hardcoded index such as 1 makes the mock wallet sign the wrong witness when an owner transaction puts the signer's input elsewhere, so that signature fails verification.
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. Cobre uma parte da lição: where CCC puts the witness, not the advice for wallets and mocks.
tests/ccc/signing-witness-position.test.mjs
- Conceitos
- Witnesses and signatures
- Evidência
- De uma correção: de um projeto, verificada contra o commit
- Vista pela primeira vez
- 2026-11-05
- Última mudança
- 2026-11-05
- Ú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)
- 2026-11-05 · Ticoworld/QuotaCell · mais deste projeto
Mais sobre CCC (TypeScript SDK)
- Re-zero the witness lock before recomputing the sign message with getSignHashInfo
- Reserve co-signer witness space before completeFeeBy in multi-signer CCC transactions
- Adding a wallet missing from CCC's connector via a SignersController subclass
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
LusoCryptoLabs, "Locate the signing witness slot instead of hardcoding its index", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/locate-the-signing-witness-slot-instead-of-hardcoding-its-in, CC BY 4.0, last changed 2026-11-05.