Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Skip header sig check on regtest, enable generatetoaddress
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptAxe committed Feb 6, 2024
1 parent 994aba9 commit 7651f5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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"} },

Expand Down
5 changes: 3 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit 7651f5f

Please sign in to comment.