[move only] move DecodeTxDoc() to a common util file for sharing
This commit is contained in:
3 files changed
+46
-42
No files matched your search
@@ -82,48 +82,6 @@ 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", "Disassembly of the signature script"},
|
|
||||||
{RPCResult::Type::STR_HEX, "hex", "The raw signature script bytes, hex-encoded"},
|
|
||||||
}},
|
|
||||||
{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", "", ScriptPubKeyDoc()},
|
|
||||||
{RPCResult::Type::BOOL, "ischange", /*optional=*/true, "Output script is change (only if wallet transaction and true for selected rpcwallet)"},
|
|
||||||
}},
|
|
||||||
}},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<RPCArg> CreateTxDoc()
|
static std::vector<RPCArg> CreateTxDoc()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -334,3 +334,45 @@ void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const
|
|||||||
result.pushKV("errors", std::move(vErrors));
|
result.pushKV("errors", std::move(vErrors));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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", "Disassembly of the signature script"},
|
||||||
|
{RPCResult::Type::STR_HEX, "hex", "The raw signature script bytes, hex-encoded"},
|
||||||
|
}},
|
||||||
|
{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", "", ScriptPubKeyDoc()},
|
||||||
|
{RPCResult::Type::BOOL, "ischange", /*optional=*/true, "Output script is change (only if wallet transaction and true for selected rpcwallet)"},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <addresstype.h>
|
#include <addresstype.h>
|
||||||
#include <consensus/amount.h>
|
#include <consensus/amount.h>
|
||||||
|
#include <rpc/util.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -55,4 +56,7 @@ void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in);
|
|||||||
/** Create a transaction from univalue parameters */
|
/** Create a transaction from univalue parameters */
|
||||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf);
|
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf);
|
||||||
|
|
||||||
|
/** Explain the UniValue "decoded" transaction object **/
|
||||||
|
std::vector<RPCResult> DecodeTxDoc(const std::string& txid_field_doc);
|
||||||
|
|
||||||
#endif // BITCOIN_RPC_RAWTRANSACTION_UTIL_H
|
#endif // BITCOIN_RPC_RAWTRANSACTION_UTIL_H
|
||||||
Reference in new issue
Block a user