mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Fix crash when mining with empty keypool.
Since the introduction of the ScriptForMining callback, the mining functions (setgenerate and generate) crash with an assertion failure (due to a NULL pointer script returned) if the keypool is empty. Fix this by giving a proper error.
This commit is contained in:
@@ -138,8 +138,12 @@ UniValue generate(const UniValue& params, bool fHelp)
|
||||
boost::shared_ptr<CReserveScript> coinbaseScript;
|
||||
GetMainSignals().ScriptForMining(coinbaseScript);
|
||||
|
||||
// If the keypool is exhausted, no script is returned at all. Catch this.
|
||||
if (!coinbaseScript)
|
||||
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
|
||||
|
||||
//throw an error if no script was provided
|
||||
if (!coinbaseScript->reserveScript.size())
|
||||
if (coinbaseScript->reserveScript.empty())
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "No coinbase script available (mining requires a wallet)");
|
||||
|
||||
{ // Don't keep cs_main locked
|
||||
|
||||
Reference in New Issue
Block a user