Todas as lições · Rust scripts and ckb-std · Começa aqui · Glossário
Treat an absent WitnessArgs.lock as a load failure in ckb-std lock scriptsPráticoDe uma correção
De uma correção · Verificação: certa · Verificada em 2026-11-19
With ckb-std, `load_witness_args(0, Source::GroupInput)` can succeed while `WitnessArgs.lock` is an empty BytesOpt, so call `lock().to_opt()` and return an error on None before reading `raw_data()`. The commit's ckb-testtool tests check both a missing witness and a WitnessArgs with no lock field, and both fail with the load witness error.
Porque importa: A WitnessArgs whose lock field is absent still deserializes successfully, so a script that only checks the load result will either panic on unwrap or run its signature logic against missing data instead of rejecting with a clear error code.
Padrão
let lock_opt = witness_args.lock().to_opt().ok_or(ERR_LOAD_WITNESS)?;Tirado do commit, encurtado.
Um teste mudou no mesmo commit
Está ao lado da correcção. Nós não o corremos.
- salmansarwarr/Tranfr:
tests/src/tests.rs
- Conceitos
- Witnesses and signatures, Data encoding (molecule, hex, bigints)
- Evidência
- De uma correção: de um projeto, verificada contra o commit
- Vista pela primeira vez
- 2026-09-25
- Última mudança
- 2026-09-25
- Ú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-09-25 · salmansarwarr/Tranfr · mais deste projeto
Mais sobre Rust scripts and ckb-std
- Use raw_data(), not as_slice(), when parsing a packed::Bytes witness
- CKB blake160 is the first 20 bytes of the 32 byte ckbhash
- Creation witness for an output type script goes in WitnessArgs.output_type
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
LusoCryptoLabs, "Treat an absent WitnessArgs.lock as a load failure in ckb-std lock scripts", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/treat-an-absent-witnessargs-lock-as-a-load-failure-in-ckb-st, CC BY 4.0, last changed 2026-09-25.