aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2023-10-15 16:34:15 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2023-10-16 17:20:59 +0200
commit9620cb449374f234f72c1a9e1bae3d4b8c0ff171 (patch)
tree306f320661c1bbf69f9938187151bee708d0ade2 /src
parent78b7e955185ab92de4e1b8b866a46d3113a5fdf5 (diff)
assumeutxo: fail early if snapshot block hash doesn't match AssumeUTXO parameters
Diffstat (limited to 'src')
-rw-r--r--src/rpc/blockchain.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 37a28e414a..51d0879b12 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -2737,6 +2737,7 @@ static RPCHelpMan loadtxoutset()
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
NodeContext& node = EnsureAnyNodeContext(request.context);
+ ChainstateManager& chainman = EnsureChainman(node);
fs::path path{AbsPathForConfigVal(EnsureArgsman(node), fs::u8path(request.params[0].get_str()))};
FILE* file{fsbridge::fopen(path, "rb")};
@@ -2751,14 +2752,16 @@ static RPCHelpMan loadtxoutset()
afile >> metadata;
uint256 base_blockhash = metadata.m_base_blockhash;
+ if (!chainman.GetParams().AssumeutxoForBlockhash(base_blockhash).has_value()) {
+ throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf("Unable to load UTXO snapshot, "
+ "assumeutxo block hash in snapshot metadata not recognized (%s)", base_blockhash.ToString()));
+ }
int max_secs_to_wait_for_headers = 60 * 10;
CBlockIndex* snapshot_start_block = nullptr;
LogPrintf("[snapshot] waiting to see blockheader %s in headers chain before snapshot activation\n",
base_blockhash.ToString());
- ChainstateManager& chainman = EnsureChainman(node);
-
while (max_secs_to_wait_for_headers > 0) {
snapshot_start_block = WITH_LOCK(::cs_main,
return chainman.m_blockman.LookupBlockIndex(base_blockhash));