@ -35,6 +35,7 @@
# include <util/bip32.h>
# include <util/strencodings.h>
# include <util/string.h>
# include <util/vector.h>
# include <validation.h>
# include <validationinterface.h>
@ -77,6 +78,54 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
}
}
static std : : vector < RPCResult > DecodeTxDoc ( const std : : string & txid_field_doc )
{
return {
{ RPCResult : : Type : : STR_HEX , " txid " , txid_field_doc } ,
{ RPCResult : : Type : : STR_HEX , " hash " , " The transaction hash (differs from txid for witness transactions) " } ,
{ RPCResult : : Type : : NUM , " size " , " The serialized transaction size " } ,
{ RPCResult : : Type : : NUM , " vsize " , " The virtual transaction size (differs from size for witness transactions) " } ,
{ RPCResult : : Type : : NUM , " weight " , " The transaction's weight (between vsize*4-3 and vsize*4) " } ,
{ RPCResult : : Type : : NUM , " version " , " The version " } ,
{ RPCResult : : Type : : NUM_TIME , " locktime " , " The lock time " } ,
{ RPCResult : : Type : : ARR , " vin " , " " ,
{
{ RPCResult : : Type : : OBJ , " " , " " ,
{
{ RPCResult : : Type : : STR_HEX , " coinbase " , /*optional=*/ true , " The coinbase value (only if coinbase transaction) " } ,
{ RPCResult : : Type : : STR_HEX , " txid " , /*optional=*/ true , " The transaction id (if not coinbase transaction) " } ,
{ RPCResult : : Type : : NUM , " vout " , /*optional=*/ true , " The output number (if not coinbase transaction) " } ,
{ RPCResult : : Type : : OBJ , " scriptSig " , /*optional=*/ true , " The script (if not coinbase transaction) " ,
{
{ RPCResult : : Type : : STR , " asm " , " asm " } ,
{ RPCResult : : Type : : STR_HEX , " hex " , " hex " } ,
} } ,
{ RPCResult : : Type : : ARR , " txinwitness " , /*optional=*/ true , " " ,
{
{ RPCResult : : Type : : STR_HEX , " hex " , " hex-encoded witness data (if any) " } ,
} } ,
{ RPCResult : : Type : : NUM , " sequence " , " The script sequence number " } ,
} } ,
} } ,
{ RPCResult : : Type : : ARR , " vout " , " " ,
{
{ RPCResult : : Type : : OBJ , " " , " " ,
{
{ RPCResult : : Type : : STR_AMOUNT , " value " , " The value in " + CURRENCY_UNIT } ,
{ RPCResult : : Type : : NUM , " n " , " index " } ,
{ RPCResult : : Type : : OBJ , " scriptPubKey " , " " ,
{
{ RPCResult : : Type : : STR , " asm " , " the asm " } ,
{ RPCResult : : Type : : STR , " desc " , " Inferred descriptor for the output " } ,
{ RPCResult : : Type : : STR_HEX , " hex " , " the hex " } ,
{ RPCResult : : Type : : STR , " type " , " The type, eg 'pubkeyhash' " } ,
{ RPCResult : : Type : : STR , " address " , /*optional=*/ true , " The Bitcoin address (only if a well-defined address exists) " } ,
} } ,
} } ,
} } ,
} ;
}
static std : : vector < RPCArg > CreateTxDoc ( )
{
return {
@ -118,7 +167,7 @@ static RPCHelpMan getrawtransaction()
{
return RPCHelpMan {
" getrawtransaction " ,
" \n Return the raw transaction data. \n "
" Return the raw transaction data. \n "
" \n By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled \n "
" and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block. \n "
@ -127,7 +176,7 @@ static RPCHelpMan getrawtransaction()
" \n Hint: Use gettransaction for wallet transactions. \n "
" \n If verbose is 'true', returns an Object with information about 'txid'. \n "
" If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'. \n " ,
" If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'. " ,
{
{ " txid " , RPCArg : : Type : : STR_HEX , RPCArg : : Optional : : NO , " The transaction id " } ,
{ " verbose " , RPCArg : : Type : : BOOL , RPCArg : : Default { false } , " If false, return a string, otherwise return a json object " } ,
@ -138,58 +187,17 @@ static RPCHelpMan getrawtransaction()
RPCResult : : Type : : STR , " data " , " The serialized, hex-encoded data for 'txid' "
} ,
RPCResult { " if verbose is set to true " ,
// When updating this documentation, update `decoderawtransaction` in the same way.
RPCResult : : Type : : OBJ , " " , " " ,
Cat < std : : vector < RPCResult > > (
{
{ RPCResult : : Type : : BOOL , " in_active_chain " , /*optional=*/ true , " Whether specified block is in the active chain or not (only present with explicit \" blockhash \" argument) " } ,
{ RPCResult : : Type : : STR_HEX , " hex " , " The serialized, hex-encoded data for 'txid' " } ,
{ RPCResult : : Type : : STR_HEX , " txid " , " The transaction id (same as provided) " } ,
{ RPCResult : : Type : : STR_HEX , " hash " , " The transaction hash (differs from txid for witness transactions) " } ,
{ RPCResult : : Type : : NUM , " size " , " The serialized transaction size " } ,
{ RPCResult : : Type : : NUM , " vsize " , " The virtual transaction size (differs from size for witness transactions) " } ,
{ RPCResult : : Type : : NUM , " weight " , " The transaction's weight (between vsize*4-3 and vsize*4) " } ,
{ RPCResult : : Type : : NUM , " version " , " The version " } ,
{ RPCResult : : Type : : NUM_TIME , " locktime " , " The lock time " } ,
{ RPCResult : : Type : : ARR , " vin " , " " ,
{
{ RPCResult : : Type : : OBJ , " " , " " ,
{
{ RPCResult : : Type : : STR_HEX , " coinbase " , /*optional=*/ true , " The coinbase value (only if coinbase transaction) " } ,
{ RPCResult : : Type : : STR_HEX , " txid " , /*optional=*/ true , " The transaction id (if not coinbase transaction) " } ,
{ RPCResult : : Type : : NUM , " vout " , /*optional=*/ true , " The output number (if not coinbase transaction) " } ,
{ RPCResult : : Type : : OBJ , " scriptSig " , /*optional=*/ true , " The script (if not coinbase transaction) " ,
{
{ RPCResult : : Type : : STR , " asm " , " asm " } ,
{ RPCResult : : Type : : STR_HEX , " hex " , " hex " } ,
} } ,
{ RPCResult : : Type : : ARR , " txinwitness " , /*optional=*/ true , " " ,
{
{ RPCResult : : Type : : STR_HEX , " hex " , " hex-encoded witness data (if any) " } ,
} } ,
{ RPCResult : : Type : : NUM , " sequence " , " The script sequence number " } ,
} } ,
} } ,
{ RPCResult : : Type : : ARR , " vout " , " " ,
{
{ RPCResult : : Type : : OBJ , " " , " " ,
{
{ RPCResult : : Type : : STR_AMOUNT , " value " , " The value in " + CURRENCY_UNIT } ,
{ RPCResult : : Type : : NUM , " n " , " index " } ,
{ RPCResult : : Type : : OBJ , " scriptPubKey " , " " ,
{
{ RPCResult : : Type : : STR , " asm " , " the asm " } ,
{ RPCResult : : Type : : STR , " desc " , " Inferred descriptor for the output " } ,
{ RPCResult : : Type : : STR_HEX , " hex " , " the hex " } ,
{ RPCResult : : Type : : STR , " type " , " The type, eg 'pubkeyhash' " } ,
{ RPCResult : : Type : : STR , " address " , /*optional=*/ true , " The Bitcoin address (only if a well-defined address exists) " } ,
} } ,
} } ,
} } ,
{ RPCResult : : Type : : STR_HEX , " blockhash " , /*optional=*/ true , " the block hash " } ,
{ RPCResult : : Type : : NUM , " confirmations " , /*optional=*/ true , " The confirmations " } ,
{ RPCResult : : Type : : NUM_TIME , " blocktime " , /*optional=*/ true , " The block time expressed in " + UNIX_EPOCH_TIME } ,
{ RPCResult : : Type : : NUM , " time " , /*optional=*/ true , " Same as \" blocktime \" " } ,
}
{ RPCResult : : Type : : STR_HEX , " hex " , " The serialized, hex-encoded data for 'txid' " } ,
} ,
DecodeTxDoc ( /*txid_field_doc=*/ " The transaction id (same as provided) " ) ) ,
} ,
} ,
RPCExamples {
@ -309,7 +317,7 @@ static RPCHelpMan createrawtransaction()
static RPCHelpMan decoderawtransaction ( )
{
return RPCHelpMan { " decoderawtransaction " ,
" \n Return a JSON object representing the serialized, hex-encoded transaction. \n " ,
" Return a JSON object representing the serialized, hex-encoded transaction. " ,
{
{ " hexstring " , RPCArg : : Type : : STR_HEX , RPCArg : : Optional : : NO , " The transaction hex string " } ,
{ " iswitness " , RPCArg : : Type : : BOOL , RPCArg : : DefaultHint { " depends on heuristic tests " } , " Whether the transaction hex is a serialized witness transaction. \n "
@ -322,51 +330,7 @@ static RPCHelpMan decoderawtransaction()
} ,
RPCResult {
RPCResult : : Type : : OBJ , " " , " " ,
{
// When updating this documentation, update `getrawtransaction` in the same way.
{ RPCResult : : Type : : STR_HEX , " txid " , " The transaction id " } ,
{ RPCResult : : Type : : STR_HEX , " hash " , " The transaction hash (differs from txid for witness transactions) " } ,
{ RPCResult : : Type : : NUM , " size " , " The serialized transaction size " } ,
{ RPCResult : : Type : : NUM , " vsize " , " The virtual transaction size (differs from size for witness transactions) " } ,
{ RPCResult : : Type : : NUM , " weight " , " The transaction's weight (between vsize*4-3 and vsize*4) " } ,
{ RPCResult : : Type : : NUM , " version " , " The version " } ,
{ RPCResult : : Type : : NUM_TIME , " locktime " , " The lock time " } ,
{ RPCResult : : Type : : ARR , " vin " , " " ,
{
{ RPCResult : : Type : : OBJ , " " , " " ,
{
{ RPCResult : : Type : : STR_HEX , " coinbase " , /*optional=*/ true , " The coinbase value (only if coinbase transaction) " } ,
{ RPCResult : : Type : : STR_HEX , " txid " , /*optional=*/ true , " The transaction id (if not coinbase transaction) " } ,
{ RPCResult : : Type : : NUM , " vout " , /*optional=*/ true , " The output number (if not coinbase transaction) " } ,
{ RPCResult : : Type : : OBJ , " scriptSig " , /*optional=*/ true , " The script (if not coinbase transaction) " ,
{
{ RPCResult : : Type : : STR , " asm " , " asm " } ,
{ RPCResult : : Type : : STR_HEX , " hex " , " hex " } ,
} } ,
{ RPCResult : : Type : : ARR , " txinwitness " , /*optional=*/ true , " " ,
{
{ RPCResult : : Type : : STR_HEX , " hex " , " hex-encoded witness data (if any) " } ,
} } ,
{ RPCResult : : Type : : NUM , " sequence " , " The script sequence number " } ,
} } ,
} } ,
{ RPCResult : : Type : : ARR , " vout " , " " ,
{
{ RPCResult : : Type : : OBJ , " " , " " ,
{
{ RPCResult : : Type : : STR_AMOUNT , " value " , " The value in " + CURRENCY_UNIT } ,
{ RPCResult : : Type : : NUM , " n " , " index " } ,
{ RPCResult : : Type : : OBJ , " scriptPubKey " , " " ,
{
{ RPCResult : : Type : : STR , " asm " , " the asm " } ,
{ RPCResult : : Type : : STR , " desc " , " Inferred descriptor for the output " } ,
{ RPCResult : : Type : : STR_HEX , " hex " , " the hex " } ,
{ RPCResult : : Type : : STR , " type " , " The type, eg 'pubkeyhash' " } ,
{ RPCResult : : Type : : STR , " address " , /*optional=*/ true , " The Bitcoin address (only if a well-defined address exists) " } ,
} } ,
} } ,
} } ,
}
DecodeTxDoc ( /*txid_field_doc=*/ " The transaction id " ) ,
} ,
RPCExamples {
HelpExampleCli ( " decoderawtransaction " , " \" hexstring \" " )