mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
qt: allow walletpassphrase in debug console without -server
Currently it is only possible to use `walletpassphrase` to unlock the wallet when bitcoin is started in server mode. Almost everything that manipulates the wallet in the RPC console needs the wallet to be unlocked and is thus unusable without -server. This is pretty unintuitive to me, and I'm sure it's even more confusing to users. Solve this with a very minimal change: by making the GUI start a dummy RPC thread just to handle timeouts.
This commit is contained in:
@@ -38,6 +38,7 @@ static asio::io_service* rpc_io_service = NULL;
|
||||
static map<string, boost::shared_ptr<deadline_timer> > deadlineTimers;
|
||||
static ssl::context* rpc_ssl_context = NULL;
|
||||
static boost::thread_group* rpc_worker_group = NULL;
|
||||
static boost::asio::io_service::work *rpc_dummy_work = NULL;
|
||||
|
||||
void RPCTypeCheck(const Array& params,
|
||||
const list<Value_type>& typesExpected,
|
||||
@@ -607,6 +608,19 @@ void StartRPCThreads()
|
||||
rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service));
|
||||
}
|
||||
|
||||
void StartDummyRPCThread()
|
||||
{
|
||||
if(rpc_io_service == NULL)
|
||||
{
|
||||
rpc_io_service = new asio::io_service();
|
||||
/* Create dummy "work" to keep the thread from exiting when no timeouts active,
|
||||
* see http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/reference/io_service.html#boost_asio.reference.io_service.stopping_the_io_service_from_running_out_of_work */
|
||||
rpc_dummy_work = new asio::io_service::work(*rpc_io_service);
|
||||
rpc_worker_group = new boost::thread_group();
|
||||
rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service));
|
||||
}
|
||||
}
|
||||
|
||||
void StopRPCThreads()
|
||||
{
|
||||
if (rpc_io_service == NULL) return;
|
||||
@@ -615,6 +629,7 @@ void StopRPCThreads()
|
||||
rpc_io_service->stop();
|
||||
if (rpc_worker_group != NULL)
|
||||
rpc_worker_group->join_all();
|
||||
delete rpc_dummy_work; rpc_dummy_work = NULL;
|
||||
delete rpc_worker_group; rpc_worker_group = NULL;
|
||||
delete rpc_ssl_context; rpc_ssl_context = NULL;
|
||||
delete rpc_io_service; rpc_io_service = NULL;
|
||||
|
||||
Reference in New Issue
Block a user