The following instructions describe installing mAPI using tools available in most mainstream Linux distributions. We assume you use a Bourne-like shell such as bash
.
The BRFC (Bitcoin request for comment) specification can be found here.
The open source code of the reference implementation can be found here.
For support and general discussion of both standard and reference implementations please join the following telegram group.
mAPI configuration relies on a settings.conf file for the main service configurations as well as one or more fees*.json files (ex. fees.json for default fees, fees_low.json for lower fees, fees_user1.json for user1, etc.) to specify fees to be charged.
In order to sign responses, you will also need to run Miner ID and provide the endpoint to mAPI in the settings configurations.
All settings can be overwritten with environment variables
Open settings.conf and edit it with your settings:
httpAddress
or httpsAddress
to bind on specific interfacesjwtKey
for tokens Generate new JWT key:console $ node -e "console.log(require('crypto').randomBytes(32).toString('hex'));"
quoteExpiryMinutes
to set feeQuote expiry timebitcoin_count
bitcoin_1_host
bitcoin_1_port
bitcoin_1_username
bitcoin_1_password
minerId_URL
and minerId_alias
to set URL alias of Miner IDPlease see the Fee Spec BRFC for the fees JSON format.
Make sure you have Golang installed on your machine and the clone the repo
git clone [email protected]:bitcoin-sv/merchantapi-reference.git
$ ./run.sh
$ ./build.sh
Run individual tests or run all tests with:
$ go test ./...
You can build the image yourself with your own modifications or own configurations.
$ docker build . -t mapi_reference:1.1.0
You can also pull it from the public Docker Hub repository for mAPI here.
$ docker pull bitcoinsv/mapi:1.1.0
Example configuration:
$ docker run -p 9004:9004 \ -e httpAddress=:9004 \ -e bitcoin_1_host=host.docker.internal \ -e minerId_URL=https://host.docker.internal:9002/minerid \ -e minerId_alias=testMiner \ bitcoinsv/mapi:1.1.0
Example running in daemon mode:
$ docker run -p 9004:9004 \ -e httpAddress=:9004 \ -e bitcoin_1_host=host.docker.internal \ -e minerId_URL=https://host.docker.internal:9002/minerid \ -e minerId_alias=testMiner \ --restart=always -d \ bitcoinsv/mapi:1.1.0
Note: The
settings.conf
configurations will get overwritten with the above environment variables.