This guide explains Bitcoin Core getrawtransaction RPC in plain English. It shows what the command does, what its result means and what it cannot prove.
TL;DR
- What it is: Bitcoin Core 0.16.0 getrawtransaction retrieved serialised transaction hex or a decoded object. By default it reliably covered the mempool; txindex enabled historical chain lookup, and a known block hash allowed a targeted search without the index.
- Why it matters: getrawtransaction is a retrieval and decoding interface, not a payment verdict. Safe use verifies serialisation and identities, understands index and block availability and keeps active-chain and script validation separate.
- Current position: In verbose mode, in_active_chain reveals whether that specified block is active.
Bitcoin Core getrawtransaction RPC in simple English
Bitcoin Core getrawtransaction RPC: Without txindex, expect mempool retrieval unless the containing block hash is supplied and available. Do not rely on the deprecated unspent-output behaviour.
Simple example
A miner is checking Bitcoin Core getrawtransaction RPC. Retain the hash because recent chain membership can change after reorganisation. Pin the mode and validate response shape before processing untrusted sizes or scripts.
Key terms in plain English
- BIP:
- Bitcoin Improvement Proposal: a document describing a proposed rule, standard or process. Its status must be checked separately.
- Bitcoin Core:
- Widely used software that validates Bitcoin and can provide wallet, network and operator tools.
- RPC:
- A command that software sends to a node to request information or a local action.
- Consensus:
- The shared rules full nodes use to decide whether blocks and transactions are valid.
- Mempool:
- A node’s changing local collection of valid, unconfirmed transactions.
Availability contract
Without txindex, expect mempool retrieval unless the containing block hash is supplied and available. Do not rely on the deprecated unspent-output behaviour. Decide archive, indexed and pruned node roles explicitly, and distinguish unavailable local data from an invalid transaction.
Block-targeted lookup
A supplied blockhash searches only that block: a mempool copy or occurrence elsewhere is deliberately ignored. In verbose mode, in_active_chain reveals whether that specified block is active. Retain the hash because recent chain membership can change after reorganisation.
Raw and verbose modes
False returns hex consensus serialisation; true returns decoded identifiers, size, vsize, version, locktime, inputs, witness stacks, outputs and chain metadata where applicable. Pin the mode and validate response shape before processing untrusted sizes or scripts.
Transaction identities
txid excludes witness serialisation while hash in the historical verbose result represents witness-inclusive identity and can differ for SegWit transactions. Recompute both from raw bytes with a trusted parser. Never accept a supplied identifier without verifying the returned serialisation.
Inputs and outputs
vin references previous outpoints and carries scriptSig, sequence and optional witness; vout contains BTC value, index and script information. Verify previous outputs and script execution independently. Address renderings are conveniences, not the consensus definition of ownership.
Time and confirmations
time and blocktime are block-related historical fields, not precise transaction creation or receipt timestamps. Confirmations and active membership can change. Payment systems must monitor the exact output and recalculate depth after reorganisations.
How specialists test it
Operators test the command on a non-production node first. They check a normal reply, an invalid request, a timeout and a restart. This shows what the response means and prevents one local result from being mistaken for a network-wide outcome.
Frequently asked questions
What is the main point of Bitcoin Core getrawtransaction RPC?
Bitcoin Core getrawtransaction RPC: Without txindex, expect mempool retrieval unless the containing block hash is supplied and available.
For Bitcoin Core getrawtransaction RPC, what should a beginner know about availability contract?
Without txindex, expect mempool retrieval unless the containing block hash is supplied and available.
For Bitcoin Core getrawtransaction RPC, what should a beginner know about block-targeted lookup?
A supplied blockhash searches only that block: a mempool copy or occurrence elsewhere is deliberately ignored.
For Bitcoin Core getrawtransaction RPC, what should a beginner know about raw and verbose modes?
False returns hex consensus serialisation. True returns decoded identifiers, size, vsize, version, locktime, inputs, witness stacks, outputs and chain metadata where applicable.
Conclusion
getrawtransaction is a retrieval and decoding interface, not a payment verdict. Safe use verifies serialisation and identities, understands index and block availability and keeps active-chain and script validation separate.
Primary sources
Check the current specification status and the documentation for the exact implementation you operate before moving production funds or changing a mining node.
Join the ASIC Mining Discussion
Members can read and join the discussion
Log in to read comments from other miners. Create a free account if you would like to ask a question or share your experience.
Membership helps us protect the discussion from spam and keep answers useful.