https://github.com/synonymdev/lsp-worker-btc
https://github.com/synonymdev/lsp-worker-btc
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/synonymdev/lsp-worker-btc
- Owner: synonymdev
- License: mit
- Created: 2022-01-06T02:44:36.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-08T17:18:04.000Z (about 2 years ago)
- Last Synced: 2025-03-24T10:56:26.373Z (about 1 year ago)
- Language: JavaScript
- Size: 85.9 KB
- Stars: 1
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LSP Bitcoin Worker
Microservice worker to interact with Bitcoin node
## Features
* Support for various Bitcoin RPC endpoints
* Support for watching mempool
* Support for sweeping the blockchain
* Alerts on new block
## Getting started
```
npm install
```
Next set up your config by copying the examples...
```
cp ./config/blocks.worker.config.json.example ./config/blocks.worker.config.json
cp ./config/mempool.worker.config.json.example ./config/mempool.worker.config.json
cp ./config/worker.config.json.example ./config/worker.config.json
```
`worker.config.json` will require credentials of a Bitcoin node in it.
For a development environment, we recommend installing [Polar](https://lightningpolar.com/) so you can easily spin up a node for testing. The example credentials in the config file match the defaults for a Bitcoin node created in Polar.
You will also need MongoDB running. `worker.config.json` can be updated to include connection information for your DB.
Blocktank uses [Grenache](https://github.com/bitfinexcom/grenache), a DHT based high performance microservices framework, to distribute and hand out tasks to workers. To create the DHT network, run 2 instances of [Grape](https://github.com/bitfinexcom/grenache-grape) to get started...
```
grape --dp 20001 --aph 30001 --bn '127.0.0.1:20002'
grape --dp 20002 --aph 40001 --bn '127.0.0.1:20001
```
## Running everything
You can either launch each of the workers in this repo manually as follows...
```
node start.bitcoin.js
node start.blocks.js
node start.mempool.js
```
or use [pm2](https://pm2.keymetrics.io/docs/usage/process-management/) to run them all and manage all the processes for you...
```
pm2 start ecosystem.config.js
```
## Workers
The following workers are started here...
* start.bitcoin.js: svc:btc - provides access to calling the connected Bitcoin node
* start.blocks.js: svc:btc:blocks - watches for new blocks and calls workers when that happens
* start.mempool.js: svc:btc:mempool - watches for new transactions in the mempool and calls workers when that happens
By default, the following workers are called (though this can be changed in the config files)...
* start.blocks.js: svc:btc_zero_conf_orders - called on each new block (see config)
* start.blocks.js: svc:btc_address_watch - called on each new block (see config)
* start.mempool.js: svc:btc_zero_conf_orders - called on each new transaction detected (see config)