mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
scripted-diff: rest/rpc: Use renamed EnsureAny*()
-BEGIN VERIFY SCRIPT- sed -i -E 's@Ensure([^(]+)(\((request\.|)context\))@EnsureAny\1\2@g' \ -- src/rest.cpp src/rpc/*.cpp -END VERIFY SCRIPT-
This commit is contained in:
parent
1570c7ee98
commit
6fb65b49f4
5 changed files with 80 additions and 80 deletions
|
@ -181,7 +181,7 @@ static bool rest_headers(const std::any& context,
|
||||||
headers.reserve(count);
|
headers.reserve(count);
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
ChainstateManager& chainman = EnsureChainman(context);
|
ChainstateManager& chainman = EnsureAnyChainman(context);
|
||||||
tip = chainman.ActiveChain().Tip();
|
tip = chainman.ActiveChain().Tip();
|
||||||
const CBlockIndex* pindex = chainman.m_blockman.LookupBlockIndex(hash);
|
const CBlockIndex* pindex = chainman.m_blockman.LookupBlockIndex(hash);
|
||||||
while (pindex != nullptr && chainman.ActiveChain().Contains(pindex)) {
|
while (pindex != nullptr && chainman.ActiveChain().Contains(pindex)) {
|
||||||
|
@ -251,7 +251,7 @@ static bool rest_block(const std::any& context,
|
||||||
CBlockIndex* tip = nullptr;
|
CBlockIndex* tip = nullptr;
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
ChainstateManager& chainman = EnsureChainman(context);
|
ChainstateManager& chainman = EnsureAnyChainman(context);
|
||||||
tip = chainman.ActiveChain().Tip();
|
tip = chainman.ActiveChain().Tip();
|
||||||
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
||||||
if (!pblockindex) {
|
if (!pblockindex) {
|
||||||
|
@ -538,7 +538,7 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
|
||||||
std::string bitmapStringRepresentation;
|
std::string bitmapStringRepresentation;
|
||||||
std::vector<bool> hits;
|
std::vector<bool> hits;
|
||||||
bitmap.resize((vOutPoints.size() + 7) / 8);
|
bitmap.resize((vOutPoints.size() + 7) / 8);
|
||||||
ChainstateManager& chainman = EnsureChainman(context);
|
ChainstateManager& chainman = EnsureAnyChainman(context);
|
||||||
{
|
{
|
||||||
auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const CTxMemPool& mempool) {
|
auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const CTxMemPool& mempool) {
|
||||||
for (const COutPoint& vOutPoint : vOutPoints) {
|
for (const COutPoint& vOutPoint : vOutPoints) {
|
||||||
|
@ -642,7 +642,7 @@ static bool rest_blockhash_by_height(const std::any& context, HTTPRequest* req,
|
||||||
CBlockIndex* pblockindex = nullptr;
|
CBlockIndex* pblockindex = nullptr;
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
const CChain& active_chain = EnsureChainman(context).ActiveChain();
|
const CChain& active_chain = EnsureAnyChainman(context).ActiveChain();
|
||||||
if (blockheight > active_chain.Height()) {
|
if (blockheight > active_chain.Height()) {
|
||||||
return RESTERR(req, HTTP_NOT_FOUND, "Block height out of range");
|
return RESTERR(req, HTTP_NOT_FOUND, "Block height out of range");
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ CTxMemPool& EnsureMemPool(const NodeContext& node)
|
||||||
|
|
||||||
CTxMemPool& EnsureAnyMemPool(const std::any& context)
|
CTxMemPool& EnsureAnyMemPool(const std::any& context)
|
||||||
{
|
{
|
||||||
return EnsureMemPool(EnsureNodeContext(context));
|
return EnsureMemPool(EnsureAnyNodeContext(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
ChainstateManager& EnsureChainman(const std::any& ctx) {
|
ChainstateManager& EnsureChainman(const std::any& ctx) {
|
||||||
|
@ -100,7 +100,7 @@ ChainstateManager& EnsureChainman(const NodeContext& node)
|
||||||
|
|
||||||
ChainstateManager& EnsureAnyChainman(const std::any& context)
|
ChainstateManager& EnsureAnyChainman(const std::any& context)
|
||||||
{
|
{
|
||||||
return EnsureChainman(EnsureNodeContext(context));
|
return EnsureChainman(EnsureAnyNodeContext(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& ctx) {
|
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& ctx) {
|
||||||
|
@ -117,7 +117,7 @@ CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node)
|
||||||
|
|
||||||
CBlockPolicyEstimator& EnsureAnyFeeEstimator(const std::any& context)
|
CBlockPolicyEstimator& EnsureAnyFeeEstimator(const std::any& context)
|
||||||
{
|
{
|
||||||
return EnsureFeeEstimator(EnsureNodeContext(context));
|
return EnsureFeeEstimator(EnsureAnyNodeContext(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the difficulty for a given block index.
|
/* Calculate the difficulty for a given block index.
|
||||||
|
@ -227,7 +227,7 @@ static RPCHelpMan getblockcount()
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
return EnsureChainman(request.context).ActiveChain().Height();
|
return EnsureAnyChainman(request.context).ActiveChain().Height();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ static RPCHelpMan getbestblockhash()
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
return EnsureChainman(request.context).ActiveChain().Tip()->GetBlockHash().GetHex();
|
return EnsureAnyChainman(request.context).ActiveChain().Tip()->GetBlockHash().GetHex();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,7 @@ static RPCHelpMan getdifficulty()
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
return GetDifficulty(EnsureChainman(request.context).ActiveChain().Tip());
|
return GetDifficulty(EnsureAnyChainman(request.context).ActiveChain().Tip());
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -609,7 +609,7 @@ static RPCHelpMan getrawmempool()
|
||||||
include_mempool_sequence = request.params[1].get_bool();
|
include_mempool_sequence = request.params[1].get_bool();
|
||||||
}
|
}
|
||||||
|
|
||||||
return MempoolToJSON(EnsureMemPool(request.context), fVerbose, include_mempool_sequence);
|
return MempoolToJSON(EnsureAnyMemPool(request.context), fVerbose, include_mempool_sequence);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -644,7 +644,7 @@ static RPCHelpMan getmempoolancestors()
|
||||||
|
|
||||||
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
||||||
|
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
LOCK(mempool.cs);
|
LOCK(mempool.cs);
|
||||||
|
|
||||||
CTxMemPool::txiter it = mempool.mapTx.find(hash);
|
CTxMemPool::txiter it = mempool.mapTx.find(hash);
|
||||||
|
@ -708,7 +708,7 @@ static RPCHelpMan getmempooldescendants()
|
||||||
|
|
||||||
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
||||||
|
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
LOCK(mempool.cs);
|
LOCK(mempool.cs);
|
||||||
|
|
||||||
CTxMemPool::txiter it = mempool.mapTx.find(hash);
|
CTxMemPool::txiter it = mempool.mapTx.find(hash);
|
||||||
|
@ -760,7 +760,7 @@ static RPCHelpMan getmempoolentry()
|
||||||
{
|
{
|
||||||
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
||||||
|
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
LOCK(mempool.cs);
|
LOCK(mempool.cs);
|
||||||
|
|
||||||
CTxMemPool::txiter it = mempool.mapTx.find(hash);
|
CTxMemPool::txiter it = mempool.mapTx.find(hash);
|
||||||
|
@ -792,7 +792,7 @@ static RPCHelpMan getblockhash()
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
const CChain& active_chain = EnsureChainman(request.context).ActiveChain();
|
const CChain& active_chain = EnsureAnyChainman(request.context).ActiveChain();
|
||||||
|
|
||||||
int nHeight = request.params[0].get_int();
|
int nHeight = request.params[0].get_int();
|
||||||
if (nHeight < 0 || nHeight > active_chain.Height())
|
if (nHeight < 0 || nHeight > active_chain.Height())
|
||||||
|
@ -852,7 +852,7 @@ static RPCHelpMan getblockheader()
|
||||||
const CBlockIndex* tip;
|
const CBlockIndex* tip;
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
||||||
tip = chainman.ActiveChain().Tip();
|
tip = chainman.ActiveChain().Tip();
|
||||||
}
|
}
|
||||||
|
@ -977,7 +977,7 @@ static RPCHelpMan getblock()
|
||||||
const CBlockIndex* tip;
|
const CBlockIndex* tip;
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
||||||
tip = chainman.ActiveChain().Tip();
|
tip = chainman.ActiveChain().Tip();
|
||||||
|
|
||||||
|
@ -1020,7 +1020,7 @@ static RPCHelpMan pruneblockchain()
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "Cannot prune blocks because node is not in prune mode.");
|
throw JSONRPCError(RPC_MISC_ERROR, "Cannot prune blocks because node is not in prune mode.");
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
|
|
||||||
int heightParam = request.params[0].get_int();
|
int heightParam = request.params[0].get_int();
|
||||||
if (heightParam < 0)
|
if (heightParam < 0)
|
||||||
|
@ -1102,7 +1102,7 @@ static RPCHelpMan gettxoutsetinfo()
|
||||||
UniValue ret(UniValue::VOBJ);
|
UniValue ret(UniValue::VOBJ);
|
||||||
|
|
||||||
CCoinsStats stats;
|
CCoinsStats stats;
|
||||||
CChainState& active_chainstate = EnsureChainman(request.context).ActiveChainstate();
|
CChainState& active_chainstate = EnsureAnyChainman(request.context).ActiveChainstate();
|
||||||
active_chainstate.ForceFlushStateToDisk();
|
active_chainstate.ForceFlushStateToDisk();
|
||||||
|
|
||||||
const CoinStatsHashType hash_type{request.params[0].isNull() ? CoinStatsHashType::HASH_SERIALIZED : ParseHashType(request.params[0].get_str())};
|
const CoinStatsHashType hash_type{request.params[0].isNull() ? CoinStatsHashType::HASH_SERIALIZED : ParseHashType(request.params[0].get_str())};
|
||||||
|
@ -1114,7 +1114,7 @@ static RPCHelpMan gettxoutsetinfo()
|
||||||
coins_view = &active_chainstate.CoinsDB();
|
coins_view = &active_chainstate.CoinsDB();
|
||||||
blockman = &active_chainstate.m_blockman;
|
blockman = &active_chainstate.m_blockman;
|
||||||
}
|
}
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if (GetUTXOStats(coins_view, *blockman, stats, hash_type, node.rpc_interruption_point)) {
|
if (GetUTXOStats(coins_view, *blockman, stats, hash_type, node.rpc_interruption_point)) {
|
||||||
ret.pushKV("height", (int64_t)stats.nHeight);
|
ret.pushKV("height", (int64_t)stats.nHeight);
|
||||||
ret.pushKV("bestblock", stats.hashBlock.GetHex());
|
ret.pushKV("bestblock", stats.hashBlock.GetHex());
|
||||||
|
@ -1186,11 +1186,11 @@ static RPCHelpMan gettxout()
|
||||||
fMempool = request.params[2].get_bool();
|
fMempool = request.params[2].get_bool();
|
||||||
|
|
||||||
Coin coin;
|
Coin coin;
|
||||||
CChainState& active_chainstate = EnsureChainman(request.context).ActiveChainstate();
|
CChainState& active_chainstate = EnsureAnyChainman(request.context).ActiveChainstate();
|
||||||
CCoinsViewCache* coins_view = &active_chainstate.CoinsTip();
|
CCoinsViewCache* coins_view = &active_chainstate.CoinsTip();
|
||||||
|
|
||||||
if (fMempool) {
|
if (fMempool) {
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
LOCK(mempool.cs);
|
LOCK(mempool.cs);
|
||||||
CCoinsViewMemPool view(coins_view, mempool);
|
CCoinsViewMemPool view(coins_view, mempool);
|
||||||
if (!view.GetCoin(out, coin) || mempool.isSpent(out)) {
|
if (!view.GetCoin(out, coin) || mempool.isSpent(out)) {
|
||||||
|
@ -1242,7 +1242,7 @@ static RPCHelpMan verifychain()
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
CChainState& active_chainstate = EnsureChainman(request.context).ActiveChainstate();
|
CChainState& active_chainstate = EnsureAnyChainman(request.context).ActiveChainstate();
|
||||||
return CVerifyDB().VerifyDB(Params(), active_chainstate, &active_chainstate.CoinsTip(), check_level, check_depth);
|
return CVerifyDB().VerifyDB(Params(), active_chainstate, &active_chainstate.CoinsTip(), check_level, check_depth);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1370,7 +1370,7 @@ RPCHelpMan getblockchaininfo()
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
|
|
||||||
const CBlockIndex* tip = chainman.ActiveChain().Tip();
|
const CBlockIndex* tip = chainman.ActiveChain().Tip();
|
||||||
CHECK_NONFATAL(tip);
|
CHECK_NONFATAL(tip);
|
||||||
|
@ -1463,7 +1463,7 @@ static RPCHelpMan getchaintips()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1575,7 +1575,7 @@ static RPCHelpMan getmempoolinfo()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
return MempoolInfoToJSON(EnsureMemPool(request.context));
|
return MempoolInfoToJSON(EnsureAnyMemPool(request.context));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1599,7 +1599,7 @@ static RPCHelpMan preciousblock()
|
||||||
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
||||||
CBlockIndex* pblockindex;
|
CBlockIndex* pblockindex;
|
||||||
|
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
||||||
|
@ -1637,7 +1637,7 @@ static RPCHelpMan invalidateblock()
|
||||||
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
|
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
CBlockIndex* pblockindex;
|
CBlockIndex* pblockindex;
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
@ -1676,7 +1676,7 @@ static RPCHelpMan reconsiderblock()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1727,7 +1727,7 @@ static RPCHelpMan getchaintxstats()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
const CBlockIndex* pindex;
|
const CBlockIndex* pindex;
|
||||||
int blockcount = 30 * 24 * 60 * 60 / Params().GetConsensus().nPowTargetSpacing; // By default: 1 month
|
int blockcount = 30 * 24 * 60 * 60 / Params().GetConsensus().nPowTargetSpacing; // By default: 1 month
|
||||||
|
|
||||||
|
@ -1910,7 +1910,7 @@ static RPCHelpMan getblockstats()
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
|
|
||||||
CBlockIndex* pindex;
|
CBlockIndex* pindex;
|
||||||
if (request.params[0].isNum()) {
|
if (request.params[0].isNum()) {
|
||||||
|
@ -2121,7 +2121,7 @@ static RPCHelpMan savemempool()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
|
|
||||||
if (!mempool.IsLoaded()) {
|
if (!mempool.IsLoaded()) {
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
|
throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
|
||||||
|
@ -2313,14 +2313,14 @@ static RPCHelpMan scantxoutset()
|
||||||
CBlockIndex* tip;
|
CBlockIndex* tip;
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
chainman.ActiveChainstate().ForceFlushStateToDisk();
|
chainman.ActiveChainstate().ForceFlushStateToDisk();
|
||||||
pcursor = std::unique_ptr<CCoinsViewCursor>(chainman.ActiveChainstate().CoinsDB().Cursor());
|
pcursor = std::unique_ptr<CCoinsViewCursor>(chainman.ActiveChainstate().CoinsDB().Cursor());
|
||||||
CHECK_NONFATAL(pcursor);
|
CHECK_NONFATAL(pcursor);
|
||||||
tip = chainman.ActiveChain().Tip();
|
tip = chainman.ActiveChain().Tip();
|
||||||
CHECK_NONFATAL(tip);
|
CHECK_NONFATAL(tip);
|
||||||
}
|
}
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
bool res = FindScriptPubKey(g_scan_progress, g_should_abort_scan, count, pcursor.get(), needles, coins, node.rpc_interruption_point);
|
bool res = FindScriptPubKey(g_scan_progress, g_should_abort_scan, count, pcursor.get(), needles, coins, node.rpc_interruption_point);
|
||||||
result.pushKV("success", res);
|
result.pushKV("success", res);
|
||||||
result.pushKV("txouts", count);
|
result.pushKV("txouts", count);
|
||||||
|
@ -2394,7 +2394,7 @@ static RPCHelpMan getblockfilter()
|
||||||
bool block_was_connected;
|
bool block_was_connected;
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
block_index = EnsureChainman(request.context).m_blockman.LookupBlockIndex(block_hash);
|
block_index = EnsureAnyChainman(request.context).m_blockman.LookupBlockIndex(block_hash);
|
||||||
if (!block_index) {
|
if (!block_index) {
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||||
}
|
}
|
||||||
|
@ -2477,7 +2477,7 @@ static RPCHelpMan dumptxoutset()
|
||||||
|
|
||||||
FILE* file{fsbridge::fopen(temppath, "wb")};
|
FILE* file{fsbridge::fopen(temppath, "wb")};
|
||||||
CAutoFile afile{file, SER_DISK, CLIENT_VERSION};
|
CAutoFile afile{file, SER_DISK, CLIENT_VERSION};
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
UniValue result = CreateUTXOSnapshot(node, node.chainman->ActiveChainstate(), afile);
|
UniValue result = CreateUTXOSnapshot(node, node.chainman->ActiveChainstate(), afile);
|
||||||
fs::rename(temppath, path);
|
fs::rename(temppath, path);
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ static RPCHelpMan getnetworkhashps()
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
const CChain& active_chain = EnsureChainman(request.context).ActiveChain();
|
const CChain& active_chain = EnsureAnyChainman(request.context).ActiveChain();
|
||||||
return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1, active_chain);
|
return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1, active_chain);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -235,8 +235,8 @@ static RPCHelpMan generatetodescriptor()
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, error);
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
|
|
||||||
return generateBlocks(chainman, mempool, coinbase_script, num_blocks, max_tries);
|
return generateBlocks(chainman, mempool, coinbase_script, num_blocks, max_tries);
|
||||||
},
|
},
|
||||||
|
@ -280,8 +280,8 @@ static RPCHelpMan generatetoaddress()
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
|
||||||
}
|
}
|
||||||
|
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
|
|
||||||
CScript coinbase_script = GetScriptForDestination(destination);
|
CScript coinbase_script = GetScriptForDestination(destination);
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ static RPCHelpMan generateblock()
|
||||||
coinbase_script = GetScriptForDestination(destination);
|
coinbase_script = GetScriptForDestination(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
|
|
||||||
std::vector<CTransactionRef> txs;
|
std::vector<CTransactionRef> txs;
|
||||||
const auto raw_txs_or_txids = request.params[1].get_array();
|
const auto raw_txs_or_txids = request.params[1].get_array();
|
||||||
|
@ -358,7 +358,7 @@ static RPCHelpMan generateblock()
|
||||||
CChainParams chainparams(Params());
|
CChainParams chainparams(Params());
|
||||||
CBlock block;
|
CBlock block;
|
||||||
|
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
|
@ -425,8 +425,8 @@ static RPCHelpMan getmininginfo()
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
const CChain& active_chain = EnsureChainman(request.context).ActiveChain();
|
const CChain& active_chain = EnsureAnyChainman(request.context).ActiveChain();
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("blocks", (int)active_chain.Height());
|
obj.pushKV("blocks", (int)active_chain.Height());
|
||||||
|
@ -474,7 +474,7 @@ static RPCHelpMan prioritisetransaction()
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Priority is no longer supported, dummy argument to prioritisetransaction must be 0.");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Priority is no longer supported, dummy argument to prioritisetransaction must be 0.");
|
||||||
}
|
}
|
||||||
|
|
||||||
EnsureMemPool(request.context).PrioritiseTransaction(hash, nAmount);
|
EnsureAnyMemPool(request.context).PrioritiseTransaction(hash, nAmount);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -596,7 +596,7 @@ static RPCHelpMan getblocktemplate()
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
|
|
||||||
std::string strMode = "template";
|
std::string strMode = "template";
|
||||||
UniValue lpval = NullUniValue;
|
UniValue lpval = NullUniValue;
|
||||||
|
@ -663,7 +663,7 @@ static RPCHelpMan getblocktemplate()
|
||||||
if (strMode != "template")
|
if (strMode != "template")
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
||||||
|
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if(!node.connman)
|
if(!node.connman)
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
|
@ -678,7 +678,7 @@ static RPCHelpMan getblocktemplate()
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int nTransactionsUpdatedLast;
|
static unsigned int nTransactionsUpdatedLast;
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
|
|
||||||
if (!lpval.isNull())
|
if (!lpval.isNull())
|
||||||
{
|
{
|
||||||
|
@ -975,7 +975,7 @@ static RPCHelpMan submitblock()
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block does not start with a coinbase");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block does not start with a coinbase");
|
||||||
}
|
}
|
||||||
|
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
uint256 hash = block.GetHash();
|
uint256 hash = block.GetHash();
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
@ -1034,7 +1034,7 @@ static RPCHelpMan submitheader()
|
||||||
if (!DecodeHexBlockHeader(h, request.params[0].get_str())) {
|
if (!DecodeHexBlockHeader(h, request.params[0].get_str())) {
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block header decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block header decode failed");
|
||||||
}
|
}
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
if (!chainman.m_blockman.LookupBlockIndex(h.hashPrevBlock)) {
|
if (!chainman.m_blockman.LookupBlockIndex(h.hashPrevBlock)) {
|
||||||
|
@ -1092,7 +1092,7 @@ static RPCHelpMan estimatesmartfee()
|
||||||
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
|
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
|
||||||
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
|
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
|
||||||
|
|
||||||
CBlockPolicyEstimator& fee_estimator = EnsureFeeEstimator(request.context);
|
CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context);
|
||||||
|
|
||||||
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
|
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
|
||||||
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
|
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
|
||||||
|
@ -1180,7 +1180,7 @@ static RPCHelpMan estimaterawfee()
|
||||||
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true);
|
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true);
|
||||||
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
|
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
|
||||||
|
|
||||||
CBlockPolicyEstimator& fee_estimator = EnsureFeeEstimator(request.context);
|
CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context);
|
||||||
|
|
||||||
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
|
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
|
||||||
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
|
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
|
||||||
|
|
|
@ -53,7 +53,7 @@ static RPCHelpMan getconnectioncount()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if(!node.connman)
|
if(!node.connman)
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ static RPCHelpMan ping()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if (!node.peerman) {
|
if (!node.peerman) {
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ static RPCHelpMan getpeerinfo()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if(!node.connman || !node.peerman) {
|
if(!node.connman || !node.peerman) {
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ static RPCHelpMan addnode()
|
||||||
self.ToString());
|
self.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if(!node.connman)
|
if(!node.connman)
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ static RPCHelpMan addconnection()
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, self.ToString());
|
throw JSONRPCError(RPC_INVALID_PARAMETER, self.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if (!node.connman) {
|
if (!node.connman) {
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled.");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled.");
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ static RPCHelpMan disconnectnode()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if(!node.connman)
|
if(!node.connman)
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ static RPCHelpMan getaddednodeinfo()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if(!node.connman)
|
if(!node.connman)
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ static RPCHelpMan getnettotals()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if(!node.connman)
|
if(!node.connman)
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
|
@ -618,7 +618,7 @@ static RPCHelpMan getnetworkinfo()
|
||||||
obj.pushKV("version", CLIENT_VERSION);
|
obj.pushKV("version", CLIENT_VERSION);
|
||||||
obj.pushKV("subversion", strSubVersion);
|
obj.pushKV("subversion", strSubVersion);
|
||||||
obj.pushKV("protocolversion",PROTOCOL_VERSION);
|
obj.pushKV("protocolversion",PROTOCOL_VERSION);
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if (node.connman) {
|
if (node.connman) {
|
||||||
ServiceFlags services = node.connman->GetLocalServices();
|
ServiceFlags services = node.connman->GetLocalServices();
|
||||||
obj.pushKV("localservices", strprintf("%016x", services));
|
obj.pushKV("localservices", strprintf("%016x", services));
|
||||||
|
@ -680,7 +680,7 @@ static RPCHelpMan setban()
|
||||||
if (strCommand != "add" && strCommand != "remove") {
|
if (strCommand != "add" && strCommand != "remove") {
|
||||||
throw std::runtime_error(help.ToString());
|
throw std::runtime_error(help.ToString());
|
||||||
}
|
}
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if (!node.banman) {
|
if (!node.banman) {
|
||||||
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
||||||
}
|
}
|
||||||
|
@ -760,7 +760,7 @@ static RPCHelpMan listbanned()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if(!node.banman) {
|
if(!node.banman) {
|
||||||
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
||||||
}
|
}
|
||||||
|
@ -797,7 +797,7 @@ static RPCHelpMan clearbanned()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if (!node.banman) {
|
if (!node.banman) {
|
||||||
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
||||||
}
|
}
|
||||||
|
@ -820,7 +820,7 @@ static RPCHelpMan setnetworkactive()
|
||||||
RPCExamples{""},
|
RPCExamples{""},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if (!node.connman) {
|
if (!node.connman) {
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
}
|
}
|
||||||
|
@ -857,7 +857,7 @@ static RPCHelpMan getnodeaddresses()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if (!node.connman) {
|
if (!node.connman) {
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
}
|
}
|
||||||
|
@ -906,7 +906,7 @@ static RPCHelpMan addpeeraddress()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
if (!node.addrman) {
|
if (!node.addrman) {
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Address manager functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Address manager functionality missing or disabled");
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,8 +157,8 @@ static RPCHelpMan getrawtransaction()
|
||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
const NodeContext& node = EnsureNodeContext(request.context);
|
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
|
|
||||||
bool in_active_chain = true;
|
bool in_active_chain = true;
|
||||||
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
||||||
|
@ -258,7 +258,7 @@ static RPCHelpMan gettxoutproof()
|
||||||
|
|
||||||
CBlockIndex* pblockindex = nullptr;
|
CBlockIndex* pblockindex = nullptr;
|
||||||
uint256 hashBlock;
|
uint256 hashBlock;
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
if (!request.params[1].isNull()) {
|
if (!request.params[1].isNull()) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
hashBlock = ParseHashV(request.params[1], "blockhash");
|
hashBlock = ParseHashV(request.params[1], "blockhash");
|
||||||
|
@ -352,7 +352,7 @@ static RPCHelpMan verifytxoutproof()
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
ChainstateManager& chainman = EnsureChainman(request.context);
|
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||||
const CBlockIndex* pindex = chainman.m_blockman.LookupBlockIndex(merkleBlock.header.GetHash());
|
const CBlockIndex* pindex = chainman.m_blockman.LookupBlockIndex(merkleBlock.header.GetHash());
|
||||||
if (!pindex || !chainman.ActiveChain().Contains(pindex) || pindex->nTx == 0) {
|
if (!pindex || !chainman.ActiveChain().Contains(pindex) || pindex->nTx == 0) {
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
|
||||||
|
@ -678,10 +678,10 @@ static RPCHelpMan combinerawtransaction()
|
||||||
CCoinsView viewDummy;
|
CCoinsView viewDummy;
|
||||||
CCoinsViewCache view(&viewDummy);
|
CCoinsViewCache view(&viewDummy);
|
||||||
{
|
{
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
LOCK(mempool.cs);
|
LOCK(mempool.cs);
|
||||||
CCoinsViewCache &viewChain = EnsureChainman(request.context).ActiveChainstate().CoinsTip();
|
CCoinsViewCache &viewChain = EnsureAnyChainman(request.context).ActiveChainstate().CoinsTip();
|
||||||
CCoinsViewMemPool viewMempool(&viewChain, mempool);
|
CCoinsViewMemPool viewMempool(&viewChain, mempool);
|
||||||
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
|
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
|
||||||
|
|
||||||
|
@ -805,7 +805,7 @@ static RPCHelpMan signrawtransactionwithkey()
|
||||||
for (const CTxIn& txin : mtx.vin) {
|
for (const CTxIn& txin : mtx.vin) {
|
||||||
coins[txin.prevout]; // Create empty map entry keyed by prevout.
|
coins[txin.prevout]; // Create empty map entry keyed by prevout.
|
||||||
}
|
}
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
FindCoins(node, coins);
|
FindCoins(node, coins);
|
||||||
|
|
||||||
// Parse the prevtxs array
|
// Parse the prevtxs array
|
||||||
|
@ -868,7 +868,7 @@ static RPCHelpMan sendrawtransaction()
|
||||||
|
|
||||||
std::string err_string;
|
std::string err_string;
|
||||||
AssertLockNotHeld(cs_main);
|
AssertLockNotHeld(cs_main);
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
const TransactionError err = BroadcastTransaction(node, tx, err_string, max_raw_tx_fee, /*relay*/ true, /*wait_callback*/ true);
|
const TransactionError err = BroadcastTransaction(node, tx, err_string, max_raw_tx_fee, /*relay*/ true, /*wait_callback*/ true);
|
||||||
if (TransactionError::OK != err) {
|
if (TransactionError::OK != err) {
|
||||||
throw JSONRPCTransactionError(err, err_string);
|
throw JSONRPCTransactionError(err, err_string);
|
||||||
|
@ -943,7 +943,7 @@ static RPCHelpMan testmempoolaccept()
|
||||||
DEFAULT_MAX_RAW_TX_FEE_RATE :
|
DEFAULT_MAX_RAW_TX_FEE_RATE :
|
||||||
CFeeRate(AmountFromValue(request.params[1]));
|
CFeeRate(AmountFromValue(request.params[1]));
|
||||||
|
|
||||||
CTxMemPool& mempool = EnsureMemPool(request.context);
|
CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
int64_t virtual_size = GetVirtualTransactionSize(*tx);
|
int64_t virtual_size = GetVirtualTransactionSize(*tx);
|
||||||
CAmount max_raw_tx_fee = max_raw_tx_fee_rate.GetFee(virtual_size);
|
CAmount max_raw_tx_fee = max_raw_tx_fee_rate.GetFee(virtual_size);
|
||||||
|
|
||||||
|
@ -952,7 +952,7 @@ static RPCHelpMan testmempoolaccept()
|
||||||
result_0.pushKV("txid", tx->GetHash().GetHex());
|
result_0.pushKV("txid", tx->GetHash().GetHex());
|
||||||
result_0.pushKV("wtxid", tx->GetWitnessHash().GetHex());
|
result_0.pushKV("wtxid", tx->GetWitnessHash().GetHex());
|
||||||
|
|
||||||
const MempoolAcceptResult accept_result = WITH_LOCK(cs_main, return AcceptToMemoryPool(EnsureChainman(request.context).ActiveChainstate(), mempool, std::move(tx),
|
const MempoolAcceptResult accept_result = WITH_LOCK(cs_main, return AcceptToMemoryPool(EnsureAnyChainman(request.context).ActiveChainstate(), mempool, std::move(tx),
|
||||||
false /* bypass_limits */, /* test_accept */ true));
|
false /* bypass_limits */, /* test_accept */ true));
|
||||||
|
|
||||||
// Only return the fee and vsize if the transaction would pass ATMP.
|
// Only return the fee and vsize if the transaction would pass ATMP.
|
||||||
|
@ -1601,9 +1601,9 @@ static RPCHelpMan utxoupdatepsbt()
|
||||||
CCoinsView viewDummy;
|
CCoinsView viewDummy;
|
||||||
CCoinsViewCache view(&viewDummy);
|
CCoinsViewCache view(&viewDummy);
|
||||||
{
|
{
|
||||||
const CTxMemPool& mempool = EnsureMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
LOCK2(cs_main, mempool.cs);
|
LOCK2(cs_main, mempool.cs);
|
||||||
CCoinsViewCache &viewChain = EnsureChainman(request.context).ActiveChainstate().CoinsTip();
|
CCoinsViewCache &viewChain = EnsureAnyChainman(request.context).ActiveChainstate().CoinsTip();
|
||||||
CCoinsViewMemPool viewMempool(&viewChain, mempool);
|
CCoinsViewMemPool viewMempool(&viewChain, mempool);
|
||||||
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
|
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue