CKB Pulse

Todas as lições · Rust scripts and ckb-std · Começa aqui · Glossário

Place a script's raw witness at the index of the input it validatesPráticoDe uma correção

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

When a type script reads its proof with load_witness(index, Source::Input) for its own input, the builder must put that raw witness at exactly that input's index. This commit puts the ledger cell at input 0 so its proof is witness 0, and pads the remaining witnesses with "0x" so witnesses.length equals inputs.length and a later funding/signing step appends rather than displaces it.

Porque importa: If the proof sits at any other witness index, the type script's load_witness(index, Source::Input) reads the wrong or empty bytes and the transaction is refused. An unpadded witness list also lets a later funding or signing step shift or overwrite the proof slot.

Padrão

Preferir
witnesses: [hex0x(ledgerWitness.encodeLedgerWitness(records)), ...entryCells.map(() => "0x"), "0x"]

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
De uma correção: de um projeto, verificada contra o commit
Vista pela primeira vez
2026-09-25
Última mudança
2026-09-25
Ú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)

Mais sobre Rust scripts and ckb-std

Ver as 35 deste tema

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

Citar esta lição
LusoCryptoLabs, "Place a script's raw witness at the index of the input it validates", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/place-a-script-s-raw-witness-at-the-index-of-the-input-it-va, CC BY 4.0, last changed 2026-09-25.

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.