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/miner.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/miner.cpp')
-rw-r--r-- | src/miner.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/miner.cpp b/src/miner.cpp index 4172266067..9dd1d459b5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -444,8 +444,10 @@ void static BitcoinMiner(const CChainParams& chainparams) GetMainSignals().ScriptForMining(coinbaseScript); try { - //throw an error if no script was provided - if (!coinbaseScript->reserveScript.size()) + // Throw an error if no script was provided. This can happen + // due to some internal error but also if the keypool is empty. + // In the latter case, already the pointer is NULL. + if (!coinbaseScript || coinbaseScript->reserveScript.empty()) throw std::runtime_error("No coinbase script available (mining requires a wallet)"); while (true) { |