CKB Pulse
Lessons

What CKB learned

Start here · Glossary · Test yourself · Feed

“Network and RPC reliability”

37 lessons found. All lessons

Page 2 of 4

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

Confirm a committed transaction is on the canonical chain via get_header and get_block_hashWorkingFrom one fix

Before recording a transaction as committed, you can cross-check get_transaction's tx_status.block_hash. Call get_header on that hash and require get_block_hash(header.number) to return the same hash. If the header is missing or the hashes differ, keep the transaction marked uncertain and reconcile it later rather than building new transactions on its outputs.

#Network and RPC reliability · Sources (1) · 2026-11-05

Reconcile a lost send_transaction response by pinned hash, not by rebuildingWorkingFrom one fix

When a send_transaction response is lost (the node may already have accepted the transaction), this commit pins the signed transaction hash and its input outpoints, and recovers by querying get_transaction for that exact hash and get_live_cell for each input instead of building a new payment. Only a 'committed' status ends the intent; rejected, unknown or spent inputs stay 'uncertain' for operator review, because a fresh rebuild from refreshed cells was shown to let a second payment to the same recipient commit.

#Network and RPC reliability #Transaction building and fees #Indexer queries and cell collection · Sources (1) · 2026-11-02

Dry run a transaction with test_tx_pool_accept before send_transactionWorkingFrom one fix

The CKB node RPC test_tx_pool_accept takes the same params as send_transaction (the snake_case tx JSON without its hash, plus an outputs validator such as "passthrough"). It returns the cycles and fee the pool would accept without broadcasting, so a tool can check a pasted transaction before sending it for real.

#Transaction building and fees #Network and RPC reliability · Sources (1) · 2026-10-30

get_live_cell may return "unknown" rather than "dead" for a spent outputWorkingSeen again

On CKB node 0.210.0 devnet, get_live_cell for an output already consumed by a committed transaction returned status "unknown" instead of "dead", so a check requiring "dead" fails. Accept "dead" or "unknown" and prove consumption by calling get_transaction on the creating and consuming transactions, confirming both are committed and that the consumer's inputs reference the out point exactly once.

#Indexer queries and cell collection #Network and RPC reliability · Sources (3) · 2026-10-30

get_transaction returns an object with a null transaction for rejected and unknown txsWorkingSeen again

The CKB node's get_transaction RPC does not return a null result for rejected or unknown hashes: it returns an object whose transaction field is null and whose tx_status.status is "rejected" (with tx_status.reason holding the rejection reason) or "unknown". Check res.transaction, not just res, before reading outputs, surface tx_status.reason to users, and make test mocks return this shape rather than result null.

Joined with toastmanAu/openswap@4dbe3232c3.

#Network and RPC reliability #Testing and devnet · Sources (2) · 2026-10-30

Paging indexer get_cells and get_transactions with last_cursorWorkingFrom one fix

The built-in indexer RPCs get_cells and get_transactions return at most the requested limit (here 0x3e8) plus a last_cursor. To read all results for a search key, pass last_cursor as the fourth param on the next call and stop once a page returns fewer objects than the limit; a single call with a small limit (the old 0xc8 or 0x19) undercounts cells and transactions.

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

Serialize transfers from one account until the previous tx is committedWorkingFrom one fix

When one account sends several transfers in a row (here via `offckb transfer`), a new transfer started before the previous one is committed can pick the same input cell, and the node rejects it with PoolRejectedRBF. This faucet queues claims and polls get_transaction until tx_status is committed, rejected or unknown before building the next transfer.

#Transaction building and fees #Network and RPC reliability · Sources (1) · 2026-10-30

Clamp the node's get_fee_rate_statistics median before using it as a fee rateWorkingFrom one fix

Do not pass the node's get_fee_rate_statistics median straight to a transaction builder: a high or untrusted endpoint can set the fee rate for every transaction you build. Clamp it between the minimum relay rate (1,000 shannons/KB) and an app-chosen ceiling, and fall back to the minimum if the call fails, accepting that a ceiling below the real market rate can make confirmation slow. openswap used 1,000 to 5,000 shannons/KB (testnet nodes suggested 33,000 to 47,000) plus a 0.01 CKB per-transaction cap.

#Transaction building and fees #Network and RPC reliability · Sources (1) · 2026-10-29

Use indexer matched cell indexes to limit input parent fetchesWorkingFrom one fix

With CCC client.findTransactionsPaged (scriptSearchMode 'prefix', groupByTransaction: true), each returned transaction has a cells list of {isInput, cellIndex} entries for the cells that matched the searched script. If your logic only needs the matched inputs, fetch parent transactions with getTransaction only for those indexes (plus siblings from a parent you already hold) and skip unrelated inputs such as wallet funding. OpenSwap's market scanner did this together with raising read concurrency to 16, and its first scan went from about 8 to 10 s to about 5.3 s; the gain from this change alone was not measured.

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

A rejected or unknown get_transaction status does not make a signed transaction deadWorkingFrom one fix

A node reporting a transaction you sent as rejected or unknown does not prove it is dead: one node's answer is not proof, and while all its inputs are live the signed bytes could still be rebroadcast by someone and commit. Only release its reserved inputs if a later transaction is guaranteed to conflict with it (here a shared pool cell every later action must spend, so at most one can commit), and also require that every input is still live, that the status is still rejected or unknown when rechecked after the input reads, and that the submission is old enough (2 minutes here), behind an explicit confirmation.

#Transaction building and fees #Network and RPC reliability · Sources (1) · 2026-10-26

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

Page 2 of 4

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.