CKB Pulse

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

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

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)

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, "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.

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.