All lessons · Rust scripts and ckb-std · Start here · Glossary
Place a script's raw witness at the index of the input it validatesWorkingFrom one fix
From one fix · Check: right · Checked 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.
Why it matters: 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.
Pattern
witnesses: [hex0x(ledgerWitness.encodeLedgerWitness(records)), ...entryCells.map(() => "0x"), "0x"]Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- toastmanAu/daowow:
apps/web/test/aggregate-tx.test.js,apps/web/test/entry-codec.test.js
- Concepts
- Witnesses and signatures, Transaction building and fees
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-09-25
- Last changed
- 2026-09-25
- Last checked
- 2026-11-19
- Check against the commit
- right: the lesson follows from its commit and still holds in the code today
Sources (1)
- 2026-09-25 · toastmanAu/daowow · more from this project
More about Rust scripts and ckb-std
- Type Script group membership and group witness index derived from the full script hash
- Use raw_data(), not as_slice(), when parsing a packed::Bytes witness
- Check that a derived successor type args match the spent cell's type args
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
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.