Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show All 30 Lines | |||||
#include <wallet/rpcwallet.h> | #include <wallet/rpcwallet.h> | ||||
#endif | #endif | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <future> | #include <future> | ||||
#include <univalue.h> | #include <univalue.h> | ||||
static void TxToJSON(const CTransaction &tx, const uint256 hashBlock, | static void TxToJSON(const CTransaction &tx, const BlockHash &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, true, RPCSerializationFlags()); | TxToUniv(tx, uint256(), entry, true, RPCSerializationFlags()); | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | if (!request.params[1].isNull()) { | ||||
fVerbose = request.params[1].isNum() | fVerbose = request.params[1].isNum() | ||||
? (request.params[1].get_int() != 0) | ? (request.params[1].get_int() != 0) | ||||
: request.params[1].get_bool(); | : request.params[1].get_bool(); | ||||
} | } | ||||
if (!request.params[2].isNull()) { | if (!request.params[2].isNull()) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
uint256 blockhash = ParseHashV(request.params[2], "parameter 3"); | BlockHash blockhash(ParseHashV(request.params[2], "parameter 3")); | ||||
blockindex = LookupBlockIndex(blockhash); | blockindex = LookupBlockIndex(blockhash); | ||||
if (!blockindex) { | if (!blockindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Block hash not found"); | "Block hash not found"); | ||||
} | } | ||||
in_active_chain = chainActive.Contains(blockindex); | in_active_chain = chainActive.Contains(blockindex); | ||||
} | } | ||||
bool f_txindex_ready = false; | bool f_txindex_ready = false; | ||||
if (g_txindex && !blockindex) { | if (g_txindex && !blockindex) { | ||||
f_txindex_ready = g_txindex->BlockUntilSyncedToCurrentChain(); | f_txindex_ready = g_txindex->BlockUntilSyncedToCurrentChain(); | ||||
} | } | ||||
CTransactionRef tx; | CTransactionRef tx; | ||||
uint256 hash_block; | BlockHash hash_block; | ||||
if (!GetTransaction(params.GetConsensus(), txid, tx, hash_block, true, | if (!GetTransaction(params.GetConsensus(), txid, tx, hash_block, true, | ||||
blockindex)) { | blockindex)) { | ||||
std::string errmsg; | std::string errmsg; | ||||
if (blockindex) { | if (blockindex) { | ||||
if (!blockindex->nStatus.hasData()) { | if (!blockindex->nStatus.hasData()) { | ||||
throw JSONRPCError(RPC_MISC_ERROR, "Block not available"); | throw JSONRPCError(RPC_MISC_ERROR, "Block not available"); | ||||
} | } | ||||
errmsg = "No such transaction found in the provided block"; | errmsg = "No such transaction found in the provided block"; | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | for (unsigned int idx = 0; idx < txids.size(); idx++) { | ||||
} | } | ||||
setTxIds.insert(txid); | setTxIds.insert(txid); | ||||
oneTxId = txid; | oneTxId = txid; | ||||
} | } | ||||
CBlockIndex *pblockindex = nullptr; | CBlockIndex *pblockindex = nullptr; | ||||
uint256 hashBlock; | BlockHash hashBlock; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
hashBlock = uint256S(request.params[1].get_str()); | hashBlock = BlockHash::fromHex(request.params[1].get_str()); | ||||
pblockindex = LookupBlockIndex(hashBlock); | pblockindex = LookupBlockIndex(hashBlock); | ||||
if (!pblockindex) { | if (!pblockindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
} else { | } else { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
// Loop through txids and try to find which block they're in. Exit loop | // Loop through txids and try to find which block they're in. Exit loop | ||||
// once a block is found. | // once a block is found. | ||||
▲ Show 20 Lines • Show All 1,621 Lines • Show Last 20 Lines |