aboutsummaryrefslogtreecommitdiff
path: root/src/rpcmining.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2015-08-19 15:02:40 +0200
committerWladimir J. van der Laan <[email protected]>2015-08-19 15:07:38 +0200
commit0f0f323c9a58437b33ba4fa9a67e1edf5fc6cc88 (patch)
tree56692e75f44ad30ef55eaa42764e46f0643b35b1 /src/rpcmining.cpp
parentMerge pull request #6553 (diff)
parentFix crash when mining with empty keypool. (diff)
downloaddiscoin-0f0f323c9a58437b33ba4fa9a67e1edf5fc6cc88.tar.xz
discoin-0f0f323c9a58437b33ba4fa9a67e1edf5fc6cc88.zip
Merge pull request #6567
2016576 Fix crash when mining with empty keypool. (Daniel Kraft)
Diffstat (limited to 'src/rpcmining.cpp')
-rw-r--r--src/rpcmining.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index b7d4ff58f..620a46be1 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