Support absence of wallet (pwalletMain==NULL) in several locations,
notably RPC.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user