mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-21 16:52:04 -07:00
Updating README and shell script examples
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
# bch-api
|
# bch-api
|
||||||
|
|
||||||
This is a node.js JavaScript REST API server using Express.js. The purpose of this code is to create a REST API server that provides a common interface for working with a Bitcoin Cash full node and various indexers. See [this article](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer) to learn about the 'Cash Stack'. Visit [FullStack.cash](https://fullstack.cash), sign up for a free account, and use this REST API right away with the [bch-js](https://github.com/Permissionless-Software-Foundation/bch-js) JavaScript library.
|
[](https://github.com/Permissionless-Software-Foundation/bch-js/blob/master/LICENSE.md)
|
||||||
|
[](https://github.com/feross/standard)
|
||||||
|
|
||||||
|
This is a node.js JavaScript REST API server using [Express.js](https://expressjs.com/). The purpose of this code is to create a REST API server that provides a common interface for working with a Bitcoin Cash full node and various indexers. See [this article](https://psfoundation.cash/blog/cash-stack) to learn about the 'Cash Stack'. Visit [FullStack.cash](https://fullstack.cash), sign up for a free account, and use this REST API right away with the [bch-js](https://github.com/Permissionless-Software-Foundation/bch-js) JavaScript library.
|
||||||
|
|
||||||
This repository is intended to be paired with [bch-js](https://github.com/Permissionless-Software-Foundation/bch-js), an npm JavaScript library for building Bitcoin Cash apps.
|
This repository is intended to be paired with [bch-js](https://github.com/Permissionless-Software-Foundation/bch-js), an npm JavaScript library for building Bitcoin Cash apps.
|
||||||
|
|
||||||
@@ -20,7 +23,7 @@ The following features set this repository apart from rest.bitcoin.com:
|
|||||||
- Fine grain access is controlled with a JWT token using
|
- Fine grain access is controlled with a JWT token using
|
||||||
[this back end auth server](https://github.com/Permissionless-Software-Foundation/jwt-bch-api) and [this front end](https://github.com/Permissionless-Software-Foundation/jwt-bch-frontend). Can be used to monetize access to the REST API.
|
[this back end auth server](https://github.com/Permissionless-Software-Foundation/jwt-bch-api) and [this front end](https://github.com/Permissionless-Software-Foundation/jwt-bch-frontend). Can be used to monetize access to the REST API.
|
||||||
- Typescript removed and ES8 JavaScript used instead.
|
- Typescript removed and ES8 JavaScript used instead.
|
||||||
- npm audit run on all dependencies.
|
- `npm audit fix` frequently run to fix dependencies.
|
||||||
|
|
||||||
## Live Demo
|
## Live Demo
|
||||||
You can test a live demo of the REST API by running the
|
You can test a live demo of the REST API by running the
|
||||||
@@ -31,17 +34,17 @@ You can bootstrap your own REST API server by downloading and installing the inf
|
|||||||
### Configure bch-js
|
### Configure bch-js
|
||||||
The live servers can be used by [bch-js](https://github.com/Permissionless-Software-Foundation/bch-js) by settings the `restURL` config property to one of these servers:
|
The live servers can be used by [bch-js](https://github.com/Permissionless-Software-Foundation/bch-js) by settings the `restURL` config property to one of these servers:
|
||||||
|
|
||||||
- BCHN Mainnet REST API server: https://bchn.fullstack.cash/v3/
|
- BCHN Mainnet REST API server: https://bchn.fullstack.cash/v4/
|
||||||
- ABC Mainnet REST API server: https://abc.fullstack.cash/v3/
|
- ABC Mainnet REST API server: https://abc.fullstack.cash/v4/
|
||||||
- Testnet3 REST API server: https://testnet3.fullstack.cash/v3/
|
- Testnet3 REST API server: https://testnet3.fullstack.cash/v4/
|
||||||
- Check server status: https://metrics.fullstack.cash
|
- Check server status: https://metrics.fullstack.cash
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
There are two installation paths, depending if you want a *development* or
|
There are two installation paths, depending if you want a *development* or
|
||||||
*production* environment. You'll also need to set up the underlying infrastructure
|
*production* environment. You'll also need to set up the underlying infrastructure
|
||||||
described on [this page](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer).
|
described on [this page](https://psfoundation.cash/blog/cash-stack).
|
||||||
|
|
||||||
This code targets the Ubuntu 18.04 LTS Linux OS.
|
This code targets the Ubuntu 18.04 LTS Linux OS or higher.
|
||||||
|
|
||||||
### Development
|
### Development
|
||||||
This is a standard node.js project. The installation is as follows:
|
This is a standard node.js project. The installation is as follows:
|
||||||
@@ -86,7 +89,7 @@ Have questions? Need help? Join our community support
|
|||||||
## IPFS
|
## IPFS
|
||||||
Copies of this repository will occasionally be uploaded and hosted on [IPFS](https://ipfs.io):
|
Copies of this repository will occasionally be uploaded and hosted on [IPFS](https://ipfs.io):
|
||||||
|
|
||||||
- v1.15.4: QmSAerFmDJm6KQp2HC8jsRR5MdL5X39hoUsJYvWNDvrD8m
|
- v1.25.1: [QmXFzFJHenymhReDc9oGAxbpmvK2fJYnisQ2pJn3gGyKKX](https://ipfs.io/ipfs/QmXFzFJHenymhReDc9oGAxbpmvK2fJYnisQ2pJn3gGyKKX)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
[MIT](./LICENSE.md)
|
[MIT](./LICENSE.md)
|
||||||
|
|||||||
@@ -1,21 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# test
|
# Docker containers for the below infrastructure is described here:
|
||||||
|
# https://psfoundation.cash/blog/cash-stack
|
||||||
|
# Pre-synced databases can be downloaded on the CashStrap page:
|
||||||
|
# https://fullstack.cash/cashstrap
|
||||||
|
|
||||||
|
# Which network are you using?
|
||||||
|
export NETWORK=mainnet
|
||||||
|
#export NETWORK=testnet
|
||||||
|
|
||||||
# Full node
|
# Full node
|
||||||
export RPC_BASEURL=http://172.17.0.1:8332/
|
export RPC_IP=172.17.0.1:8332
|
||||||
|
export RPC_BASEURL=http://$RPC_IP/
|
||||||
export RPC_USERNAME=bitcoin
|
export RPC_USERNAME=bitcoin
|
||||||
export RPC_PASSWORD=password
|
export RPC_PASSWORD=password
|
||||||
export NETWORK=mainnet
|
|
||||||
|
|
||||||
# SLPDB
|
# SLPDB
|
||||||
export SLPDB_URL=http://172.17.0.1:12300/
|
export SLPDB_URL=http://172.17.0.1:12300/
|
||||||
export SLPDB_PASS=somelongpassword
|
export SLPDB_PASS=somelongpassword
|
||||||
|
# Use the same address as SLPDB_URL if you don't have a separate whitelist server.
|
||||||
# Blockbook Indexer
|
export SLPDB_WHITELIST_URL=http://172.17.0.1:12300/
|
||||||
export BLOCKBOOK_URL=https://172.17.0.1:9131/
|
# slp-api alternative SLP validator using slp-validate:
|
||||||
# Allow node.js to make network calls to https using self-signed certificate.
|
# https://github.com/Permissionless-Software-Foundation/slp-api
|
||||||
export NODE_TLS_REJECT_UNAUTHORIZED=0
|
export SLP_API_URL=http://10.0.0.5:5001/
|
||||||
|
|
||||||
# Mainnet Fulcrum / ElectrumX
|
# Mainnet Fulcrum / ElectrumX
|
||||||
export FULCRUM_URL=172.17.0.1
|
export FULCRUM_URL=172.17.0.1
|
||||||
@@ -26,12 +33,25 @@ export REDIS_PORT=6379
|
|||||||
export REDIS_HOST=172.17.0.1
|
export REDIS_HOST=172.17.0.1
|
||||||
|
|
||||||
# JWT Token Secret
|
# JWT Token Secret
|
||||||
|
# This is used to verify JWT tokens generated with jwt-bch-api:
|
||||||
|
# https://github.com/Permissionless-Software-Foundation/jwt-bch-api
|
||||||
export TOKENSECRET=somelongsecretvalue
|
export TOKENSECRET=somelongsecretvalue
|
||||||
|
|
||||||
# So that bch-api can call bch-js locally.
|
# So that bch-api can call bch-js locally.
|
||||||
export LOCAL_RESTURL=http://127.0.0.1:3000/v3/
|
export LOCAL_RESTURL=http://127.0.0.1:3000/v4/
|
||||||
|
|
||||||
# slp-api alternative SLP validator.
|
# Basic Authentication password
|
||||||
export SLP_API_URL=http://10.0.0.5:5001/
|
export PRO_PASS=somerandomepassword:someotherrandompassword:aThirdPassword
|
||||||
|
|
||||||
|
# Whitelisted domains. Automatically give pro-tier rate limit access to apps
|
||||||
|
# that originate froma domain on the whitelist.
|
||||||
|
export WHITELIST_DOMAINS=fullstack.cash,psfoundation.cash,torlist.cash
|
||||||
|
|
||||||
|
# Rate Limits. Numbers are divided into 1000. e.g. 1000 / 50 = 20 RPM for ANON.
|
||||||
|
# Requests use the ANON rate limit if they fail to pass in a JWT token.
|
||||||
|
# ANON = 20 requests per minute (RPM)
|
||||||
|
export ANON_RATE_LIMIT=50
|
||||||
|
# 10 = 100 RPM
|
||||||
|
export WHITELIST_RATE_LIMIT=10
|
||||||
|
|
||||||
npm start
|
npm start
|
||||||
|
|||||||
@@ -1,22 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Docker containers for the below infrastructure is described here:
|
||||||
|
# https://psfoundation.cash/blog/cash-stack
|
||||||
|
# Pre-synced databases can be downloaded on the CashStrap page:
|
||||||
|
# https://fullstack.cash/cashstrap
|
||||||
|
|
||||||
|
# Which network are you using?
|
||||||
|
#export NETWORK=mainnet
|
||||||
|
export NETWORK=testnet
|
||||||
|
|
||||||
# Full node
|
# Full node
|
||||||
export RPC_BASEURL=http://172.17.0.1:18332/
|
export RPC_IP=172.17.0.1:18332
|
||||||
|
export RPC_BASEURL=http://$RPC_IP/
|
||||||
export RPC_USERNAME=bitcoin
|
export RPC_USERNAME=bitcoin
|
||||||
export RPC_PASSWORD=password
|
export RPC_PASSWORD=password
|
||||||
export NETWORK=testnet
|
|
||||||
|
|
||||||
# SLPDB
|
# SLPDB
|
||||||
export SLPDB_URL=http://172.17.0.1:13300/
|
export SLPDB_URL=http://172.17.0.1:13300/
|
||||||
|
export SLPDB_PASS=somelongpassword
|
||||||
# Blockbook Indexer
|
# Use the same address as SLPDB_URL if you don't have a separate whitelist server.
|
||||||
export BLOCKBOOK_URL=https://172.17.0.1:19131/
|
export SLPDB_WHITELIST_URL=http://172.17.0.1:13300/
|
||||||
# Allow node.js to make network calls to https using self-signed certificate.
|
# slp-api alternative SLP validator using slp-validate:
|
||||||
export NODE_TLS_REJECT_UNAUTHORIZED=0
|
# https://github.com/Permissionless-Software-Foundation/slp-api
|
||||||
|
export SLP_API_URL=http://10.0.0.5:5001/
|
||||||
|
|
||||||
# Mainnet Fulcrum / ElectrumX
|
# Mainnet Fulcrum / ElectrumX
|
||||||
export FULCRUM_URL=172.17.0.1
|
export FULCRUM_URL=172.17.0.1
|
||||||
export FULCRUM_PORT=50002
|
export FULCRUM_PORT=60002
|
||||||
|
|
||||||
# Redis DB
|
# Redis DB
|
||||||
export REDIS_PORT=6380
|
export REDIS_PORT=6380
|
||||||
@@ -26,9 +36,20 @@ export REDIS_HOST=172.17.0.1
|
|||||||
export TOKENSECRET=somelongsecretvalue
|
export TOKENSECRET=somelongsecretvalue
|
||||||
|
|
||||||
# So that bch-api can call bch-js locally.
|
# So that bch-api can call bch-js locally.
|
||||||
export LOCAL_RESTURL=http://127.0.0.1:3000/v3/
|
export LOCAL_RESTURL=http://127.0.0.1:3000/v4/
|
||||||
|
|
||||||
# slp-api alternative SLP validator.
|
# Basic Authentication password (optional)
|
||||||
export SLP_API_URL=http://10.0.0.5:5001/
|
export PRO_PASS=somerandomepassword:someotherrandompassword:aThirdPassword
|
||||||
|
|
||||||
|
# Whitelisted domains. Automatically give pro-tier rate limit access to apps
|
||||||
|
# that originate froma domain on the whitelist.
|
||||||
|
export WHITELIST_DOMAINS=fullstack.cash,psfoundation.cash,torlist.cash
|
||||||
|
|
||||||
|
# Rate Limits. Numbers are divided into 1000. e.g. 1000 / 50 = 20 RPM for ANON.
|
||||||
|
# Requests use the ANON rate limit if they fail to pass in a JWT token.
|
||||||
|
# ANON = 20 requests per minute (RPM)
|
||||||
|
export ANON_RATE_LIMIT=50
|
||||||
|
# 10 = 100 RPM
|
||||||
|
export WHITELIST_RATE_LIMIT=10
|
||||||
|
|
||||||
npm start
|
npm start
|
||||||
|
|||||||
+10
-2
@@ -1,5 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Docker containers for the below infrastructure is described here:
|
||||||
|
# https://psfoundation.cash/blog/cash-stack
|
||||||
|
# Pre-synced databases can be downloaded on the CashStrap page:
|
||||||
|
# https://fullstack.cash/cashstrap
|
||||||
|
|
||||||
# Which network are you using?
|
# Which network are you using?
|
||||||
export NETWORK=mainnet
|
export NETWORK=mainnet
|
||||||
#export NETWORK=testnet
|
#export NETWORK=testnet
|
||||||
@@ -15,7 +20,6 @@ export SLPDB_URL=http://<SLPDB IP>:12300/
|
|||||||
export SLPDB_PASS=somelongpassword
|
export SLPDB_PASS=somelongpassword
|
||||||
# Use the same address as SLPDB_URL if you don't have a separate whitelist server.
|
# Use the same address as SLPDB_URL if you don't have a separate whitelist server.
|
||||||
export SLPDB_WHITELIST_URL=http://<SLPDB IP>:12300/
|
export SLPDB_WHITELIST_URL=http://<SLPDB IP>:12300/
|
||||||
|
|
||||||
# slp-api alternative SLP validator using slp-validate:
|
# slp-api alternative SLP validator using slp-validate:
|
||||||
# https://github.com/Permissionless-Software-Foundation/slp-api
|
# https://github.com/Permissionless-Software-Foundation/slp-api
|
||||||
export SLP_API_URL=http://10.0.0.5:5001/
|
export SLP_API_URL=http://10.0.0.5:5001/
|
||||||
@@ -24,13 +28,17 @@ export SLP_API_URL=http://10.0.0.5:5001/
|
|||||||
export FULCRUM_URL=192.168.0.6
|
export FULCRUM_URL=192.168.0.6
|
||||||
export FULCRUM_PORT=50002
|
export FULCRUM_PORT=50002
|
||||||
|
|
||||||
|
# Redis DB - Used for rate limiting - customize to your own Redis installation.
|
||||||
|
export REDIS_PORT=6379
|
||||||
|
export REDIS_HOST=172.17.0.1
|
||||||
|
|
||||||
# JWT Token Secret
|
# JWT Token Secret
|
||||||
# This is used to verify JWT tokens generated with jwt-bch-api:
|
# This is used to verify JWT tokens generated with jwt-bch-api:
|
||||||
# https://github.com/Permissionless-Software-Foundation/jwt-bch-api
|
# https://github.com/Permissionless-Software-Foundation/jwt-bch-api
|
||||||
export TOKENSECRET=somelongpassword
|
export TOKENSECRET=somelongpassword
|
||||||
|
|
||||||
# So that bch-api can call bch-js locally.
|
# So that bch-api can call bch-js locally.
|
||||||
export LOCAL_RESTURL=http://127.0.0.1:3000/v3/
|
export LOCAL_RESTURL=http://127.0.0.1:3000/v4/
|
||||||
|
|
||||||
# Basic Authentication password
|
# Basic Authentication password
|
||||||
export PRO_PASS=somerandomepassword:someotherrandompassword:aThirdPassword
|
export PRO_PASS=somerandomepassword:someotherrandompassword:aThirdPassword
|
||||||
|
|||||||
Reference in New Issue
Block a user