All lessons · CKB node, RPC and indexer · Start here · Glossary
get_transaction returns an object with a null transaction for rejected and unknown txsWorkingSeen again
Seen again · Check: right · Checked 2026-11-19
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.
Why it matters: Code that treats only a null result as 'not found' misreads unknown or rejected hashes: it crashes or misbehaves on the null transaction field, hides the node's rejection reason, and test mocks returning null guard against a shape real nodes never send.
Joined with toastmanAu/openswap@4dbe3232c3.
Pattern
if (res.tx_status.status === "rejected") return { hash, status: "rejected", reason: res.tx_status.reason ?? null, rejected: true };Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- toastmanAu/openswap:
frontend/test/fixtures.ts
- Concepts
- Network and RPC reliability, Testing and devnet
- Evidence
- Seen again: seen in two or more projects
- First seen
- 2026-10-30
- Last changed
- 2026-10-30
- Last checked
- 2026-11-19
- Check against the commit
- right: the lesson follows from its commit and still holds in the code today
Sources (2)
- 2026-10-30 · wildanrhmn/ckb-devnet-explorer · more from this project
- 2026-10-22 · toastmanAu/openswap · more from this project
More about CKB node, RPC and indexer
- CKB log subscription notifications may carry params.result as a JSON string
- Simulating a real CKB reorg with two devnet nodes over P2P
- Wait for tx_pool_info tip to match chain tip before submitting on devnet
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "get_transaction returns an object with a null transaction for rejected and unknown txs", CKB lessons, https://pulse.lusocryptolabs.com/learned/node/get-transaction-returns-an-object-with-a-null-transaction-fo, CC BY 4.0, last changed 2026-10-30.