Skip to content

Commit 2ad8514

Browse files
committed
docs: Update README
1 parent 5a190cd commit 2ad8514

File tree

1 file changed

+127
-25
lines changed

1 file changed

+127
-25
lines changed

README.md

Lines changed: 127 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
# libbwt-nodejs
1+
# Bitcoin Wallet Tracker - JavaScript bindings
22

3-
A nodejs library for programmatically managing the Bitcoin Wallet Tracker Electrum RPC and HTTP API servers
4-
using the [`libbwt` C FFI interface](https://github.com/bwt-dev/libbwt).
3+
[![Build Status](https://travis-ci.org/bwt-dev/libbwt-nodejs.svg?branch=master)](https://travis-ci.org/bwt-dev/libbwt-nodejs)
4+
[![NPM release](https://img.shields.io/npm/v/libbwt.svg)](https://www.npmjs.com/package/libbwt)
5+
[![NPM installs](https://img.shields.io/npm/dt/libbwt?label=npm%20installs)](https://www.npmjs.com/package/libbwt)
6+
[![Downloads](https://img.shields.io/github/downloads/bwt-dev/libbwt-nodejs/total.svg?color=blueviolet)](https://github.com/bwt-dev/libbwt-nodejs/releases)
7+
[![MIT license](https://img.shields.io/github/license/bwt-dev/libbwt-nodejs.svg?color=yellow)](https://github.com/bwt-dev/libbwt-nodejs/blob/master/LICENSE)
8+
[![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/bwt-dev/bwt#developing)
59

6-
> ⚠️ WARNING: This is an alpha preview, released to gather developers' feedback. It is not ready for general use.
10+
JavaScript bindings for [Bitcoin Wallet Tracker](https://github.com/bwt-dev/bwt), a lightweight personal indexer for bitcoin wallets.
711

8-
### Install
12+
`libbwt-nodejs` allows to programmatically manage bwt's Electrum RPC and HTTP API servers.
13+
It can be used as a compatibility layer for easily upgrading Electrum-backed wallets to support a
14+
Bitcoin Core full node backend (by running the Electrum server *in* the wallet),
15+
or for shipping software that integrates bwt's [HTTP API](https://github.com/bwt-dev/bwt#http-api)
16+
as an all-in-one package.
917

10-
```
11-
$ npm install libbwt
12-
```
18+
It is based on the [`libbwt` C FFI](https://github.com/bwt-dev/libbwt).
1319

14-
This will download the `libbwt` library for your platform.
15-
The currently supported platforms are Linux, Mac, Windows and ARMv7/8.
16-
17-
The hash of the downloaded library is verified against the
18-
[`SHA256SUMS`](https://github.com/bwt-dev/libbwt-nodejs/blob/master/SHA256SUMS)
19-
file that ships with the npm package.
20+
Support development: [⛓️ on-chain or ⚡ lightning via BTCPay](https://btcpay.shesek.info/)
2021

21-
The library comes with the electrum and http servers by default.
22-
If you're only interested in the Electrum server, you can install with `BWT_VARIANT=electrum_only npm install libbwt`.
23-
This reduces the download size by ~1.6MB.
22+
- [Usage](#usage)
23+
- [Installation](#installation)
24+
- [Electrum only](#electrum-only-variant)
25+
- [Verifying the signature](#verifying-the-signature)
26+
- [Building from source](#building-from-source)
27+
- [Reproducible builds](#reproducible-builds)
28+
- [License](#license)
2429

25-
> Note: `libbwt-nodejs` uses [`ffi-napi`](https://github.com/node-ffi-napi/node-ffi-napi), which requires
26-
> a recent nodejs version. If you're running into errors during installation or segmentation faults,
27-
> try updating to a newer version.
30+
> Also see: [bwt](https://github.com/bwt-dev/bwt), [libbwt](https://github.com/bwt-dev/libbwt) and [libbwt-nodejs](https://github.com/bwt-dev/libbwt-nodejs).
2831
29-
### Use
32+
## Usage
3033

3134
Below is a minimally viable setup. If bitcoind is running locally on the default port, at the default datadir location
3235
and with cookie auth enabled (the default), this should Just Work™ \o/
@@ -82,15 +85,114 @@ console.log('bwt http server ready on', bwtd.http_url)
8285
bwtd.shutdown()
8386
```
8487

85-
See [`example.js`](https://github.com/bwt-dev/libbwt-nodejs/blob/master/example.js) for an even more complete
86-
example, including connecting to the HTTP API.
88+
See [`example.js`](example.js) for a more complete example, including connecting to the HTTP API.
8789

88-
The full list of options is available in the [libbwt documentation](https://github.com/bwt-dev/libbwt#config-options).
90+
The list of options is available in the [libbwt C FFI documentation](https://github.com/bwt-dev/libbwt#config-options).
8991
The nodejs wrapper also provides the following additional options:
9092

9193
- `progress` - callback for progress update notifications, invoked with `(type, progress, detail)` (optional)
9294
- `electrum` - setting to `true` is an alias for `electrum_addr=127.0.0.1:0`
9395
- `http` - setting to `true` is an alias for `http_addr=127.0.0.1:0`
9496

95-
### License
97+
Note that if you call `shutdown()` while bitcoind is importing/rescanning addresses, the daemon will
98+
not stop immediately but will be marked for later termination.
99+
100+
## Installation
101+
102+
Install from the npm registry:
103+
104+
```
105+
$ npm install libbwt
106+
```
107+
108+
(Instructions for installing the signed package are available below.)
109+
110+
The will download the `libbwt` library for your platform as a postinstall step.
111+
The currently supported platforms are Linux, Mac, Windows and ARMv7/8.
112+
113+
The hash of the downloaded library is verified against the
114+
[`SHA256SUMS`](SHA256SUMS) file that ships with the npm package.
115+
116+
> Note: `libbwt-nodejs` uses [`ffi-napi`](https://github.com/node-ffi-napi/node-ffi-napi), which requires
117+
> a recent nodejs version. If you're running into errors during installation or segmentation faults,
118+
> try updating to a newer version, and make sure to install and run libbwt using the same version.
119+
120+
#### Electrum-only variant
121+
122+
To install libbwt with Electrum support only (without the HTTP API), run `BWT_VARIANT=electrum_only npm install libbwt`.
123+
124+
The `electrum_only` variant is roughly 33% smaller and comes with less dependencies.
125+
126+
#### Verifying the signature
127+
128+
The releases are signed by Nadav Ivgi (@shesek).
129+
The public key can be verified on
130+
the [PGP WoT](http://keys.gnupg.net/pks/lookup?op=vindex&fingerprint=on&search=0x81F6104CD0F150FC),
131+
[github](https://api.github.com/users/shesek/gpg_keys),
132+
[twitter](https://twitter.com/shesek),
133+
[keybase](https://keybase.io/nadav),
134+
[hacker news](https://news.ycombinator.com/user?id=nadaviv)
135+
and [this video presentation](https://youtu.be/SXJaN2T3M10?t=4).
136+
137+
```bash
138+
# Download
139+
$ wget https://github.com/bwt-dev/libbwt-nodejs/releases/download/v0.2.0/libbwt-nodejs-0.2.0.tgz
140+
141+
# Fetch public key
142+
$ gpg --keyserver keyserver.ubuntu.com --recv-keys FCF19B67866562F08A43AAD681F6104CD0F150FC
143+
144+
# Verify signature
145+
$ wget -qO - https://github.com/bwt-dev/libbwt-nodejs/releases/download/v0.2.0/SHA256SUMS.asc \
146+
| gpg --decrypt - | sha256sum -c -
147+
148+
# Install
149+
$ npm install libbwt-nodejs-0.2.0.tgz
150+
```
151+
152+
The signature verification should show `Good signature from "Nadav Ivgi <[email protected]>" ... Primary key fingerprint: FCF1 9B67 ...` and `libbwt-nodejs-0.2.0.tgz: OK`.
153+
154+
## Building from source
155+
156+
Build the FFI library for your platform(s) as [described here](https://github.com/bwt-dev/libbwt#building-from-source) and
157+
copy the `libbwt.so`/`libbwt.dylib`/`bwt.dll` file into the root directory of `libbwt-nodejs`.
158+
159+
## Reproducible builds
160+
161+
The nodejs package (including the `SHA256SUMS` file with the `libbwt` hashes for all platforms)
162+
can be reproduced in a Docker container environment as follows:
163+
164+
```bash
165+
$ git clone https://github.com/bwt-dev/libbwt-nodejs && cd libbwt-nodejs
166+
$ git checkout <tag>
167+
$ git verify-commit HEAD
168+
$ git submodule update --init --recursive
169+
170+
# Build libbwt FFI library files for Linux, Windows, ARMv7 and ARMv8
171+
$ docker build -t bwt-builder - < bwt/scripts/builder.Dockerfile
172+
$ docker run -it --rm -u `id -u` -v `pwd`/libbwt:/usr/src/libbwt -w /usr/src/libbwt \
173+
--entrypoint scripts/build.sh bwt-builder
174+
175+
# Build libbwt FFI library files for Mac OSX (cross-compiled via osxcross)
176+
$ docker build -t bwt-builder-osx - < bwt/scripts/builder-osx.Dockerfile
177+
$ docker run -it --rm -u `id -u` -v `pwd`/libbwt:/usr/src/libbwt -w /usr/src/libbwt \
178+
--entrypoint scripts/build.sh bwt-builder-osx
179+
180+
# Build libbwt-nodejs npm package
181+
$ docker run -it --rm -u `id -u` -v `pwd`:/usr/src/libbwt-nodejs -w /usr/src/libbwt-nodejs \
182+
-e LIBBWT_DIST=/usr/src/libbwt-nodejs/libbwt/dist \
183+
--entrypoint scripts/build.sh node:14
184+
185+
$ sha256sum dist/*.tgz
186+
```
187+
188+
You may set `-e TARGETS=...` to a comma separated list of the platforms to build.
189+
The available platforms are: `x86_64-linux`, `x86_64-osx`, `x86_64-windows`, `arm32v7-linux` and `arm64v8-linux`.
190+
191+
Both variants will be built by default. To build the `electrum_only` variant only, set `-e ELECTRUM_ONLY_ONLY=1`.
192+
193+
The builds are [reproduced on Travis CI](https://travis-ci.org/github/bwt-dev/libbwt-nodejs/branches) using the code from GitHub.
194+
The SHA256 checksums are available under the "Reproducible builds" stage.
195+
196+
## License
197+
96198
MIT

0 commit comments

Comments
 (0)