矿工文档-mAPI

发表时间:2020年10月1日

信息来源:Bitcoinsv.io


以下的指引是介绍在主流的Linux系统下安装mAPI可使用的工具,前提假设是你使用着类似Bourne shell的shell,比如bash

在此了解mAPI的BRFC(比特币注释请求)。

在此了解mAPI参考实现的开源代码

技术支持

欲获得技术支持、参与讨论技术标准和参考实现的,请加入以下telegram群组

配置

mAPI配置依赖于用于主要服务配置的settings.conf文件以及一个或多个fee * .json文件,用于规定要收取的费用(例如,fees.json用于定义默认费用,fees_low.json用于定义降低费用,fees_user1.json用于定义用户1的费用等)。

为了对响应进行签名,还需要运行Miner ID并在设置配置中为mAPI提供端点。

所有设置都可以被环境变量覆盖

settings.conf文件

打开settings.conf文件开始编辑你的设置:

  • 更改httpAddresshttpsAddress以绑定到特定接口
  • 更改jwtKey使token生成新的JWT密钥:

console $ node -e "console.log(require('crypto').randomBytes(32).toString('hex'));"

  • 更改quoteExpiryMinutes以设置费用报价的到期时间
  • 更改与mAPI连接的比特币节点计数以及它们各自的比特币RPC参数:
  • bitcoin_count
  • bitcoin_1_host
  • bitcoin_1_port
  • bitcoin_1_username
  • bitcoin_1_password
  • 更改minerId_URLminerId_alias来设置Miner ID的URL别名

fees*.json文件

费率的JSON格式请参考Fee Spec BRFC

从源代码开始构建

首先确保你已经在本地机器上安装了Golang并复制了库。

git clone [email protected]:bitcoin-sv/merchantapi-reference.git

运行

$ ./run.sh

构建

$ ./build.sh

测试

运行单项测试或运行全部测试:

$ go test ./...

Docker

Build Image

你可以使用自己的更改配置来自行build image。

$ docker build . -t mapi_reference:1.1.0

Pull Image

你还可以从mAPI的公共Docker Hub库中提取image。

$ docker pull bitcoinsv/mapi:1.1.0

运行容器

配置示范:

$ docker run -p 9004:9004 \
    -e httpAddress=:9004 \
    -e bitcoin_1_host=host.docker.internal \
    -e minerId_URL=http://host.docker.internal:9002/minerid \
    -e minerId_alias=testMiner \
    bitcoinsv/mapi:1.1.0

在守护程序模式下运行的示范:

$ docker run -p 9004:9004 \
    -e httpAddress=:9004 \
    -e bitcoin_1_host=host.docker.internal \
    -e minerId_URL=http://host.docker.internal:9002/minerid \
    -e minerId_alias=testMiner \
    --restart=always -d \
    bitcoinsv/mapi:1.1.0
 

请注意settings.conf的配置将被上述环境变量所覆盖。


Bitcoin SV节点项目为比特币协会所拥有,请前往Bitcoinsv.io网站获取BSV节点的官方信息。

猜你喜欢

转载自blog.csdn.net/BitcoinSV/article/details/108977914
今日推荐