aboutsummaryrefslogtreecommitdiff
path: root/src/rpcmining.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2013-08-25 00:00:02 -0400
committerJeff Garzik <jgarzik@bitpay.com>2013-10-01 16:14:37 -0400
commitb0730874d95e42953736f49d8041221d698ed95a (patch)
treedb3e8841f61b5efccfbc1b4bc2a0b99380a64ce0 /src/rpcmining.cpp
parent19c415b1cf0dc4fd5fe08e8e7e146c7996261170 (diff)
Support absence of wallet (pwalletMain==NULL) in several locations,
notably RPC.
Diffstat (limited to 'src/rpcmining.cpp')
-rw-r--r--src/rpcmining.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 2b7a5e38c3..b013b4b200 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -18,12 +18,18 @@ static CReserveKey* pMiningKey = NULL;
void InitRPCMining()
{
+ if (!pwalletMain)
+ return;
+
// getwork/getblocktemplate mining rewards paid here:
pMiningKey = new CReserveKey(pwalletMain);
}
void ShutdownRPCMining()
{
+ if (!pMiningKey)
+ return;
+
delete pMiningKey; pMiningKey = NULL;
}
@@ -87,6 +93,9 @@ Value getgenerate(const Array& params, bool fHelp)
"getgenerate\n"
"Returns true or false.");
+ if (!pMiningKey)
+ return false;
+
return GetBoolArg("-gen", false);
}
@@ -112,6 +121,7 @@ Value setgenerate(const Array& params, bool fHelp)
}
mapArgs["-gen"] = (fGenerate ? "1" : "0");
+ assert(pwalletMain != NULL);
GenerateBitcoins(fGenerate, pwalletMain);
return Value::null;
}
@@ -143,7 +153,7 @@ Value getmininginfo(const Array& params, bool fHelp)
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
- obj.push_back(Pair("generate", GetBoolArg("-gen", false)));
+ obj.push_back(Pair("generate", getgenerate(params, false)));
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
@@ -261,6 +271,7 @@ Value getwork(const Array& params, bool fHelp)
pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second;
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
+ assert(pwalletMain != NULL);
return CheckWork(pblock, *pwalletMain, *pMiningKey);
}
}