A Bitcoin transaction can spend an output before that spend receives a confirmation. Bitcoin Core’s gettxout method takes this into account: by default, an output spent in the node’s mempool will no longer appear. A null response can therefore arrive while the spending transaction is still waiting for inclusion in a block.
| What you need to know |
|---|
| gettxout looks up one transaction output using its transaction ID and output number. |
| The include_mempool option defaults to true. |
| An output spent in the mempool is excluded when that option is enabled. |
| If the requested unspent output is not found, the method returns null. |
The rule is explicit in Bitcoin Core 30.0’s gettxout reference. Its warning matters when a wallet developer or payment operator uses the method to investigate an apparently missing output. The lookup is not restricted to confirmed spends unless the caller changes its mempool setting.
A pending spend changes the lookup
Consider an output created by a confirmed transaction. If a transaction spending it enters the node’s mempool, the default lookup excludes that output. The absence says something about the node’s view of available outputs, but it does not establish that the spend has been mined.
Setting include_mempool to false leaves the mempool out of the lookup. In that example, the confirmed output can still appear in the chain-only view while its spending transaction is unconfirmed. These two responses answer different questions. The chain-only result does not make the pending spend disappear; it changes which information the lookup considers.
The response belongs to a particular output
The two required arguments are the transaction ID and its vout number, identifying the requested output within that transaction. A successful response supplies the value in BTC, confirmation count and scriptPubKey details. It also includes bestblock, the hash of the block at the chain tip, which provides context for the returned information.
The address inside scriptPubKey is optional: Core only includes it when a well-defined address exists. Software reading the response therefore cannot treat an absent address field as the same thing as a null lookup. One is a field that may be omitted from a returned object; the other means the requested unspent output was not found.






