From a5ba554c1f214fed067cef354d25c7d49ee99d05 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 20 Oct 2014 09:38:35 -0700 Subject: [PATCH] fix example. --- README.md | 11 ++++++----- src/bitcoindjs.cc | 13 +++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 68994546..04728824 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,6 @@ making all useful bitcoind functions asynchronous. ### bitcoind -- NOTE (to self): Arch is using bitcoin-daemon 0.9.2.1, the latest boost headers - in Arch should be correct. - Cloning libbitcoind: ``` bash @@ -28,11 +25,13 @@ bitcoind as a shared object. This may not be ideal yet. - Boost - Bost Header Files (`/usr/include/boost`) + - NOTE: These are now included in the repo if they're not present. - Berkeley DB - LevelDB Header Files (included in bitcoin source repo, leveldb itself unnecessary, libbitcoind.so is already linked to them) + - NOTE: These also are now included in the repo if they're not present. ``` bash @@ -47,7 +46,7 @@ $ ./autogen.sh # use --with-incompatible-bdb if necessary # use --prefix=/usr if necessary # osx users may have to specify a boost path -$ ./configure --enable-daemonlib +$ ./configure --enable-daemonlib --with-incompatible-bdb # build libbitcoind.so $ time make @@ -97,7 +96,9 @@ $ tail -f ~/.bitcoin/debug.log bitcoind.js has direct access to the global wallet: ``` js -var bitcoind = require('bitcoind.js')(); +var bitcoind = require('bitcoind.js')({ + directory: '~/.libbitcoin-test' +}); bitcoind.on('open', function() { console.log(bitcoind.wallet.listAccounts()); }); diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index f6291bbe..31f83a0a 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -290,6 +290,7 @@ static volatile bool shutdown_complete = false; static int block_poll_top_height = -1; static char *g_data_dir = NULL; static bool g_rpc = false; +static bool g_testnet = false; /** * Private Structs @@ -306,6 +307,7 @@ struct async_node_data { std::string result; std::string datadir; bool rpc; + bool testnet; Persistent callback; }; @@ -433,6 +435,7 @@ NAN_METHOD(StartBitcoind) { Local callback; std::string datadir = std::string(""); bool rpc = false; + bool testnet = false; if (args.Length() >= 2 && args[0]->IsObject() && args[1]->IsFunction()) { Local options = Local::Cast(args[0]); @@ -443,6 +446,9 @@ NAN_METHOD(StartBitcoind) { if (options->Get(NanNew("rpc"))->IsBoolean()) { rpc = options->Get(NanNew("rpc"))->ToBoolean()->IsTrue(); } + if (options->Get(NanNew("testnet"))->IsBoolean()) { + testnet = options->Get(NanNew("testnet"))->ToBoolean()->IsTrue(); + } callback = Local::Cast(args[1]); } else if (args.Length() >= 2 && (args[0]->IsUndefined() || args[0]->IsNull()) @@ -463,6 +469,7 @@ NAN_METHOD(StartBitcoind) { data->err_msg = std::string(""); data->result = std::string(""); data->datadir = datadir; + data->testnet = testnet; data->rpc = rpc; data->callback = Persistent::New(callback); @@ -490,6 +497,7 @@ async_start_node(uv_work_t *req) { g_data_dir = (char *)data->datadir.c_str(); } g_rpc = (bool)data->rpc; + g_testnet = (bool)data->testnet; start_node(); data->result = std::string("start_node(): bitcoind opened."); } @@ -596,6 +604,11 @@ start_node_thread(void) { argc++; } + if (g_testnet) { + argv[argc] = (char *)"-testnet"; + argc++; + } + argv[argc] = NULL; bool fRet = false;