CKB Pulse

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

Prefer
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.

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)

More about CKB node, RPC and indexer

All 45 in this topic

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.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.