bitcore-node-zcash/README.md

141 lines
3.6 KiB
Markdown
Raw Normal View History

2014-08-12 12:03:04 -07:00
# bitcoind.js
2014-08-20 14:51:07 -07:00
Bitcoind as a node.js module.
## Building
2014-09-11 17:18:36 -07:00
### bitcoind
2014-08-20 14:51:07 -07:00
- NOTE (to self): Arch is using bitcoin-daemon 0.9.2.1, the latest boost headers
in Arch should be correct.
2014-09-11 17:18:36 -07:00
Cloning libbitcoind:
2014-08-20 14:51:07 -07:00
``` bash
2014-09-11 17:18:36 -07:00
$ cd ~
$ git clone git@github.com:bitpay/libbitcoind.git bitcoin
$ cd bitcoin
```
2014-08-20 14:51:07 -07:00
2014-09-11 17:18:36 -07:00
This is a fork of bitcoin v0.9.0 right now, but it has the ability to compile
bitcoind as a shared object. This may not be ideal yet.
2014-08-20 14:51:07 -07:00
2014-09-11 17:18:36 -07:00
#### Compiling bticoind as a library
2014-08-20 14:51:07 -07:00
2014-09-12 14:27:25 -07:00
##### Dependencies
- Boost
- Bost Header Files (`/usr/include/boost`)
- Berkeley DB
- LevelDB Header Files (included in bitcoin source repo, leveldb itself
unnecessary, libbitcoind.so is already linked to them)
2014-10-02 14:29:38 -07:00
2014-09-11 17:18:36 -07:00
``` bash
# ensure clean up
$ make clean
2014-10-02 14:29:38 -07:00
$ find ~/bitcoin -type f -name '*.o' \
-or -name '*.so' -or -name '*.lo' \
-or -name '*.la' -print0 | xargs -0 rm -fv
2014-08-20 14:51:07 -07:00
2014-09-11 17:18:36 -07:00
# create configure file
2014-08-20 14:51:07 -07:00
$ ./autogen.sh
2014-09-11 17:18:36 -07:00
# configure as a library with -fPIC on all object files
# use --with-incompatible-bdb if necessary
# use --prefix=/usr if necessary
2014-10-02 14:29:38 -07:00
$ ./configure --enable-daemonlib
2014-08-20 14:51:07 -07:00
2014-09-11 17:18:36 -07:00
# build libbitcoind.so
2014-10-02 14:29:38 -07:00
$ time make
2014-08-20 15:32:15 -07:00
real 31m33.128s
user 16m23.930s
sys 2m52.310s
2014-08-20 14:51:07 -07:00
```
2014-10-02 14:29:38 -07:00
`--enable-daemonlib` will compile all object files with `-fPIC` (Position
2014-09-11 17:18:36 -07:00
Independent Code - needed to create a shared object).
2014-10-02 14:29:38 -07:00
`make` will then compile `./src/libbitcoind.so` (with `-shared -fPIC`), linking
to all the freshly compiled PIC object files. This will completely ignore
compiling tests and the QT object files.
2014-09-11 17:18:36 -07:00
2014-10-02 14:29:38 -07:00
Without `--enable-daemonlib`, the Makefile with compile bitcoind with -fPIE
2014-09-11 17:18:36 -07:00
(Position Independent for Executable), this allows compiling of bitcoind.
#### Todo
- Find a way to compile bitcoind and libbitcoind.so at the same time without
recompiling object files each time?
2014-08-20 14:51:07 -07:00
### bitcoind.js:
- NOTE: This will eventually try to include our included version of boost.
- NOTE: Rename bitcoind to bitcoind.o to try to statically link it?
``` bash
$ cd ~/work/node_modules/bitcoind.js
2014-09-12 15:44:57 -07:00
$ BITCOIN_DIR=~/bitcoin BOOST_INCLUDE=/usr/include/boost PYTHON=/usr/bin/python2.7 make
2014-08-20 14:51:07 -07:00
```
2014-08-12 12:03:04 -07:00
2014-09-11 17:18:36 -07:00
#### Running bitcoind.js
You can run bitcoind.js to start downloading the blockchain by doing:
``` bash
$ node example/ &
bitcoind: log pipe opened: 12
bitcoind: status="start_node(): bitcoind opened."
```
However, if you look at the bitcoind log files:
``` bash
$ tail -f ~/.bitcoin/debug.log
connect() to [2001:470:c1f2:3::201]:8333 failed: 101
connect() to [2001:470:6c:778::2]:8333 failed: 101
connect() to [2001:470:c1f2:3::201]:8333 failed: 101
```
Right now, the `connect(3)` call is failing due to some conflict with node or
libuv I'm guessing. This is being investigated.
^C (SIGINT) will call `StartShutdown()` in bitcoind on the node thread pool.
2014-09-26 15:50:05 -07:00
##### Features
bitcoind.js now has access to the wallet:
``` js
console.log(bitcoind.wallet.listAccounts());
...
```
``` bash
$ node example
bitcoind.js: status="start_node(): bitcoind opened."
{ '':
{ balance: 0,
addresses:
[ { address: '16PvEk4NggaCyfR2keZaP9nPufJvDb2ATZ',
privkeycompressed: true,
privkey: 'L47MC7gtB5UdWYsmxT6czzGophFm6Zj99PYVQWDNkJG6Mf12GGyi',
pubkeycompressed: true,
pubkey: '02bf636e7a3ad48ea2cf0c8dbdf992792e617a4f92f2e161f20f3c038883647f0d' } ] } }
bitcoind.js: stop_node(): bitcoind shutdown.
bitcoind.js: shutting down...
bitcoind.js: shut down.
```
2014-08-12 12:03:04 -07:00
## Contribution and License Agreement
If you contribute code to this project, you are implicitly allowing your code
to be distributed under the MIT license. You are also implicitly verifying that
all code is your original work. `</legalese>`
## License
Copyright (c) 2014, BitPay (MIT License).