CKB Pulse
Lessons

What CKB learned

Start here · Glossary · Test yourself · Feed

From one fix

155 lessons found. All lessons

Page 5 of 13

Verify a deployed code cell is canonical and live before recording it as a cell depWorkingFrom one fix

Before writing a deployment manifest for a code cell, this commit checks get_transaction is committed, that get_block_hash at the header number equals the block hash (not reorganized), and that get_live_cell still reports status live with the expected data hash. It then repeats the canonical and live checks after all reads (on two independent RPCs), so a stale, spent or reorganized cell never yields a manifest.

#Cell deps and script lookup #Network and RPC reliability · Sources (1) · 2026-11-09

Verifying an indexer funding cell against an advancing tip instead of a frozen snapshotWorkingFrom one fix

A frozen-tip check ("the indexer tip must not change during the scan") fails often on a live chain, so do not demand it. Select a single funding cell from get_cells, verify it directly against the node (get_live_cell, get_transaction, get_header, output and data equal to the indexed ones), then re-check at the end that get_block_hash at the starting indexer tip still equals the anchor hash, that the cell's block is canonical, and that the cell is still live. New blocks arriving in between are fine, but still fail closed if the indexer lags the node at the start or the anchor hash changed. This gives one verified input, not a snapshot of the whole wallet.

#Indexer queries and cell collection #Network and RPC reliability · Sources (1) · 2026-11-09

Cheque lock receiver path must return the cell's capacity to the senderWorkingFrom one fix

When a Cheque lock cell (RFC 0039) is spent on the receiver path, rule 1.b.ii requires the Cheque cell's CKB capacity to go back to the sender's lock. An output paying that CKB to the receiver fails with Cheque error 8 (SenderCapacityNotSame). So the Cheque lock cannot be used to deliver plain CKB to the receiver, and in this project's tests it also blocked an owner placed in the receiver role from reclaiming their own CKB.

#Testing and devnet #Capacity and cell size · Sources (1) · 2026-11-09

Cheque lock sender withdrawal requires exact since 0xA000000000000006WorkingFrom one fix

The deployed Cheque lock (RFC 0039) accepts a sender withdrawal only when the Cheque input's since is exactly 0xA000000000000006 (relative epoch, 6 epochs after the cell was committed). A since of 0 fails with Cheque error 11 (WithdrawChequeInputSinceError), so the sender cannot reclaim for about 24h after each create or renew.

#Since and time locks #Testing and devnet · Sources (1) · 2026-11-09

Close spawn pipe descriptors when an IPC channel is freedWorkingFrom one fix

A pipe fd created by ckb_pipe or inherited through spawn stays live until ckb_close is called on it, and the VM limits how many descriptors can be live at once. Code that creates channels repeatedly must therefore close both pipe ends when finished. In ckb-script-ipc, csi_free_channel did not close them before PR #32; it now closes the library-owned pipe fds, and the peer's ckb_read then returns CKB_OTHER_END_CLOSED.

#Other · Sources (1) · 2026-11-09

Handle None from ckb_sdk Since::extract_metric for invalid since valuesWorkingFrom one fix

A raw since u64 can carry the reserved metric flag 0b11 (e.g. 0x6000_0000_0000_0000), for which ckb_sdk::Since::extract_metric() returns None, and a timestamp metric value can exceed what chrono can represent. Code that formats since values received from RPC should handle both cases instead of unwrapping, as ckb-cli now does by printing "invalid since" or "invalid".

#Since and time locks #Data encoding (molecule, hex, bigints) · Sources (1) · 2026-11-09

Classifying sendTransaction failures before dropping a pending CKB transactionWorkingFrom one fix

A failed or timed out ccc client.sendTransaction, or a getTransaction status of "rejected" or "unknown", does not prove the transaction can never commit: a node may have taken it, and "rejected" also covers pool removals such as expiry or a full pool. Store the signed bytes before sending. Drop the pending state only on final refusals (ErrorClientVerification, ErrorClientMaxFeeRateExceeded, TransactionFailedToVerify, PoolRejectedMalformedTransaction), or when an input is not live, the transaction that created that input is committed, and the node no longer holds your transaction as pending, proposed or committed. A not-live input alone is not proof, because CCC's getCellLive also returns not live for a cell the node has not seen. Otherwise resend the stored bytes, treating ErrorClientDuplicatedTransaction and PoolRejectedDuplicatedTransaction as success.

#Network and RPC reliability #Transaction building and fees · Sources (1) · 2026-11-08

Iterating group inputs and outputs with ckb-std until IndexOutOfBoundWorkingFrom one fix

In a ckb-std script, walk the cells of a source with the high-level loaders, for example load_cell_type_hash(i, Source::GroupInput) or load_cell_lock_hash(j, Source::Output), in an index loop. Break on Err(SysError::IndexOutOfBound), and return a script error code for any other SysError. Accumulate the u64 capacities you load in a u128 so that a sum over many cells cannot overflow.

#Capacity and cell size #Cell deps and script lookup · Sources (1) · 2026-11-08

ckb-cli deploy info file layout for offline multisig signingWorkingFrom one fix

A `ckb-cli deploy` info file is JSON with snake_case JSON-RPC transactions `cell_tx` and `dep_group_tx` (either may be null), `used_input_txs` (previous transactions by hash, so inputs resolve offline), signature maps `cell_tx_signatures` and `dep_group_tx_signatures` (lock args to a list of 65-byte signatures), and `deployment.multisig_config` with `sighash_addresses`, `require_first_n`, `threshold` and `lock_code_hash`. Each member address is a full-format sighash address whose args are the member's key hash; the list can be empty when the default config is used, so check for that before building the multisig script.

#Transaction building and fees #Witnesses and signatures · Sources (1) · 2026-11-08

Shape of ckb-cli deploy sign-txs outputWorkingFrom one fix

`ckb-cli deploy sign-txs` prints two maps, `cell_tx_signatures` and `dep_group_tx_signatures`, for the deploy info file's `cell_tx` and `dep_group_tx`. Each map goes from lock args (20 bytes, or 28 for multisig args with a since) to one 65 byte signature. It prints YAML-style text by default and a JSON object with `--output-format json`, and the YAML writer prints an empty map inline as `cell_tx_signatures: {}`, so a parser collecting multisig signatures must accept both shapes and the inline empty header.

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

Multisig sighash placeholder lock: script plus M zeroed signaturesWorkingFrom one fix

When computing the signing message for a secp256k1_blake160_multisig_all input, set the first witness's WitnessArgs.lock to the multisig script bytes followed by threshold × 65 zero bytes (a single key sighash lock uses just 65 zero bytes), and keep the inputType and outputType fields, before calling CCC's tx.getSignHashInfo(script, client). The same placeholder length must be used here as in the signed witness, otherwise the message differs from what the lock script hashes on chain.

#Witnesses and signatures #Transaction building and fees · Sources (2) · 2026-11-08

secp256k1_blake160_multisig_all signature matching rulesWorkingFrom one fix

The system multisig lock (secp256k1_blake160_multisig_all) expects the witness to carry exactly M signatures (threshold), uses each member key at most once, and requires all of the first R keys (require_first_n) to be among them. A tool collecting partial signatures should dedupe per member key and check the first R are present before finalizing, since any M valid distinct signers that include the first R form a complete set.

#Witnesses and signatures · Sources (1) · 2026-11-08

Page 5 of 13

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.