mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user