diff options
author | Daniel Kraft <d@domob.eu> | 2015-08-18 09:07:33 +0200 |
---|---|---|
committer | Daniel Kraft <d@domob.eu> | 2015-08-18 09:07:33 +0200 |
commit | 20165769989ed5aa744af2b73dfcf9d5a5cf7aa0 (patch) | |
tree | 56692e75f44ad30ef55eaa42764e46f0643b35b1 /src/rpcmining.cpp | |
parent | 1e92b275406e3fbc7ab59d2ada1c882ca15fb36f (diff) |
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.
Diffstat (limited to 'src/rpcmining.cpp')
-rw-r--r-- | src/rpcmining.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index b7d4ff58fc..620a46be15 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -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 |