From 10aef460503272dcd46181bdf00de6429500ae30 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 11 Nov 2014 13:36:08 -0800 Subject: [PATCH] default datadir=.bitcoind.js --- lib/bitcoind.js | 14 +++++++------- src/bitcoindjs.cc | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/bitcoind.js b/lib/bitcoind.js index e45e2f1d..be51a52c 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -44,17 +44,17 @@ function Bitcoin(options) { } if (!this.options.datadir) { - this.options.datadir = process.env.HOME + '/.bitcoin'; + this.options.datadir = '~/.bitcoind.js'; } this.options.datadir = this.options.datadir.replace(/^~/, process.env.HOME); - this.config = this.options.datadir + '/bitcoin.conf'; - + this.datadir = this.options.datadir; + this.config = this.datadir + '/bitcoin.conf'; this.network = Bitcoin[this.options.testnet ? 'testnet' : 'livenet']; - if (!fs.existsSync(this.options.datadir)) { - mkdirp.sync(this.options.datadir); + if (!fs.existsSync(this.datadir)) { + mkdirp.sync(this.datadir); } if (!fs.existsSync(this.config)) { @@ -154,10 +154,10 @@ Bitcoin.prototype.start = function(options, callback) { callback = utils.NOOP; } - if (this.instances[this.options.datadir]) { + if (this.instances[this.datadir]) { return; } - this.instances[this.options.datadir] = true; + this.instances[this.datadir] = true; var none = {}; var isSignal = {}; diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index d19b7ad2..63e94583 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -657,6 +657,9 @@ async_start_node(uv_work_t *req) { async_node_data *data = static_cast(req->data); if (data->datadir != "") { g_data_dir = (char *)data->datadir.c_str(); + } else { + g_data_dir = (char *)malloc(sizeof(char) * 512); + snprintf(g_data_dir, sizeof(char) * 512, "%s/.bitcoind.js", getenv("HOME")); } g_rpc = (bool)data->rpc; g_testnet = (bool)data->testnet;