From 7651f5f0191aa3af6b1380a704942f00b858c8b3 Mon Sep 17 00:00:00 2001 From: CryptAxe Date: Tue, 6 Feb 2024 14:28:17 -0800 Subject: [PATCH] Skip header sig check on regtest, enable generatetoaddress --- src/rpc/mining.cpp | 5 +++++ src/validation.cpp | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index bad191b53..66b48bf48 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -136,6 +136,9 @@ UniValue generatetoaddress(const JSONRPCRequest& request) + HelpExampleCli("generatetoaddress", "11 \"myaddress\"") ); + if (Params().NetworkIDString() != "regtest") + throw JSONRPCError(RPC_MISC_ERROR, "Error: Only use this function in regtest mode!"); + int nGenerate = request.params[0].get_int(); uint64_t nMaxTries = 1000000; if (!request.params[2].isNull()) { @@ -950,6 +953,8 @@ static const CRPCCommand commands[] = { "mining", "getblocktemplate", &getblocktemplate, {"template_request"} }, { "mining", "submitblock", &submitblock, {"hexdata","dummy"} }, + { "hidden", "generatetoaddress", &generatetoaddress, {"nblocks","address","maxtries"} }, + { "hidden", "estimatefee", &estimatefee, {} }, { "util", "estimatesmartfee", &estimatesmartfee, {"conf_target", "estimate_mode"} }, diff --git a/src/validation.cpp b/src/validation.cpp index 5a0310e12..b324f2cbe 100755 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3375,8 +3375,9 @@ static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, consensusParams)) return state.DoS(50, false, REJECT_INVALID, "high-hash", false, "proof of work failed"); - // Check header signature - if (fCheckPOW && block.GetHash() != Params().GetConsensus().hashGenesisBlock) { + // Check header signature except on genesis blocks and regtest mode + if (block.GetHash() != consensusParams.hashGenesisBlock && fCheckPOW && + Params().NetworkIDString() != "regtest") { if (!VerifyHeaderSig(block)) return state.DoS(50, false, REJECT_INVALID, "header-signature", false, "invalid header signature"); }