Updating README

This commit is contained in:
Chris Troutner
2019-08-11 09:36:20 -07:00
parent 7205a5fea3
commit db925637f1
3 changed files with 67 additions and 113 deletions
View File
+44 -113
View File
@@ -35,137 +35,68 @@ continuous-release with semantic versioning through Semantic Release.
- Add end-to-end tests.
## Features
The following features have been implemented:
The following features set this repository apart from rest.bitcoin.com:
- Address balance and UTXO queries for [Blockbook](https://github.com/trezor/blockbook) and [Bitcore](https://github.com/bitpay/bitcore/tree/master/packages/bitcore-node) added.
- Typescript removed and ES8 JavaScript used instead.
- npm audit run on all depedencies.
- npm audit run on all dependencies.
- [Greenkeeper](https://greenkeeper.io/) implemented for automatic dependency management
and security updates.
----
## Live Demo
You can test a live demo of the REST API by running the
[bch-js examples](https://github.com/christroutner/bch-js/tree/master/examples).
Rate limits are 10 requests per minute. This is fast enough to try out the examples
but these servers are not intended as a freemium service. You can run your own
REST server by purchasing the hard drive at [bchjs.cash](https://bchjs.cash).
## REST
- Mainnet REST API server: http://decatur.hopto.org:12400/v3/
- Check server status: http://decatur.hopto.org:12401
- Testnet REST API server: http://decatur.hopto.org:13400/v3/
- Check server status: http://decatur.hopto.org:13401
[rest.bitcoin.com](https://rest.bitcoin.com) is the REST layer for Bitcoin.com's Cloud.
## Installation
There are two installation paths, depending if you want a *development* or
*production* environment. You'll also need to set up the underlying infrastructure
described [this page](https://bchjs.cash/bch-api-stack/).
More info: [developer.bitcoin.com](https://developer.bitcoin.com). Chatroom [http://geni.us/CashDev](geni.us/CashDev)
This code targets the Ubuntu 18.04 LTS Linux OS.
Testnet available at [trest.bitcoin.com](https://trest.bitcoin.com)
### Development
This is a standard node.js project. The installation is as follows:
## Usage
- Clone this repository:
You can also run an instance of REST for your own full node.
`git clone https://github.com/christroutner/bch-api && cd bch-api`
### Prerequisites
- Install dependencies:
#### NodeJS
`npm install`
Install nodejs's LTS. 8.11.4 at the time of writing.
- Customize the [start-dev-example.sh](start-dev-example.sh) shell script to
point to the required infrastructure. Start the bch-api REST API by running
this script:
https://nodejs.org/en/
`./start-dev-example.sh`
#### build-essential package
### Production
For a production environment, a Docker container is provided in the
[docker](docker) directory. One for mainnet and one for testnet. Again, these
containers target the Ubuntu 18.04 LTS Linux OS.
If you encounter
- Install Docker and Docker Compose by following the commands on
[this Dev Ops page](https://troutsblog.com/research/dev-ops/overview).
```
gyp ERR! build error
gyp ERR! stack Error: not found: make
```
- Customize the [bash script](docker/mainnet/start-local-mainnet.sh) for your
installation.
For Ubuntu
- Build the Docker container with:
```
sudo apt-get install build-essential
```
`docker-compose build --no-cache`
For CENTOS
- Run the Docker container with:
```
RUN yum install -y make gcc*
```
`docker-compose up`
### Full node
Fire up a full Bitcoin Cash node and add the following to your `bitcoin.conf`.
```
# Accept command line and JSON-RPC commands.
server=1
# Username for JSON-RPC connections
rpcuser=rpcUsername
# Password for JSON-RPC connections
rpcpassword=rpcPasssword
# If you're running REST on a different host than bitcoind's localhost
# rpcallowip=*
# Or you can restrict by IP or range of IPs
# rpcallowip=192.168.1.*
# Enable zeromq for real-time data
zmqpubrawtx=tcp://your.nodes.ip.address:28332
zmqpubrawblock=tcp://your.nodes.ip.address:28332
zmqpubhashtx=tcp://your.nodes.ip.address:28332
zmqpubhashblock=tcp://your.nodes.ip.address:28332
```
Also allow tcp requests on port `28332`
```
sudo ufw allow 28332
```
### Clone the repo
Next clone the rest.bitcoin.com repo.
```
git clone https://github.com/Bitcoin-com/rest.bitcoin.com.git
```
#### Install dependencies
`cd` into the newly cloned directory and install the dependencies.
```
cd rest.bitcoin.com
npm install
```
#### Build REST
```bash
npm run build
```
#### Start REST
Now you need to start REST and pass in the following environment variables
- BITCOINCOM_BASEURL - On rest.bitcoin.com this env var is to our internal insight API. You can use insight's public API.
- RPC_BASEURL - The IP address of your full BCH node
- RPC_PASSWORD - The rpc password of your full BCH node
- RPC_USERNAME - The rpc username of your full BCH node
- ZEROMQ_PORT - The port on which you enabled ZeroMQ
- ZEROMQ_URL - The IP address of your full BCH node
- NETWORK - mainnet or testnet depending on which network you're using
- BITDB_URL - mainnet or testnet BITDB URL
- SLPDB_URL - mainnet or testnet SLPDB URL
- RATE_LIMIT_MAX_REQUESTS (optional) - Rate limit per route per minute. Defaults to 60. Set to 0 to disable rate limit.
- NON_JS_FRAMEWORK (optional) - enables endpoints to create, mint, send, burn and burnAll SLP tokens
Here's how the final command would look
```
BITCOINCOM_BASEURL=https://bch-insight.bitpay.com/api/ RPC_BASEURL=http://your.nodes.ip.address:8332/ RPC_PASSWORD=rpcPasssword RPC_USERNAME=rpcUsername ZEROMQ_PORT=28332 ZEROMQ_URL=your.nodes.ip.address BITDB_URL=https://bitdb.bitcoin.com/ SLPDB_URL=https://slpdb.bitcoin.com/ NETWORK=mainnet npm run dev
```
Starting in the regtest mode (partly working since the bitcoincom_baseurl does not work with local nodes):
```bash
PORT=3000 BITCOINCOM_BASEURL=http://localhost:3000/api/ RPC_BASEURL=http://localhost:18332/ RPC_PASSWORD=regtest RPC_USERNAME=regtest ZEROMQ_PORT=0 ZEROMQ_URL=0 NETWORK=local npm start
```
#### View in browser
Finally open `http://localhost:3000/` and confirm you see the GUI
## License
[MIT](LICENSE.md)
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
# Harddrive Mainnet full node
export RPC_BASEURL=http://<full node ip>:8332/
export RPC_USERNAME=<RPC username>
export RPC_PASSWORD=<RPC password>
export NETWORK=mainnet
# Team DO QA Testnet Insight Server
export BITCOINCOM_BASEURL=http://<Insight API IP>:12100/api/
# Testnet SLPDB
export SLPDB_URL=http://<SLPDB IP>:12300/
# Testnet Bitcore Node API
export BITCORE_URL=http://<Bitcore Node IP>:12200/
# Testnet Blockbook
export BLOCKBOOK_URL=https://<Blockbook IP>:9131/
# Allow node.js to make network calls to https using self-signed certificate.
export NODE_TLS_REJECT_UNAUTHORIZED=0
npm start