<commit_before># bitcoind.js

__bitcoind.js__ as a node.js module which dynamically loads a node.js C++
modules which links to libbitcoind.{so|dylib}. Unix/Linux use the file extension "so" whereas Mac OSX uses "dylib" (bitcoind compiled as a shared library),
making all useful bitcoind functions asynchronous (with the exception of the wallet functionality).

## Building

### libbitcoind.{so|dylib}

#### Compiling bitcoind as a library

##### Dependencies

- Boost
  - Bost Header Files (`/usr/include/boost`)
  - NOTE: These are now included in the repo if they're not present.

- secp256k1

- OpenSSL headers and libraries (-lcrypto and -lssl)

- If target platform is Mac OS X, then OS X >= 10.9, Clang and associated linker.

##### Building

``` bash
$ cd ~/node_modules/bitcoind.js
$ ./bin/build-libbitcoind
```

NOTE: This script will run automatically on an `npm install`, along with the
compilation below.

The first argument can also be a bitcoin repo directory you already have on your disk, otherwise
it will check for ~/bitcoin by default. The `PATCH_VERSION` file dictates what version/tag the patch goes clean against.


###### In the build-libbitcoind.sh script:

`--enable-daemonlib` will compile all object files with `-fPIC` (Position
Independent Code - needed to create a shared object).

`make` will then compile `./src/libbitcoind.{so|dylib}` (with `-shared -fPIC`), linking
to all the freshly compiled PIC object files. This will completely ignore
compiling tests, QT object files and the wallet features in bitcoind/libbitcoind.{so|dylib}.

Without `--enable-daemonlib`, the Makefile with compile bitcoind with -fPIE
(Position Independent for Executable), this allows compiling of bitcoind.

### bitcoind.js

``` bash
$ cd ~/node_modules/bitcoind.js
$ BITCOIN_DIR=~/libbitcoind BOOST_INCLUDE=/usr/include/boost PYTHON=/usr/bin/python2.7 make
```

#### Running bitcoind.js

You can run bitcoind.js to start downloading the blockchain by doing:

``` bash
$ node example --on-block &
bitcoind: status="start_node(): bitcoind opened."
...
[should see full javascript blocks here]<commit_msg>adjusted README<commit_after># bitcoind.js

__bitcoind.js__ as a node.js module which dynamically loads a node.js C++
modules which links to libbitcoind.{so|dylib}. Unix/Linux use the file extension "so" whereas Mac OSX uses "dylib" (bitcoind compiled as a shared library),
making all useful bitcoind functions asynchronous (with the exception of the wallet functionality).

## Building

### libbitcoind.{so|dylib}

#### Compiling bitcoind as a library

##### Dependencies

- Boost
  - Boost Header Files (`/usr/include/boost`)
  - The Boost header files can be from your distro (like Debian or Ubuntu), just be sure to install the "-dev" versions of Boost.

- OpenSSL headers and libraries (-lcrypto and -lssl), this is used to compile Bitcoin.

- If target platform is Mac OS X, then OS X >= 10.9, Clang and associated linker.

##### Building

``` bash
$ cd ~/node_modules/bitcoind.js
$ ./bin/build-libbitcoind
```

NOTE: This script will run automatically on an `npm install`, along with the
compilation below.

The first argument can also be a bitcoin repo directory you already have on your disk, otherwise
it will check for ~/bitcoin by default. The `PATCH_VERSION` file dictates what version/tag the patch goes clean against.


###### In the build-libbitcoind.sh script:

`--enable-daemonlib` will compile all object files with `-fPIC` (Position
Independent Code - needed to create a shared object).

`make` will then compile `./src/libbitcoind.{so|dylib}` (with `-shared -fPIC`), linking
to all the freshly compiled PIC object files. This will completely ignore
compiling tests, QT object files and the wallet features in bitcoind/libbitcoind.{so|dylib}.

Without `--enable-daemonlib`, the Makefile with compile bitcoind with -fPIE
(Position Independent for Executable), this allows compiling of bitcoind.

### bitcoind.js

``` bash
$ cd bitcoind.js
$ node-gyp rebuild
```

#### Running bitcoind.js

You can run bitcoind.js to start downloading the blockchain by doing:

``` bash
$ node example --on-block &
bitcoind: status="start_node(): bitcoind opened."
...
[should see full javascript blocks here]
{'fraction_non_alphanumeric': 0.10111295287710159, 'fraction_numerical': 0.0028415818138763913, 'mean_word_length': 4.374045801526718, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1808579', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1250, 'n_words': 528}