CKB Pulse

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

Prefer
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.

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)

More about Rust scripts and ckb-std

All 35 in this topic

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.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.