Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show All 37 Lines | |||||
void TxToJSON(const CTransaction &tx, const uint256 hashBlock, | void TxToJSON(const CTransaction &tx, const uint256 hashBlock, | ||||
UniValue &entry) { | UniValue &entry) { | ||||
// Call into TxToUniv() in bitcoin-common to decode the transaction hex. | // Call into TxToUniv() in bitcoin-common to decode the transaction hex. | ||||
// | // | ||||
// Blockchain contextual information (confirmations and blocktime) is not | // Blockchain contextual information (confirmations and blocktime) is not | ||||
// available to code in bitcoin-common, so we query them here and push the | // available to code in bitcoin-common, so we query them here and push the | ||||
// data into the returned UniValue. | // data into the returned UniValue. | ||||
TxToUniv(tx, uint256(), entry); | TxToUniv(tx, uint256(), entry, true, RPCSerializationFlags()); | ||||
if (!hashBlock.IsNull()) { | if (!hashBlock.IsNull()) { | ||||
entry.pushKV("blockhash", hashBlock.GetHex()); | entry.pushKV("blockhash", hashBlock.GetHex()); | ||||
BlockMap::iterator mi = mapBlockIndex.find(hashBlock); | BlockMap::iterator mi = mapBlockIndex.find(hashBlock); | ||||
if (mi != mapBlockIndex.end() && (*mi).second) { | if (mi != mapBlockIndex.end() && (*mi).second) { | ||||
CBlockIndex *pindex = (*mi).second; | CBlockIndex *pindex = (*mi).second; | ||||
if (chainActive.Contains(pindex)) { | if (chainActive.Contains(pindex)) { | ||||
entry.pushKV("confirmations", | entry.pushKV("confirmations", | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | if (!GetTransaction(config, txid, tx, hashBlock, true)) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_ADDRESS_OR_KEY, | RPC_INVALID_ADDRESS_OR_KEY, | ||||
std::string(fTxIndex ? "No such mempool or blockchain transaction" | std::string(fTxIndex ? "No such mempool or blockchain transaction" | ||||
: "No such mempool transaction. Use -txindex " | : "No such mempool transaction. Use -txindex " | ||||
"to enable blockchain transaction queries") + | "to enable blockchain transaction queries") + | ||||
". Use gettransaction for wallet transactions."); | ". Use gettransaction for wallet transactions."); | ||||
} | } | ||||
std::string strHex = EncodeHexTx(*tx, RPCSerializationFlags()); | |||||
if (!fVerbose) { | if (!fVerbose) { | ||||
return strHex; | return EncodeHexTx(*tx, RPCSerializationFlags()); | ||||
} | } | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.pushKV("hex", strHex); | |||||
TxToJSON(*tx, hashBlock, result); | TxToJSON(*tx, hashBlock, result); | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue gettxoutproof(const Config &config, | static UniValue gettxoutproof(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || | if (request.fHelp || | ||||
(request.params.size() != 1 && request.params.size() != 2)) { | (request.params.size() != 1 && request.params.size() != 2)) { | ||||
▲ Show 20 Lines • Show All 381 Lines • ▼ Show 20 Lines | static UniValue decoderawtransaction(const Config &config, | ||||
CMutableTransaction mtx; | CMutableTransaction mtx; | ||||
if (!DecodeHexTx(mtx, request.params[0].get_str())) { | if (!DecodeHexTx(mtx, request.params[0].get_str())) { | ||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); | ||||
} | } | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
TxToUniv(CTransaction(std::move(mtx)), uint256(), result); | TxToUniv(CTransaction(std::move(mtx)), uint256(), result, false); | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue decodescript(const Config &config, | static UniValue decodescript(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
▲ Show 20 Lines • Show All 720 Lines • Show Last 20 Lines |