CKB Pulse
Lessons

What CKB learned

Start here · Glossary · Test yourself · Feed

Wallets and signing

23 lessons found. All lessons

Page 2 of 2

Omnilock owner signing needs an 85 byte zeroed witness lock placeholderWorkingFrom one fix

For an Omnilock cell spent in owner (secp256k1) mode, the WitnessArgs.lock is an 85 byte OmniLockWitnessLock (a 20 byte molecule header 0x5500000010000000550000005500000041000000 plus the 65 byte signature), so the sighash digest must be computed with an 85 byte zeroed placeholder (e.g. CCC prepareSighashAllWitness(lock, 85, client)). A digest taken over the usual 65 byte secp256k1 placeholder does not verify, which the test confirms against a real testnet spend.

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

JoyID lock witness outputType may carry a subkey proof, so type script data must move elsewhereWorkingFrom one fix

When the funding wallet uses the JoyID lock, its WitnessArgs outputType may carry a subkey unlock proof, so do not put your own type script data in that witness's outputType. Place the type script action in another witness index and align the related output index with it. Size the fee estimate's signature placeholder for JoyID's larger witness (openswap uses 1000 bytes) instead of the 65 byte secp256k1 size.

#Witnesses and signatures #Transaction building and fees · Sources (1) · 2026-10-22

Release a stuck signed transaction's inputs only after one input is spent elsewhereWorkingFrom one fix

A signed CKB transaction that is not committed (not pending, proposed or sent) is still valid and can be broadcast by anyone while all its inputs are live, so do not release its input reservations yet. Release them only after a committed-state live-cell check shows at least one input spent (a spend still in the tx pool does not count), and a second status check confirms the transaction still has not committed. A conflicting spend can still be reorganized away, so require the operator to acknowledge that risk.

#Transaction building and fees #Indexer queries and cell collection #Network and RPC reliability · Sources (2) · 2026-10-22

Keep at least 61 CKB in the change cell when sending from a secp256k1 walletBasicFrom one fix

A plain secp256k1_blake160 cell occupies 61 CKB, so when a wallet sends X it must keep at least 61 CKB (the occupied capacity of its own lock) in the change cell, plus the fee, and refuse the send otherwise. The recipient output must also be at least the occupied capacity of the recipient's lock, never less than 61 CKB for a plain address. Enforce the change floor in the transaction builder, and use extra headroom (this runner uses threshold >= amount + 100) for automatic sweeps so fee and change always fit.

#Capacity and cell size #Transaction building and fees · Sources (1) · 2026-10-21

Address balance via get_cells_capacity with snake_case lock scriptWorkingFrom one fix

To show a CKB address balance, convert the address to a lock script (ckb-sdk-utils addressToScript returns camelCase codeHash/hashType) and pass it to the indexer RPC get_cells_capacity with snake_case fields (code_hash, hash_type, args) and script_type "lock". The returned capacity is a hex shannon string, so parse it with BigInt and divide by 10^8 for CKB.

#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · Sources (1) · 2026-10-15

JoyID sub key membership is checked through the CoTA aggregatorAdvancedChecked by the owner

A JoyID passkey from a second device is a sub key, so deriving the JoyID lock from the signer's public key does not find the account. Given the account's address, call JoyID's CoTA aggregator method generate_subkey_unlock_smt with alg_index 1 (the passkey algorithm), pubkey_hash set to the first 20 bytes of ckbHash(pubkey) for the same pubkey bytes JoyID signs with, and lock_script set to the serialized lock; a non-empty result.unlock_entry means the key belongs to that account. The aggregator is trusted and its SMT proof is not checked against the chain, and the positive case was not run against a real sub key here.

#Witnesses and signatures #Login and authorization · Sources (1) · 2026-10-12

Secp256k1 sighash lock groups cover non contiguous later group witnessesWorkingFrom one fix

With the bundled secp256k1 blake160 sighash lock, all inputs sharing the same lock form one group even when another owner's inputs sit between them. The signature goes in the witness at the group's first input index, and changing a later group witness (which leaves the tx hash unchanged) still fails verification at Inputs[first].Lock. So composed multi owner transactions must place one signature placeholder per lock group at its first input and finalize every group witness before signing.

#Witnesses and signatures #Transaction building and fees · Sources (1) · 2026-10-09

EVM owners may hold Omnilock lock args with auth flag 0x12, not only 0x01WorkingFrom one fix

When mapping an Ethereum address to the CKB lock scripts it controls, match Omnilock args 0x12 || addr20 || 0x00 (Ethereum displaying, used by CCC's EVM signer for new addresses) as well as 0x01 || addr20 || 0x00 and PW Lock args = addr20. Otherwise deposits held by CCC created EVM addresses are not recognised. The commit notes this is still pending confirmation in a wallet proof of concept.

#Witnesses and signatures #Login and authorization · Sources (1) · 2026-10-08

Verifying Neuron style signed messages against a secp256k1_blake160 lockWorkingFrom one fix

To verify a Neuron "Sign Message" signature, hash with CKB Blake2b over UTF-8("Nervos Message:" followed by the text), recover the compressed public key from the 65 byte r||s||v signature (v is 0 or 1, not 27/28), and accept the owner only if the lock has the exact code_hash and hash_type of the secp256k1_blake160 template and its args equal blake160 of the recovered key (comparing args alone is not enough). Neuron signs low-s; if you choose to also accept high-s, normalise s to n minus s and flip v before recovery, because some verify helpers (CCC's) reject high-s.

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

DAO compensation must use the deposit cell's occupied capacity (102 CKB), not 61WorkingFrom one fix

When calculating Nervos DAO max withdraw or compensation (here via the light client's nativeCalculateMaxWithdraw), pass the occupied capacity of the actual DAO deposit cell (102 CKB for a secp256k1 lock plus DAO type plus 8 bytes data), not the 61 CKB of a plain secp256k1 cell. Using 61 overstates the interest by (C - 61) / (C - 102), and the result no longer matches what the unlock transaction pays out.

#Capacity and cell size · Sources (1) · 2026-10-06

Use the secp256k1 sighash dep group, not the bare code cell, as the lock depWorkingFrom one fix

When a hand-built transaction spends a secp256k1_blake160_sighash_all cell, it needs a cell dep for that lock. That dep should be the genesis dep group (dep_type dep_group), not the bare code cell in genesis tx0, because the lock also loads the secp256k1_data table from a second cell. With only the code cell, ScriptNotFound goes away but the lock then fails inside execution.

#Cell deps and script lookup #Transaction building and fees · Sources (2) · 2026-09-25

Page 2 of 2

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.