CKB Pulse
Lessons

What CKB learned

Start here · Glossary · Test yourself · Feed

LusoCryptoLabs/ckb-script-pitfalls

Lessons from LusoCryptoLabs/ckb-script-pitfalls

github.com/LusoCryptoLabs/ckb-script-pitfalls

Do you maintain this project? Confirm its lessons in one issue

1 lessons found. All lessons

Use raw_data(), not as_slice(), when parsing a packed::Bytes witnessWorkingChecked by the owner

A transaction witness in ckb_types is a molecule packed::Bytes, so as_slice() returns the 4 byte length header followed by the content, while raw_data() returns only the content (here a serialized WitnessArgs). A check that compares a witness to the secp256k1 sighash placeholder WitnessArgs (lock of 65 zero bytes) must use witness.raw_data() (or unpack()), otherwise it is silently never true. Fiber's funding witness merge never recognized placeholders until it switched to raw_data(), so a peer's placeholder could be kept in place of a real signature.

#Data encoding (molecule, hex, bigints) #Witnesses and signatures · Sources (2) · 2026-10-29

Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. JSON · Want a lesson changed or removed? Open an issue.