Todas as lições · Rust scripts and ckb-std · Começa aqui · Glossário
Keep other WitnessArgs fields when signing sighash_all in testsPráticoDe uma correção
De uma correção · Verificação: certa · Verificada em 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.
Porque importa: 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.
Padrão
let zero_lock = existing.clone().as_builder().lock(Some(Bytes::from(vec![0u8; 65])).pack()).build();Tirado do commit, encurtado.
Um teste mudou no mesmo commit
Está ao lado da correcção. Nós não o corremos.
- 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
- Conceitos
- Witnesses and signatures, Testing and devnet
- Evidência
- De uma correção: de um projeto, verificada contra o commit
- Vista pela primeira vez
- 2026-10-20
- Última mudança
- 2026-10-20
- Ú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)
- 2026-10-20 · ckb-service-runner/ckb-service-runner · mais deste projeto
Mais sobre 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
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
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.