Skip to content

Commit

Permalink
RPC: Limit generate command to regtest
Browse files Browse the repository at this point in the history
It doesn't make sense on other networks; closes #191
  • Loading branch information
mjmacleod committed Apr 11, 2020
1 parent 6b4d26a commit 001d2dc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ static UniValue generate(const JSONRPCRequest& request)
+ HelpExampleCli("generate", "11")
);

if (!IsArgSet("-regtest"))
throw std::runtime_error("generate command only for regtest; for mainnet/testnet use setgenerate");

int nGenerate = request.params[0].get_int();
uint64_t nMaxTries = 1000000;
if (request.params.size() > 1) {
Expand Down Expand Up @@ -475,6 +478,9 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
+ HelpExampleCli("generatetoaddress", "11 \"myaddress\"")
);

if (!IsArgSet("-regtest"))
throw std::runtime_error("generatetoaddress command only for regtest; for mainnet/testnet use setgenerate");

int nGenerate = request.params[0].get_int();
uint64_t nMaxTries = 1000000;
if (request.params.size() > 2) {
Expand Down

0 comments on commit 001d2dc

Please sign in to comment.