All lessons · Rust scripts and ckb-std · Start here · Glossary
Keep other WitnessArgs fields when signing sighash_all in testsWorkingFrom one fix
From one fix · Check: right · Checked 2026-11-19
When a test signer for the secp256k1 sighash_all lock fills the first witness of a script group, it should parse the existing WitnessArgs (for example one with data in output_type) and replace only the lock field: zeroed to 65 bytes while hashing, then set to the signature. Building a fresh WitnessArgs drops output_type or input_type data that a type script reads, and sighash_all hashes the whole first witness with only the lock zeroed, so those fields must already be in place when hashing.
Why it matters: A signer that writes a fresh WitnessArgs silently drops the data a type script reads from output_type or input_type, here the stake owner's consent signature, so the registry script rejects the transaction. If those fields were added after signing instead, the sighash_all signature would no longer match.
Pattern
let zero_lock = existing.clone().as_builder().lock(Some(Bytes::from(vec![0u8; 65])).pack()).build();Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- ckb-service-runner/ckb-service-runner:
acceptance/a8/p1.test.mjs,contracts/csr-contract-tests/tests/job.rs,contracts/csr-contract-tests/tests/registry.rs
- Concepts
- Witnesses and signatures, Testing and devnet
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-10-20
- Last changed
- 2026-10-20
- 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-10-20 · ckb-service-runner/ckb-service-runner · more from this project
More about Rust scripts and ckb-std
- ckb-std C shim needs a RISC-V C toolchain (clang) in CI
- Median time vs tip timestamp for deadlines
- Use raw_data(), not as_slice(), when parsing a packed::Bytes witness
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Keep other WitnessArgs fields when signing sighash_all in tests", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/keep-other-witnessargs-fields-when-signing-sighash-all-in-te, CC BY 4.0, last changed 2026-10-20.