GetTxOut

The gettxout RPC returns details about an unspent transaction output (UTXO).

Parameter #1—the TXID of the output to get

Name Type Presence Description
TXID string (hex) Required
(exactly 1)
The TXID of the transaction containing the output to get, encoded as hex in RPC byte order

Parameter #2—the output index number (vout) of the output to get

Name Type Presence Description
Vout number (int) Required
(exactly 1)
The output index number (vout) of the output within the transaction; the first output in a transaction is vout 0

Parameter #3—whether to display unconfirmed outputs from the memory pool

Name Type Presence Description
Unconfirmed bool Optional
(0 or 1)
Set to true to display unconfirmed outputs from the memory pool; set to false (the default) to only display outputs from confirmed transactions

Result—a description of the output

Name Type Presence Description
result object/null Required
(exactly 1)
Information about the output. If output wasn’t found, if it was spent or if an error occurred, this will be JSON null

bestblock
string (hex) Required
(exactly 1)
The hash of the header of the block on the local best block chain which includes this transaction. The hash will encoded as hex in RPC byte order. If the transaction is not part of a block, the string will be empty

confirmations
number (int) Required
(exactly 1)
The number of confirmations received for the transaction containing this output or 0 if the transaction hasn’t been confirmed yet

value
number (pai’s) Required
(exactly 1)
The amount of pai’s spent to this output. May be 0

scriptPubKey
string : object Optional
(0 or 1)
An object with information about the pubkey script. This may be null if there was no pubkey script
→ →
asm
string Required
(exactly 1)
The pubkey script in decoded form with non-data-pushing opcodes listed
→ →
hex
string (hex) Required
(exactly 1)
The pubkey script encoded as hex
→ →
reqSigs
number (int) Optional
(0 or 1)
The number of signatures required; this is always 1 for P2PK, P2PKH, and P2SH (including P2SH multisig because the redeem script is not available in the pubkey script). It may be greater than 1 for bare multisig. This value will not be returned for nulldata or nonstandard script types (see the type key below)
→ →
type
string Optional
(0 or 1)
The type of script. This will be one of the following:
pubkey for a P2PK script
pubkeyhash for a P2PKH script
scripthash for a P2SH script
multisig for a bare multisig script
nulldata for nulldata scripts
nonstandard for unknown scripts
→ →
addresses
string : array Optional
(0 or 1)
The P2PKH or P2SH addresses used in this transaction, or the computed P2PKH address of any pubkeys in this transaction. This array will not be returned for nulldata or nonstandard script types
→ → →
Address
string Required
(1 or more)
A P2PKH or P2SH address

version
number (int) Required
(exactly 1)
The transaction version number of the transaction containing the pubkey script

coinbase
bool Required
(exactly 1)
Set to true if the transaction output belonged to a coinbase transaction; set to false for all other transactions. Coinbase transactions need to have 101 confirmations before their outputs can be spent

Example

Get the UTXO from the following transaction from the first output index (“0”), searching the memory pool if necessary.

pai-cli -testnet gettxout \
  d77aee99e8bdc11f40b8a9354956f0346fec5535b82c77c8b5c06047e3bca86a \
  0 true

Result:

{
    "bestblock" : "00000000c92356f7030b1deeab54b3b02885711320b4c48523be9daa3e0ace5d",
    "confirmations" : 0,
    "value" : 0.00100000,
    "scriptPubKey" : {
        "asm" : "OP_DUP OP_HASH160 a11418d3c144876258ba02909514d90e71ad8443 OP_EQUALVERIFY OP_CHECKSIG",
        "hex" : "76a914a11418d3c144876258ba02909514d90e71ad844388ac",
        "reqSigs" : 1,
        "type" : "pubkeyhash",
        "addresses" : [
            "mvCfAJSKaoFXoJEvv8ssW7wxaqRPphQuSv"
        ]
    },
    "version" : 1,
    "coinbase" : false
}

See also

  • GetRawTransaction: gets a hex-encoded serialized transaction or a JSON object describing the transaction. By default, Pai Core only stores complete transaction data for UTXOs and your own transactions, so the RPC may fail on historic transactions unless you use the non-default txindex=1 in your Pai Core startup settings.
  • GetTransaction: gets detailed information about an in-wallet transaction.