aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoinrpc.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-05-23 14:13:05 -0400
committerGavin Andresen <gavinandresen@gmail.com>2013-05-23 14:17:15 -0400
commit36e826cea14585f68d5c363a82c1a887a779e130 (patch)
tree18fd48ebecaf4657faaf02864e6cec36bad3cb76 /src/bitcoinrpc.cpp
parent36dc41f4273c59e570978c603e48bbec43f3d0a1 (diff)
downloadbitcoin-36e826cea14585f68d5c363a82c1a887a779e130.tar.xz
Clean up mining CReserveKey to prevent crash at shutdown
Fixes issue#2687
Diffstat (limited to 'src/bitcoinrpc.cpp')
-rw-r--r--src/bitcoinrpc.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index a9b73fd5a6..2c4744a579 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -30,6 +30,10 @@ using namespace boost;
using namespace boost::asio;
using namespace json_spirit;
+// Key used by getwork/getblocktemplate miners.
+// Allocated in StartRPCThreads, free'd in StopRPCThreads
+CReserveKey* pMiningKey = NULL;
+
static std::string strRPCUserColonPass;
// These are created by StartRPCThreads, destroyed in StopRPCThreads
@@ -722,6 +726,9 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol,
void StartRPCThreads()
{
+ // getwork/getblocktemplate mining rewards paid here:
+ pMiningKey = new CReserveKey(pwalletMain);
+
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"];
if ((mapArgs["-rpcpassword"] == "") ||
(mapArgs["-rpcuser"] == mapArgs["-rpcpassword"]))
@@ -841,6 +848,8 @@ void StartRPCThreads()
void StopRPCThreads()
{
+ delete pMiningKey; pMiningKey = NULL;
+
if (rpc_io_service == NULL) return;
rpc_io_service->stop();