fix example.
This commit is contained in:
parent
5150a64e90
commit
a5ba554c1f
11
README.md
11
README.md
@ -8,9 +8,6 @@ making all useful bitcoind functions asynchronous.
|
|||||||
|
|
||||||
### bitcoind
|
### bitcoind
|
||||||
|
|
||||||
- NOTE (to self): Arch is using bitcoin-daemon 0.9.2.1, the latest boost headers
|
|
||||||
in Arch should be correct.
|
|
||||||
|
|
||||||
Cloning libbitcoind:
|
Cloning libbitcoind:
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
@ -28,11 +25,13 @@ bitcoind as a shared object. This may not be ideal yet.
|
|||||||
|
|
||||||
- Boost
|
- Boost
|
||||||
- Bost Header Files (`/usr/include/boost`)
|
- Bost Header Files (`/usr/include/boost`)
|
||||||
|
- NOTE: These are now included in the repo if they're not present.
|
||||||
|
|
||||||
- Berkeley DB
|
- Berkeley DB
|
||||||
|
|
||||||
- LevelDB Header Files (included in bitcoin source repo, leveldb itself
|
- LevelDB Header Files (included in bitcoin source repo, leveldb itself
|
||||||
unnecessary, libbitcoind.so is already linked to them)
|
unnecessary, libbitcoind.so is already linked to them)
|
||||||
|
- NOTE: These also are now included in the repo if they're not present.
|
||||||
|
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
@ -47,7 +46,7 @@ $ ./autogen.sh
|
|||||||
# use --with-incompatible-bdb if necessary
|
# use --with-incompatible-bdb if necessary
|
||||||
# use --prefix=/usr if necessary
|
# use --prefix=/usr if necessary
|
||||||
# osx users may have to specify a boost path
|
# osx users may have to specify a boost path
|
||||||
$ ./configure --enable-daemonlib
|
$ ./configure --enable-daemonlib --with-incompatible-bdb
|
||||||
|
|
||||||
# build libbitcoind.so
|
# build libbitcoind.so
|
||||||
$ time make
|
$ time make
|
||||||
@ -97,7 +96,9 @@ $ tail -f ~/.bitcoin/debug.log
|
|||||||
bitcoind.js has direct access to the global wallet:
|
bitcoind.js has direct access to the global wallet:
|
||||||
|
|
||||||
``` js
|
``` js
|
||||||
var bitcoind = require('bitcoind.js')();
|
var bitcoind = require('bitcoind.js')({
|
||||||
|
directory: '~/.libbitcoin-test'
|
||||||
|
});
|
||||||
bitcoind.on('open', function() {
|
bitcoind.on('open', function() {
|
||||||
console.log(bitcoind.wallet.listAccounts());
|
console.log(bitcoind.wallet.listAccounts());
|
||||||
});
|
});
|
||||||
|
|||||||
@ -290,6 +290,7 @@ static volatile bool shutdown_complete = false;
|
|||||||
static int block_poll_top_height = -1;
|
static int block_poll_top_height = -1;
|
||||||
static char *g_data_dir = NULL;
|
static char *g_data_dir = NULL;
|
||||||
static bool g_rpc = false;
|
static bool g_rpc = false;
|
||||||
|
static bool g_testnet = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Structs
|
* Private Structs
|
||||||
@ -306,6 +307,7 @@ struct async_node_data {
|
|||||||
std::string result;
|
std::string result;
|
||||||
std::string datadir;
|
std::string datadir;
|
||||||
bool rpc;
|
bool rpc;
|
||||||
|
bool testnet;
|
||||||
Persistent<Function> callback;
|
Persistent<Function> callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -433,6 +435,7 @@ NAN_METHOD(StartBitcoind) {
|
|||||||
Local<Function> callback;
|
Local<Function> callback;
|
||||||
std::string datadir = std::string("");
|
std::string datadir = std::string("");
|
||||||
bool rpc = false;
|
bool rpc = false;
|
||||||
|
bool testnet = false;
|
||||||
|
|
||||||
if (args.Length() >= 2 && args[0]->IsObject() && args[1]->IsFunction()) {
|
if (args.Length() >= 2 && args[0]->IsObject() && args[1]->IsFunction()) {
|
||||||
Local<Object> options = Local<Object>::Cast(args[0]);
|
Local<Object> options = Local<Object>::Cast(args[0]);
|
||||||
@ -443,6 +446,9 @@ NAN_METHOD(StartBitcoind) {
|
|||||||
if (options->Get(NanNew<String>("rpc"))->IsBoolean()) {
|
if (options->Get(NanNew<String>("rpc"))->IsBoolean()) {
|
||||||
rpc = options->Get(NanNew<String>("rpc"))->ToBoolean()->IsTrue();
|
rpc = options->Get(NanNew<String>("rpc"))->ToBoolean()->IsTrue();
|
||||||
}
|
}
|
||||||
|
if (options->Get(NanNew<String>("testnet"))->IsBoolean()) {
|
||||||
|
testnet = options->Get(NanNew<String>("testnet"))->ToBoolean()->IsTrue();
|
||||||
|
}
|
||||||
callback = Local<Function>::Cast(args[1]);
|
callback = Local<Function>::Cast(args[1]);
|
||||||
} else if (args.Length() >= 2
|
} else if (args.Length() >= 2
|
||||||
&& (args[0]->IsUndefined() || args[0]->IsNull())
|
&& (args[0]->IsUndefined() || args[0]->IsNull())
|
||||||
@ -463,6 +469,7 @@ NAN_METHOD(StartBitcoind) {
|
|||||||
data->err_msg = std::string("");
|
data->err_msg = std::string("");
|
||||||
data->result = std::string("");
|
data->result = std::string("");
|
||||||
data->datadir = datadir;
|
data->datadir = datadir;
|
||||||
|
data->testnet = testnet;
|
||||||
data->rpc = rpc;
|
data->rpc = rpc;
|
||||||
data->callback = Persistent<Function>::New(callback);
|
data->callback = Persistent<Function>::New(callback);
|
||||||
|
|
||||||
@ -490,6 +497,7 @@ async_start_node(uv_work_t *req) {
|
|||||||
g_data_dir = (char *)data->datadir.c_str();
|
g_data_dir = (char *)data->datadir.c_str();
|
||||||
}
|
}
|
||||||
g_rpc = (bool)data->rpc;
|
g_rpc = (bool)data->rpc;
|
||||||
|
g_testnet = (bool)data->testnet;
|
||||||
start_node();
|
start_node();
|
||||||
data->result = std::string("start_node(): bitcoind opened.");
|
data->result = std::string("start_node(): bitcoind opened.");
|
||||||
}
|
}
|
||||||
@ -596,6 +604,11 @@ start_node_thread(void) {
|
|||||||
argc++;
|
argc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_testnet) {
|
||||||
|
argv[argc] = (char *)"-testnet";
|
||||||
|
argc++;
|
||||||
|
}
|
||||||
|
|
||||||
argv[argc] = NULL;
|
argv[argc] = NULL;
|
||||||
|
|
||||||
bool fRet = false;
|
bool fRet = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user