Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | static void TxToJSON(const CTransaction &tx, const BlockHash &hashBlock, | ||||
TxToUniv(tx, uint256(), entry, true, RPCSerializationFlags()); | TxToUniv(tx, uint256(), entry, true, RPCSerializationFlags()); | ||||
if (!hashBlock.IsNull()) { | if (!hashBlock.IsNull()) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
entry.pushKV("blockhash", hashBlock.GetHex()); | entry.pushKV("blockhash", hashBlock.GetHex()); | ||||
CBlockIndex *pindex = LookupBlockIndex(hashBlock); | CBlockIndex *pindex = LookupBlockIndex(hashBlock); | ||||
if (pindex) { | if (pindex) { | ||||
if (chainActive.Contains(pindex)) { | if (::ChainActive().Contains(pindex)) { | ||||
entry.pushKV("confirmations", | entry.pushKV("confirmations", | ||||
1 + chainActive.Height() - pindex->nHeight); | 1 + ::ChainActive().Height() - pindex->nHeight); | ||||
entry.pushKV("time", pindex->GetBlockTime()); | entry.pushKV("time", pindex->GetBlockTime()); | ||||
entry.pushKV("blocktime", pindex->GetBlockTime()); | entry.pushKV("blocktime", pindex->GetBlockTime()); | ||||
} else { | } else { | ||||
entry.pushKV("confirmations", 0); | entry.pushKV("confirmations", 0); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | if (!request.params[2].isNull()) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
BlockHash 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; | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | if (!request.params[1].isNull()) { | ||||
} | } | ||||
} 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. | ||||
for (const auto &txid : setTxIds) { | for (const auto &txid : setTxIds) { | ||||
const Coin &coin = AccessByTxid(*pcoinsTip, txid); | const Coin &coin = AccessByTxid(*pcoinsTip, txid); | ||||
if (!coin.IsSpent()) { | if (!coin.IsSpent()) { | ||||
pblockindex = chainActive[coin.GetHeight()]; | pblockindex = ::ChainActive()[coin.GetHeight()]; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// Allow txindex to catch up if we need to query it and before we acquire | // Allow txindex to catch up if we need to query it and before we acquire | ||||
// cs_main. | // cs_main. | ||||
if (g_txindex && !pblockindex) { | if (g_txindex && !pblockindex) { | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | static UniValue verifytxoutproof(const Config &config, | ||||
if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != | if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != | ||||
merkleBlock.header.hashMerkleRoot) { | merkleBlock.header.hashMerkleRoot) { | ||||
return res; | return res; | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const CBlockIndex *pindex = LookupBlockIndex(merkleBlock.header.GetHash()); | const CBlockIndex *pindex = LookupBlockIndex(merkleBlock.header.GetHash()); | ||||
if (!pindex || !chainActive.Contains(pindex) || pindex->nTx == 0) { | if (!pindex || !::ChainActive().Contains(pindex) || pindex->nTx == 0) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Block not found in chain"); | "Block not found in chain"); | ||||
} | } | ||||
// Check if proof is valid, only add results if so | // Check if proof is valid, only add results if so | ||||
if (pindex->nTx == merkleBlock.txn.GetNumTransactions()) { | if (pindex->nTx == merkleBlock.txn.GetNumTransactions()) { | ||||
for (const uint256 &hash : vMatch) { | for (const uint256 &hash : vMatch) { | ||||
res.push_back(hash.GetHex()); | res.push_back(hash.GetHex()); | ||||
▲ Show 20 Lines • Show All 1,592 Lines • Show Last 20 Lines |