# 全节点API

# API使用方法

Client URL
Go http://localhost:9888

以下是使用 curl调用的具体例子:

# Go

// curl -X POST url/method -d data
curl -X POST http://localhost:9888/create-key -d '{"alias": "alice", "password": "123456", "language": "en"}'

// response
{
  "status": "success",
  "data": {
    "alias": "alice",
    "xpub": "66008ba54d0fb103e075c0ab403f2ac1527a3b9d23dc16312dede67c85199423f912c4f84c9515e87e14874bd405953abfced87f66926c25ba8c31968094c05b",
    "file": "/home/.bytom/keystore/UTC--2018-11-01T06-44-28.250301455Z--6c794d3a-53b3-4c79-92d0-7b0e216667ae",
    "mnemonic": "ocean exotic route sad volume grace knock frame pumpkin fetch december capital orange cake copper exercise elephant sound aware shiver silver donate pool interest"
  }
}

# API 方法

# 必须创建钱包才能使用

# 无需创建钱包即可使用


# create-key

通过给定参数创建一个密钥对,返回公钥信息,私钥会被加密保存在文件中,需要设置一个密码,在签名时解密私钥。

# 请求参数

Object:

  • String - alias, 密钥别名
  • String - password, 密钥密码
  • String - language, 助记词的语言

可选:

  • String - mnemonic, 可以选择使用助记词来生成密钥
# 返回值
  • String - status, 状态信息
  • Object - data, 密钥信息
    • String - alias, 密钥别名
    • String - xpub, 公钥
    • String - file, 存储密钥的文件路径

Optional:

  • String - mnemonic, 助记词,当请求中不存在助记词则会在响应中打印出助记词
# 示例

随机生成模式

// Request
curl -X POST create-key -d '{"alias": "alice", "password": "123456", "language": "en"}'

// Result
{
  "status": "success",
  "data": {
    "alias": "alice",
    "xpub": "6f9d945cd03cce033f4a2a9fd5659d3ddfa58e2d32f8c711baca0de0aae83ff6d67f4f4e53f3ff0b3c11bac2a11123c26c7c32e0478e6cf802ca1109941bb45b",
    "file": "/home/yang/.bytom/keystore/UTC--2018-10-10T07-09-17.509894697Z--341695b9-9223-470c-a26d-bea210f8e1bb",
    "mnemonic": "price put soldier kitten beef garlic release burden symptom jump purity flower"
  }
}

通过助记词生成

// Request
curl -X POST create-key -d '{"alias":"jack", "password":"123456", "mnemonic":"please observe raw beauty blue sea believe then boat float beyond position", "language":"en"}'

// Result
{
  "status": "success",
  "data": {
    "alias": "jack",
    "xpub": "c7bcb65febd31c6d900bc84c386d95c3d5b047090628d9bf5c51a848945b6986e99ff70388018a7681fa37a240dbd8df39a994c86f9314a61e75feb33563ca72",
    "file": "/home/yang/.bytom/keystore/UTC--2018-10-10T07-08-51.815030323Z--46ee932e-88d3-4680-a5c1-dd9e63918fcc"
  }
}

# list-keys

展示钱包所有密钥信息

# 请求参数

none

# 返回值
  • String - status, 状态信息
  • Array of Object, 钱包所有的密钥列表
    • Object - data,密钥信息
      • String - alias, 密钥别名
      • String - xpub, 公钥
      • String - file, 存储密钥的文件路径
# 示例
// Request
curl -X POST list-keys

// Result
{
  "status": "success",
  "data": [
    {
      "alias": "alice",
      "xpub": "6f9d945cd03cce033f4a2a9fd5659d3ddfa58e2d32f8c711baca0de0aae83ff6d67f4f4e53f3ff0b3c11bac2a11123c26c7c32e0478e6cf802ca1109941bb45b",
      "file": "/Path/To/Library/Bytom/keystore/UTC--2018-04-21T02-35-15.035935116Z--4f2b8bd7-0576-4b82-8941-6cc6da05efe3"
    },
    {
      "alias": "bob",
      "xpub": "c7bcb65febd31c6d900bc84c386d95c3d5b047090628d9bf5c51a848945b6986e99ff70388018a7681fa37a240dbd8df39a994c86f9314a61e75feb33563ca72",
      "file": "/Path/To/Library/Bytom/keystore/UTC--2018-04-22T06-30-27.609315219Z--0e34293c-8856-4f5f-b934-37456a3820fa"
    }
  ]
}

# update-key-alias

更新密钥别名

# 请求参数

Object

  • String - xpub, 公钥
  • String - new_alias, 更新后的密钥别名
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST update-key-alias -d '{"xpub": "a7dae957c2d35b42efe7e6871cf5a75ebd2a0d0e51caffe767db42d3e6d69dbe211d1ca492ecf05908fe6fa625ad61b3253375ea744c9442dd5551613ba50aea", "new_alias": "new_key"}'

// Result
{
  "status": "success"
}

# delete-key

删除密钥,删除前请确认在关联钱包中没有任何资产余额

# 请求参数

Object:

  • String - xpub, 公钥
  • String - password, 密钥密码
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST delete-key -d '{"xpub": "a7dae957c2d35b42efe7e6871cf5a75ebd2a0d0e51caffe767db42d3e6d69dbe211d1ca492ecf05908fe6fa625ad61b3253375ea744c9442dd5551613ba50aea", "password": "123456"}'

// Result
{
  "status": "success"
}

# check-key-password

校验密码是否和输入值匹配

# 请求参数

Object:

  • String - xpub, 公钥
  • String - password, 密钥密码
# 返回值
  • String - status, 状态信息
  • Object- data, 校验信息
    • Boolean - check_result, 校验结果,如果匹配则是true,否则是false
# 示例
// Request
curl -X POST check-key-password -d '{"xpub": "a7dae957c2d35b42efe7e6871cf5a75ebd2a0d0e51caffe767db42d3e6d69dbe211d1ca492ecf05908fe6fa625ad61b3253375ea744c9442dd5551613ba50aea", "password": "123456"}'

// Result
{
  "status": "success",
  "data": {
    "check_result": true
  }
}

# reset-key-password

重设密钥密码

# 请求参数

Object:

  • String - xpub, 公钥
  • String - old_password, 旧密码
  • String - new_password, 新密码
# 返回值
  • String - status, 状态信息
  • Object- data,
  • Boolean - changed, 密码修改结果,true代表修改成功,false代表未修改
# 示例
// Request
curl -X POST reset-key-password -d '{"xpub": "a7dae957c2d35b42efe7e6871cf5a75ebd2a0d0e51caffe767db42d3e6d69dbe211d1ca492ecf05908fe6fa625ad61b3253375ea744c9442dd5551613ba50aea", "old_password": "123456", "new_password": "654321"}'

// Result
{
  "status": "success",
  "data": {
    "changed": true
  }
}

# create-account

创建账户以管理地址,单签账户只包含一个根公钥和一个签名数,多签账户可以包含多个根公钥和多个签名数,签名数的范围是[1, len(根公钥)]

# 请求参数

Object:

  • Array of String - root_xpubs, 根公钥列表,单签为一个,多签为多个
  • String - alias, 账户别名
  • Integer - quorum, 单签账户为1,多签账户小于根公钥数量,该参数用于签名时需要的最小数量
# 返回值
  • String - status, 状态信息
  • Object- data,
    • String - id, 账户id
    • String - alias, 账户名称
    • Integer - key_index, 账户序号(用相同密钥生成多个账户,第一个生成的账户为1,依次类推)
    • Integer - quorom, 签名数
    • Array of Object - xpubs, 公钥列表
    • String - derive_rule, 派生规则 0- BIP32,1 - BIP44
# 示例
// Request
curl -X POST create-account -d '{"root_xpubs":["2d6c07cb1ff7800b0793e300cd62b6ec5c0943d308799427615be451ef09c0304bee5dd492c6b13aaa854d303dc4f1dcb229f9578786e19c52d860803efa3b9a"],"quorum":1,"alias":"alice"}'

// Result
{
  "status": "success",
  "data": {
    "id": "4b5d460c-7773-4b6e-94ee-4d074df31729",
    "alias": "alice",
    "xpubs": [
  "6f9d945cd03cce033f4a2a9fd5659d3ddfa58e2d32f8c711baca0de0aae83ff6d67f4f4e53f3ff0b3c11bac2a11123c26c7c32e0478e6cf802ca1109941bb45b"
    ],
    "quorum": 1,
    "key_index": 1,
    "derive_rule": 1
  }
}

# list-accounts

查询账户列表

# 请求参数

可选

  • String - id, 账户id
  • String - alias, 账户名称
# 返回值
  • String - status, 状态信息
  • Array of Object, 账户列表.
    • Object- data
      • String - id, 账户id
      • String - alias, 账户别名
      • Integer - key_index, 账户序号(用相同密钥生成多个账户,第一个生成的账户为1,依次类推)
      • Integer - quorom, 签名数
      • Array of Object - xpubs, 公钥列表
      • String - derive_rule,派生规则 0- BIP32,1 - BIP44
# 示例
// Request
curl -X POST list-accounts -d '{"alias":"alice"}'

// Result
{
  "status": "success",
  "data": [
    {
      "id": "4b5d460c-7773-4b6e-94ee-4d074df31729",
      "alias": "alice",
      "xpubs": [
 "6f9d945cd03cce033f4a2a9fd5659d3ddfa58e2d32f8c711baca0de0aae83ff6d67f4f4e53f3ff0b3c11bac2a11123c26c7c32e0478e6cf802ca1109941bb45b"
      ],
      "quorum": 1,
      "key_index": 1,
      "derive_rule": 1
    }
  ]
}

# update-account-alias

为账户更新名称

# 请求参数
  • String - new_alias, 更新后的别名

以下二选一

  • String - account_alias, 账户别名
  • String - account_id, 账户id
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST update-account-alias -d '{"account_id": "65a47ef1-40f3-40a2-82d6-6c40e3e84e6c", "new_alias": "new_account"}'
or
curl -X POST update-account-alias -d '{"account_alias": "alice", "new_alias": "new_account"}'

// Result
{
  "status": "success"
}

# delete-account

删除账户,请确保账户中没有余额

# 请求参数

二选一:

  • String - account_alias, 账户别名
  • String - account_id, 账户id
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST delete-account -d '{"account_id": "65a47ef1-40f3-40a2-82d6-6c40e3e84e6c"}'
or
curl -X POST delete-account -d '{"account_alias": "alice"}'

// Result
{
  "status": "success"
}

# create-account-receiver

创建地址和控制程序(control program),地址和控制程序是一一对应的。

# 请求参数

二选一

  • String - account_alias, alias of account.
  • String - account_id, id of account.
# 返回值
  • String - status, 状态信息
  • Object - data
    • String - address, 账户地址
    • String - control_program, 账户控制程序.
# 示例

//Request

curl -X POST create-account-receiver -d '{"account_alias": "alice", "account_id": "65a47ef1-40f3-40a2-82d6-6c40e3e84e6c"}'

// Result

{
  "status": "success",
  "data": {
    "control_program": "00141e36aad4971c019c4602e6fb463bd7d7c7137e66",
    "address": "bn1qrcm244yhrsqec3szuma5vw7h6lr3xlnxk6l84h"
  }
}

# list-addresses

返回指定账户的地址列表

# 请求参数

二选一:

  • String - account_alias, alias of account.
  • String - account_id, id of account.

可选:

  • Integer - from, the start position of first address
  • Integer - count, the number of returned
# 返回值
  • String - status, 状态信息
  • Array of Object-data, 地址列表
    • Object
      • String - account_alias, 账户别名
      • String - account_id, 账户id
      • String - address, 账户地址
      • String - control_program, 账户控制程序
      • Boolean - change, 是否是找零地址
      • Integer - key_index,地址序号(用相同密钥生成多个地址,第一个生成的地址为1,依次类推)
# 示例
// Request
curl -X POST list-addresses -d '{"account_alias": "alice", "account_id": "65a47ef1-40f3-40a2-82d6-6c40e3e84e6c", "from": 0, "count": 3}'

// Result
{
  "status": "success",
  "data": [
    {
      "account_alias": "alice",
      "account_id": "2e91a178-9447-4984-b80b-d4f4b8360ae0",
      "address": "bn1qn7nv4pq0z6xavgkwfnsa02mg08l8thjmzn23av",
      "control_program": "00149fa6ca840f168dd622ce4ce1d7ab6879fe75de5b",
      "change": false,
      "key_index": 1
    },
    {
      "account_alias": "alice",
      "account_id": "2e91a178-9447-4984-b80b-d4f4b8360ae0",
      "address": "bn1q9j0kzs72pxc68jeva44su5mkw3p8eu85n75pxv",
      "control_program": "00142c9f6143ca09b1a3cb2ced6b0e537674427cf0f4",
      "change": false,
      "key_index": 2
    },
    {
      "account_alias": "alice",
      "account_id": "2e91a178-9447-4984-b80b-d4f4b8360ae0",
      "address": "bn1qrcm244yhrsqec3szuma5vw7h6lr3xlnxk6l84h",
      "control_program": "00141e36aad4971c019c4602e6fb463bd7d7c7137e66",
      "change": false,
      "key_index": 3
    }
  ]
}

# validate-address

验证地址合法性,同时判断是否是当前账户地址

# 请求参数
  • string - address, 地址
# 返回值
  • String - status, 状态信息
  • Object- data
    • Boolean - valid, 地址是否合法
    • Boolean - is_local, 是否是当前账户地址
# 示例
// Request
curl -X POST validate-address -d '{"address": "bn1q9j0kzs72pxc68jeva44su5mkw3p8eu85n75pxv"}'

// Result
{
  "status": "success",
  "data": {
    "valid": true,
    "is_local": true
  }
}

# get-mining-address

获取质押挖矿的收益地址

# 请求参数

none

# 返回值
  • String - status, 状态信息
  • Object- data
    • String - mining_address, 当前使用的质押挖矿收益地址
# 示例
// Request
curl -X POST get-mining-address

// Result
{
  "status": "success",
  "data": {
    "mining_address": "bn1qkyfkwgjwa84wfmtfccgp5msuka9hpqhl2afjuj"
  }
}

# set-mining-address

设置质押挖矿地址,无需本地钱包地址,必须确保地址格式正确

# 请求参数
  • String - mining_address, 设置质押挖矿地址
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - mining_address, 新的质押挖矿地址
# 示例
// Request
curl -X POST set-mining-address -d '{"mining_address":"bn1qkyfkwgjwa84wfmtfccgp5msuka9hpqhl2afjuj"}'


// Result
{
  "status": "success",
  "data": {
    "mining_address": "bn1qkyfkwgjwa84wfmtfccgp5msuka9hpqhl2afjuj"
  }
}

# list-pubkeys

查询账户下的公钥列表

# 请求参数
  • String - account_id, 账户id

可选

  • String - account_alias, 账户别名
  • string - public_key, 公钥
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - root_xpub, 根公钥
    • Array of Object -pubkey_infos, 派生公钥列表
      • String - pubkey, 派生公钥
      • Object - derivation_path, 派生路径
# 示例
// Request
curl -X POST list-pubkeys -d '{"account_id": "65a47ef1-40f3-40a2-82d6-6c40e3e84e6c"}'

// Result
{
  "status": "success",
  "data": {
    "root_xpub": "bec1040aa05d7da3c1fc7deeedaecf74e548d84588804f2bddf8d6cce0367d95bb0c180bb62449eb0e580499ee9955244b606a17664f46be6d23f3a65fe304e6",
    "pubkey_infos": [
      {
        "pubkey": "e14d663c7f02be9cbdaf2f2dc8263aa00c177239866f1be8eb30e041b5a50a99",
        "derivation_path": [
          "2c000000",
          "99000000",
          "01000000",
          "00000000",
          "01000000"
        ]
      },
      {
        "pubkey": "07edc2df1f8af18dd0f0254f35a57ee870ae9dce121e02b31edd10e6cbaec8f1",
        "derivation_path": [
          "2c000000",
          "99000000",
          "01000000",
          "00000000",
          "02000000"
        ]
      },
      {
        "pubkey": "01bdf0d40a9b9c7b38f570360f3147a30362c124551dc9fa9bac9ae6097316e0",
        "derivation_path": [
          "2c000000",
          "99000000",
          "01000000",
          "00000000",
          "03000000"
        ]
      },
      {
        "pubkey": "65ffffa87b338828119adb6cca0de02869e02f92a088bc82c4be54a083d88271",
        "derivation_path": [
          "2c000000",
          "99000000",
          "01000000",
          "00000000",
          "04000000"
        ]
      }
    ]
  }
}

# create-asset

创建资产定义,为资产上链做准备

# 请求参数
  • String - alias, 资产名称
  • Object - definition, 资产定义,可以为空

以下二选一

使用默认的资产创建合约程序

  • Array of String - root_xpubs, 公钥列表
  • Integer - quorum, 签名数,单签默认为1,多签不能多于公钥数,签名时不能少于该签名数

或者使用自定义的资产创建合约程序

  • String - issuance_program, 用户自定义的合约程序
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - id, 资产id
    • String - alias, 资产名称
    • String - issuance_program, 资产创建合约程序
    • Array of Object - xpubs,公钥列表
    • String - definition, 资产定义
    • Integer - quorum, 签名数,单签默认为1,多签不能多于公钥数,签名时不能少于该签名数
    • String - type, 资产类型,默认类型asset,BTM资产internal
    • Integer - key_index, 资产生成顺序,由该密钥创建第一个资产为1,依次类推
    • Integer - derive_rule, 派生规则 0- BIP32,1 - BIP44
    • Integer - vm_version, 虚拟机版本
    • String - raw_definition_byte, 资产定义的十六进制
    • Integer - limit_height, 超过该高度后无法增发
# 示例

用公钥创建

// Request
curl -X POST create-asset -d '{"alias": "GOLD", "root_xpubs": ["f6a16704f745a168642712060e6c5a69866147e21ec2447ae628f87d756bb68cc9b91405ad0a95f004090e864fde472f62ba97053ea109837bc89d63a64040d5"], "quorum":1}'

// Result
{
  "status": "success",
  "data": {
    "type": "asset",
    "xpubs": [
 "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7"
    ],
    "quorum": 1,
    "key_index": 1,
    "derive_rule": 0,
    "id": "4de79606de7845a979ebff195ced79a33eca25af55cf7ab06981d33fda7f2f99",
    "alias": "GOLD",
    "vm_version": 1,
    "issue_program": "ae20993984e9b86cea381424a3a1213fcd72cbeb3cddc8f34536ee979a27fe867c7d5151ad",
    "raw_definition_byte": "7b7d",
    "definition": {},
    "limit_height": 0
  }
}

用合约创建

// Request
curl -X POST create-asset -d '{"alias": "TESTASSET","issuance_program": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78160014c5a5b563c4623018557fb299259542b8739f6bc20163201e074b22ed7ae8470c7ba5d8a7bc95e83431a753a17465e8673af68a82500c22741a547a6413000000007b7b51547ac1631a000000547a547aae7cac00c0", "definition":{"name":"TESTASSET","symbol":"TESTASSET","decimals":8,"description":{}}}'

// Result
{
  "status": "success",
  "data": {
    "type": "",
    "xpubs": null,
    "quorum": 0,
    "key_index": 0,
    "derive_rule": 0,
    "id": "0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5",
    "alias": "TESTASSET",
    "vm_version": 1,
    "issue_program": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78160014c5a5b563c4623018557fb299259542b8739f6bc20163201e074b22ed7ae8470c7ba5d8a7bc95e83431a753a17465e8673af68a82500c22741a547a6413000000007b7b51547ac1631a000000547a547aae7cac00c0",
    "raw_definition_byte": "7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b7d2c0a2020226e616d65223a2022544553544153534554222c0a20202273796d626f6c223a2022544553544153534554220a7d",
    "definition": {
      "decimals": 8,
      "description": {},
      "name": "TESTASSET",
      "symbol": "TESTASSET"
    },
    "limit_height": 0
  }
}

# get-asset

通过资产id查询资产信息

# 请求参数
  • String - id,资产id
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - id, 资产id
    • String - alias, 资产名称
    • String - issuance_program, 资产创建合约程序
    • Array of Object - xpubs,公钥列表
    • String - definition, 资产定义
    • Integer - quorum, 签名数,单签默认为1,多签不能多于公钥数,签名时不能少于该签名数
    • String - type, 资产类型,默认类型asset,BTM资产internal
    • Integer - key_index, 资产生成顺序,由该密钥创建第一个资产为1,依次类推
    • Integer - derive_rule, 派生规则 0- BIP32,1 - BIP44
    • Integer - vm_version, 虚拟机版本
    • String - raw_definition_byte, 资产定义的十六进制
    • Integer - limit_height, 超过该高度后无法增发
# 示例
// Request
curl -X POST get-asset -d '{"id": "0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5"}'

// Result
{
  "status": "success",
  "data": {
    "type": "",
    "xpubs": null,
    "quorum": 0,
    "key_index": 0,
    "derive_rule": 0,
    "id": "0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5",
    "alias": "TESTASSET",
    "vm_version": 1,
    "issue_program": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78160014c5a5b563c4623018557fb299259542b8739f6bc20163201e074b22ed7ae8470c7ba5d8a7bc95e83431a753a17465e8673af68a82500c22741a547a6413000000007b7b51547ac1631a000000547a547aae7cac00c0",
    "raw_definition_byte": "7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b7d2c0a2020226e616d65223a2022544553544153534554222c0a20202273796d626f6c223a2022544553544153534554220a7d",
    "definition": {
      "decimals": 8,
      "description": {},
      "name": "TESTASSET",
      "symbol": "TESTASSET"
    },
    "limit_height": 0
  }
}

# list-assets

查询当前钱包所有的资产

# 请求参数

# 返回值
  • String - status, 状态信息
  • Array of Object, 资产列表
    • Object- data
      • String - id, 资产id
      • String - alias, 资产名称
      • String - issuance_program, 资产创建合约程序
      • Array of Object - xpubs,公钥列表
      • String - definition, 资产定义
      • Integer - quorum, 签名数,单签默认为1,多签不能多于公钥数,签名时不能少于该签名数
      • Array of Object - xpubs, 公钥列表
      • String - type, 资产类型,默认类型asset,BTM资产internal
      • Integer - vm_version, 虚拟机版本
      • String - raw_definition_byte, 资产定义的十六进制
      • Object - definition, 资产定义
      • Integer - key_index, 资产生成顺序,由该密钥创建第一个资产为1,依次类推
      • Integer - derive_rule, 派生规则 0- BIP32,1 - BIP44
      • Integer - limit_height, 超过该高度后无法增发
# 示例
// Request
curl -X POST list-assets -d {}

// Result
{
  "status": "success",
  "data": [
    {
      "type": "internal",
      "xpubs": null,
      "quorum": 0,
      "key_index": 0,
      "derive_rule": 0,
      "id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "alias": "BTM",
      "vm_version": 1,
      "issue_program": "",
      "raw_definition_byte": "7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a20224279746f6d204f6666696369616c204973737565222c0a2020226e616d65223a202242544d222c0a20202273796d626f6c223a202242544d220a7d",
      "definition": {
        "decimals": 8,
        "description": "Bytom Official Issue",
        "name": "BTM",
        "symbol": "BTM"
      },
      "limit_height": 0
    },
    {
      "type": "",
      "xpubs": null,
      "quorum": 0,
      "key_index": 0,
      "derive_rule": 0,
      "id": "0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5",
      "alias": "TESTASSET",
      "vm_version": 1,
      "issue_program": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78160014c5a5b563c4623018557fb299259542b8739f6bc20163201e074b22ed7ae8470c7ba5d8a7bc95e83431a753a17465e8673af68a82500c22741a547a6413000000007b7b51547ac1631a000000547a547aae7cac00c0",
      "raw_definition_byte": "7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b7d2c0a2020226e616d65223a2022544553544153534554222c0a20202273796d626f6c223a2022544553544153534554220a7d",
      "definition": {
        "decimals": 8,
        "description": {},
        "name": "TESTASSET",
        "symbol": "TESTASSET"
      },
      "limit_height": 0
    },
    {
      "type": "asset",
      "xpubs": [
        "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7"
      ],
      "quorum": 1,
      "key_index": 1,
      "derive_rule": 0,
      "id": "4de79606de7845a979ebff195ced79a33eca25af55cf7ab06981d33fda7f2f99",
      "alias": "GOLD",
      "vm_version": 1,
      "issue_program": "ae20993984e9b86cea381424a3a1213fcd72cbeb3cddc8f34536ee979a27fe867c7d5151ad",
      "raw_definition_byte": "7b7d",
      "definition": {},
      "limit_height": 0
    },
  ]
}

# update-asset-alias

根据资产id更新资产别名

# 请求参数
  • String - id,资产id
  • String - alias, 新的资产别名
# 返回值
  • String - status, 状态信息
# 示例

update asset alias.

// Request
curl -X POST update-asset-alias -d '{"id":"0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5", "alias":"testassets"}'

// Result
{
  "status": "success"
}

# list-balances

返回账户中所有资产的余额

# 请求参数

可选

  • String - account_id, 账户id
  • String - account_alias, 账户别名
# 返回值
  • String - status, 状态信息
  • Array of Object-data, 余额列表
    • Object
      • String - account_id, 账户id
      • String - account_alias, 账户别名
      • String - asset_id, 资产id
      • String - asset_alias, 资产别名
      • Integer - amount, 资产余额
      • Object - definition, 资产定义
# 示例
// Request
curl -X POST list-balances -d {}

// Result
{
  "status": "success",
  "data": [
    {
      "account_id": "6b8bd994-960d-4658-897c-4f5fed4c7f5b",
      "account_alias": "test",
      "asset_alias": "BTM",
      "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "amount": 581760572,
      "asset_definition": {
        "decimals": 8,
        "description": "Bytom Official Issue",
        "name": "BTM",
        "symbol": "BTM"
      }
    }
  ]
}
// Request
curl -X POST list-balances -d {"account_id":"65a47ef1-40f3-40a2-82d6-6c40e3e84e6c"}

// Result
{
  "status": "success",
  "data": [
    {
      "account_id": "65a47ef1-40f3-40a2-82d6-6c40e3e84e6c",
      "account_alias": "test",
      "asset_alias": "BTM",
      "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "amount": 499000000,
      "asset_definition": {
        "decimals": 8,
        "description": "Bytom Official Issue",
        "name": "BTM",
        "symbol": "BTM"
      }
    }
  ]
}

# list-unspent-outputs

查询钱包中的未花费的输出(UTXO)

# 请求参数

可选

  • String - id, 未花费输出id
  • Boolean - unconfirmed, 是否包含未被确认的输出
  • Boolean - smart_contract,是否包含合约中的未花费输出
  • Integer - from, 返回第一个未花费输出的位置
  • Integer - count,返回的未花费输出的数量
  • String - account_id, 账户id
  • String - account_alias, 账户别名
# 返回值
  • String - status, 状态信息
  • Array of Object, UTXO列表
    • Object:
      • String - account_id, 账户id
      • String - account_alias, 账户别名
      • String - asset_id, 资产id
      • String - asset_alias, 资产别名
      • Integer - amount, 资产余额
      • String - address, 账户地址
      • Boolean - change, 是否是找零
      • String - id, 未花费输出的id
      • String - program, 账户控制程序
      • String - control_program_index, 账户控制程序索引
      • String - source_id, 前一个未花费输出的id
      • String - source_pos, 前一个未花费输出在区块中的位置
      • String - valid_height, 可被花费的高度(该高度之前未被确认,不可使用)
      • Integer-derive_rule,派生方式
# 示例
// Request
curl -X POST list-unspent-outputs -d {}

// Result
{
  "status": "success",
  "data": [
    {
      account_alias": "test",
      "id": "ebf16bba6f4745f655d86d3bc2c5de79ae26845429b7a2ab425fcc609c8adc5e",
      "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "asset_alias": "BTM",
      "amount": 100000000,
      "account_id": "6b8bd994-960d-4658-897c-4f5fed4c7f5b",
      "address": "bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr",
      "control_program_index": 1,
      "program": "0014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b35",
      "source_id": "bd2bce3858decfc86f282267ec4bb8da40cdd9dbda8b98a67576702afb49fdd6",
      "source_pos": 1,
      "valid_height": 30011,
      "change": false,
      "derive_rule": 0
    }
  ]
}

通过指定id查询未花费输出UTXO

// Request
curl -X POST list-unspent-outputs -d '{"id": "8e84b6a3047e00a4c740d2741ad4cdbfa2aa74da774c3271f6f14376f0afa34c"}'

// Result
{
  "status": "success",
  "data": [
    {
      "account_alias": "test",
      "id": "8e84b6a3047e00a4c740d2741ad4cdbfa2aa74da774c3271f6f14376f0afa34c",
      "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "asset_alias": "BTM",
      "amount": 499000000,
      "account_id": "65a47ef1-40f3-40a2-82d6-6c40e3e84e6c",
      "address": "bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr",
      "control_program_index": 1,
      "program": "001433cc42c8598e5b0bdf42a20c338c7a95aa535f79",
      "source_id": "d4d47100a40069edb2541a820de335bc22093008d5ffb6b823ad11ebc6b42865",
      "source_pos": 0,
      "valid_height": 0,
      "change": false,
      "derive_rule": 0
    }
  ]
}

# backup-wallet

将钱包备份成镜像文件,包含账户,资产和密钥镜像

# 请求参数

# 返回值
  • String - status, 状态信息
  • Object - data
    • Object - account_image, 账户镜像
    • Object - asset_image, 资产镜像.
    • Object - key_images, 密钥镜像.
# 示例
// Request
curl -X backup-wallet -d {}

// Result
{
  "status": "success",
  "data": {
    "account_image": {
      "slices": [
        {
          "account": {
            "type": "account",
            "xpubs": [
              "cc5ef9e9bb71968bbfa94536874570bd765ba08f5492882c794c8f73f8af7791cfd6d2945ea18a3177dbdd82460763cf2958128e4531c440238ee1e065d219a6"
            ],
            "quorum": 1,
            "key_index": 1,
            "derive_rule": 1,
            "id": "2e91a178-9447-4984-b80b-d4f4b8360ae0",
            "alias": "alice"
          },
          "contract_index": 0
        },
        {
          "account": {
            "type": "account",
            "xpubs": [
              "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7"
            ],
            "quorum": 1,
            "key_index": 1,
            "derive_rule": 1,
            "id": "6b8bd994-960d-4658-897c-4f5fed4c7f5b",
            "alias": "test"
          },
          "contract_index": 0
        }
      ]
    },
    "asset_image": {
      "assets": [
        {
          "id": "0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5",
          "alias": "TESTASSETS",
          "vm_version": 1,
          "issue_program": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78160014c5a5b563c4623018557fb299259542b8739f6bc20163201e074b22ed7ae8470c7ba5d8a7bc95e83431a753a17465e8673af68a82500c22741a547a6413000000007b7b51547ac1631a000000547a547aae7cac00c0",
          "raw_definition_byte": "7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b7d2c0a2020226e616d65223a2022544553544153534554222c0a20202273796d626f6c223a2022544553544153534554220a7d",
          "definition": {
            "decimals": 8,
            "description": {},
            "name": "TESTASSET",
            "symbol": "TESTASSET"
          }
        },
        {
          "type": "asset",
          "xpubs": [
 "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7"
          ],
          "quorum": 1,
          "key_index": 1,
          "derive_rule": 0,
          "id": "4de79606de7845a979ebff195ced79a33eca25af55cf7ab06981d33fda7f2f99",
          "alias": "GOLD",
          "vm_version": 1,
          "issue_program": "ae20993984e9b86cea381424a3a1213fcd72cbeb3cddc8f34536ee979a27fe867c7d5151ad",
          "raw_definition_byte": "7b7d",
          "definition": null
        },
        {
          "type": "asset",
          "xpubs": [
            "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7"
          ],
          "quorum": 1,
          "key_index": 2,
          "derive_rule": 0,
          "id": "9de35c8265397db20cd7002e5dd458f9f6366b82256724f1147f522e2cba40b1",
          "alias": "SILVE",
          "vm_version": 1,
          "issue_program": "ae20a4873501792ce6f44d27e5a0efa11db98e13e95b320e5b40a5b15cde1343ac3d5151ad",
          "raw_definition_byte": "7b7d",
          "definition": null
        }
      ]
    },
    "key_images": {
      "xkeys": [
        {
          "crypto": {
            "cipher": "aes-128-ctr",
            "ciphertext": "ebbd1b1f7f597ef6267ca315fbff0f85be8fead6d798c459711e30f169d8db4e2705eac6f6f9e4e162a5e08f9d5e2080024f7db1a35fb95c5dee9a73e5bcba19",
            "cipherparams": {
              "iv": "7080b540bb0d64f5b9add924397ff876"
            },
            "kdf": "scrypt",
            "kdfparams": {
              "dklen": 32,
              "n": 4096,
              "p": 6,
              "r": 8,
              "salt": "c7f29540fe29646c9783d3242dd33c5077cc17e1853b0ef9831580b9e351f50f"
            },
            "mac": "79cfcc3891062eba9f7ed8fb97763f6cec5204b353a4ebb760b3185d3f19b32a"
          },
          "id": "5a68ae8c-3d6b-4be4-bbca-f7e3209b56f4",
          "type": "bytom_kd",
          "version": 1,
          "alias": "test",
          "xpub": "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7"
        },
        {
          "crypto": {
            "cipher": "aes-128-ctr",
            "ciphertext": "2e5c165a871b3842c7b8eb3c4a3c2051a4e4b10efe5f07406fe3a1b9f1272358ac500b32522c63554433dd34f85393cd36049e7d7d2af4f33f0fcf9ba5515dba",
            "cipherparams": {
              "iv": "9c52fc9b535478c8104350590a66d8ec"
            },
            "kdf": "scrypt",
            "kdfparams": {
              "dklen": 32,
              "n": 4096,
              "p": 6,
              "r": 8,
              "salt": "23d59b94fe5af02195afe5b8d8edff79320fb5b8ac6c0cadaae336e786dbf19e"
            },
            "mac": "59247979d257d0b83dc5e0ff99b624fccb47037bb75e004c6ae1aad0a0fbc248"
          },
          "id": "f42e72ff-5d5d-4b17-81e2-d407b507393e",
          "type": "bytom_kd",
          "version": 1,
          "alias": "alice",
          "xpub": "cc5ef9e9bb71968bbfa94536874570bd765ba08f5492882c794c8f73f8af7791cfd6d2945ea18a3177dbdd82460763cf2958128e4531c440238ee1e065d219a6"
        },
        {
          "crypto": {
            "cipher": "aes-128-ctr",
            "ciphertext": "31f841b5b71348d110ceaa744b6d34b04001e8d855572278fc89fbdc0c848924e84fd28000936317604520153c42d92eed7c207bb294c76f3d5bd1c92e3cd04e",
            "cipherparams": {
              "iv": "5136cc06d7ab727e8b3dc292f2c3388d"
            },
            "kdf": "scrypt",
            "kdfparams": {
              "dklen": 32,
              "n": 4096,
              "p": 6,
              "r": 8,
              "salt": "5e6a3d82d673174a6bd4fc04ceec1a129e882158cf4937051a3793b24c9a44d0"
            },
            "mac": "a145a90b6778dac4c1433420c96eb498d2ba24fb7916d4b31199be789f257238"
          },
          "id": "de1353ee-9c5f-4bcd-9023-f08805bd8c2c",
          "type": "bytom_kd",
          "version": 1,
          "alias": "alice2",
          "xpub": "adb65c15d6d4309417295b912590481b11aa5f9046f8ad79419b5dbc02a397fa47d2bcbd3cd9d8c48ab92c2bb8651d61aed98395bd39fc2dc811ae279dd1e462"
        }
      ]
    }
  }
}

# restore-wallet

通过镜像文件恢复钱包

# 请求参数
  • Object - account_image, 账户镜像
  • Object - asset_image, 资产镜像.
  • Object - key_images, 密钥镜像
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST restore-wallet -d '{"account_image":{"slices":[{"account":{"type":"account","xpubs":["395d6e0ac25978c3f52f9c7bdfdf75ce6af02639fd7875b4b1f40778ab1120c6dcf461b7ab6fd310983afb54a9a0fb3e09b6ec0d4364c4808c94383d50fb0681"],"quorum":1,"key_index":1,"ID":"0CQTA3EOG0A02","Alias":"def"},"contract_index":2}]},"asset_image":{"assets":[]},"key_images":{"xkeys":[{"crypto":{"cipher":"aes-128-ctr","ciphertext":"bf44766fec149478af9500e25ce0a6bc50bb2fa04e40465781da6ff64e9b3a4c9af3d214cd92c5a41d8498db5f4376526740f960ff429b16e52876aec6860e1d","cipherparams":{"iv":"1b0fc61ae4dacb15f0f77d2b4ba67635"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"e133b1e7caae771ff1ab34b14824d6e27ef399f2b7ded4ad3500f080ede4a1dd"},"mac":"bc6bf411fb63e61a17bc15b94f29cf0d5a0f084c328955da1f7e2b26757cfc23"},"id":"1f40be59-7400-4fdc-b46b-15009f65363a","type":"bytom_kd","version":1,"alias":"default","xpub":"c4ec9bfd5df19d175e17ff7fed89193c37a4a64e1c0928387da01387ca76c3bfd99390e3373ec4d438522cc2d4644214cd2ec3b00965f7a1fa3546809583191c"},{"crypto":{"cipher":"aes-128-ctr","ciphertext":"f0887c8603cbbafc0a66d5b45f71488e089708c7dea4342625a67858a49d6d08c79cd3f1800627e3c8b4668e8df34fcf0be9df5d9d4503acff05373976c312a9","cipherparams":{"iv":"c111b46f9104f49f2c40aedb827e53b5"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"d9ef588b258b111dea1d99a4e4c5a4f968ab69072176bb95b111922e3bbea9e6"},"mac":"336f5fee643776e139f05ebe5e4f209d992ff97e16b906105fadac9e86133554"},"id":"611d407c-9e97-4297-a02a-13cd68e47983","type":"bytom_kd","version":1,"alias":"def","xpub":"395d6e0ac25978c3f52f9c7bdfdf75ce6af02639fd7875b4b1f40778ab1120c6dcf461b7ab6fd310983afb54a9a0fb3e09b6ec0d4364c4808c94383d50fb0681"}]}}'

// Result
{
  "status": "success"
}

# rescan-wallet

扫描区块信息来更新相关钱包的资产和余额

# 请求参数

# 返回值
  • String - status,状态信息
# 示例
// Request
curl -X POST rescan-wallet -d '{}'

// Result
{
  "status": "success"
}

# recovery-wallet

通过根公钥恢复钱包 确定性钱包的 bip44 多账户层次结构的所有账户和余额都可以通过 root xpubs 恢复。

# 请求参数

Object:

  • Object - xpubs, 根公钥
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST recovery-wallet -d '{ "xpubs":["c536a2c11fafd8278e02e9393dcbf5aa420eb51a1761a7e5da7f2b9b37969b52a8f8e2b692e7dcaf79dfa0d1e28c63eb9fda42942f20feaa8a71b383d9a4668c"]}'

// Result
{
    "status": "success"
}

# wallet-info

返回钱包信息

# 请求参数

# 返回值
  • String - status, 状态信息
  • Object - data
    • Integer - best_block_height, current block height.
    • Integer - wallet_height, current block height for wallet.
# 示例
// Request
curl -X POST wallet-info -d '{}'

// Result
{
  "status": "success",
  "data": {
    "best_block_height": 25861,
    "wallet_height": 25861
  }
}

# sign-message

对消息进行签名

# 请求参数
  • String - address, 用来签名的地址
  • String - message, 待签名的消息,必须是HEX格式
  • String - password, 密钥密码
# 返回值
  • String - status, 状态信息
  • Object - data
    • String - derived_xpub, 派生公钥
    • String - signature, 签名后的消息
# 示例
// Request
curl -X POST sign-message -d '{"address":"bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr", "message":"6d657373616765", "password":"123456"}'

// Result
{
  "status": "success",
  "data": {
    "signature": "0fb3f4b25536172cd332db53dba97e318393924d6f892ecc3d2624494ea754375541bfd9f74a3fdc5eb60c49087596e8814b0c738eecd25f13e9a7ee74577b09",
    "derived_xpub": "e231f38c7652312e2e68b1c30eb08bff5e957995e11c5f27126a5411fd5e4df9c71145e483c1ee3f04b6d5f7746a0693be6a6d148359f40a2d5f111344727946"
  }
}

# decode-program

解码控制程序

# 请求参数
  • String - program, 账户的控制程序
# 返回值
  • String - status, 状态信息
  • Object - data
    • String - instructions, 控制程序的指令和数据
# 示例
// Request
curl -X POST decode-program -d '{"program":"0014a86c83ee12e6d790fb388345cc2e2b87056a0773"}'

// Result
{
  "status": "success",
  "data": {
    "instructions": "DUP \nHASH160 \nDATA_20 a86c83ee12e6d790fb388345cc2e2b87056a0773\nEQUALVERIFY \nTXSIGHASH \nSWAP \nCHECKSIG \n"
  }
}

# get-transaction

使用交易id查询交易信息

# 请求参数
  • String - tx_id, 交易id
# 返回值
  • String - status, 状态信息
  • Object - data
    • String - tx_id, 交易id
    • Integer - block_time, 区块产生的时间
    • String - block_hash, 该交易所处的区块哈希
    • Integer - block_height,该交易所处的区块高度
    • Integer - block_index, 该交易所处的区块中的位置
    • Integer - block_transactions_count,区块中交易数量
    • Integer - size, 交易体积
    • Array of Object - inputs, 交易的输入列表
      • String - type, 输入类型,包括花费输入'spend', 资产发行输入 'issue', 出块输入'coinbase, '取消投票输入'veto' .
      • String - asset_id, 资产id
      • String - asset_alias, 资产别名
      • Object - asset_definition, 资产定义
      • Integer - amount, 资产数量
      • Object - issuance_program, 资产发行程序,只有在输入类型是 'issue'时存在
      • Object - control_program, 花费控制程序, 只有在输入类型是'spend'时存在
      • String - address, 账户地址, 只有在输入类型是'spend'时存在
      • String - spent_output_id,该输入指向的前一个输出, 只有在输入类型是'spend'时存在
      • String - account_id, 账户id
      • String - account_alias, 账户名称
      • Object - arbitrary, 附加信息,只有在输入类型是'coinbase'时存在
      • String - input_id, 输入id
      • Array of String - witness_arguments, 隔离见证参数,存签名信息
      • String - sign_data, 输入的签名数据
      • String - vote, 投票的节点公钥,只有在输入类型是'veto'时存在
    • Array of Object - outputs, 交易的输出列表
      • String - type, 输出类型,包括删除输出'retire',收款输出 'control',投票输出 'vote'.
      • String - id, 输出的id
      • Integer - position, 输出处于交易中的位置
      • String - asset_id, 资产id
      • String - asset_alias, 资产别名
      • Object - asset_definition,资产定义
      • Integer - amount, 资产数量
      • String - account_id, 账户id
      • String - account_alias, 账户别名
      • Object - control_program, 账户的控制程序
      • String - address, 账户的地址
      • String - vote, 投票的节点公钥,只有在输入类型是'vote'时存在
# 示例
// Request
curl -X POST get-transaction -d '{"tx_id": "dcaf26fd91c8f6ac6fa542ecbf024f0419788c89006c60d6f441f13c6a96673b"}'

// Result
{
  "status": "success",
  "data": {
    "tx_id": "dcaf26fd91c8f6ac6fa542ecbf024f0419788c89006c60d6f441f13c6a96673b",
    "block_time": 1629442644000,
    "block_hash": "9947f53d10c635f08f2906756cb173777a92b4ca4316812eaa6eebfdf9882156",
    "block_height": 812,
    "block_index": 1,
    "block_transactions_count": 2,
    "inputs": [
      {
        "type": "spend",
        "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
        "asset_alias": "BTM",
        "asset_definition": {
          "decimals": 8,
          "description": "Bytom Official Issue",
          "name": "BTM",
          "symbol": "BTM"
        },
        "amount": 223096731217,
        "control_program": "0014c28fede9076c2bbc719c7fce59ef1a10baadcb5d",
        "address": "bn1qc287m6g8ds4mcuvu0l89nmc6zza2mj6atwflw5",
        "spent_output_id": "9df43c51ce03c8e80b0702810b128909d5d24e83b4340e798bb5d3881d4cdfc7",
        "input_id": "cb3d07210d68f95d3fd669e4bcf9fe4214e1e0f579efa3371bf856521814be79",
        "witness_arguments": [
          "5b278f01c5cb2670d8f754f96f12471d036acce26aaf312b1a2b8c7b2afa33ae5934f91fa96d1e9a2c02ccbaa2b305d5bd90f93c608391f0f0e94e64324e8c09",
          "79efe42f0dbc49b84acf91b8c33f16c94a9a8a75fd3ffdbc7553766f00f275e1"
        ],
        "sign_data": "435328252f3c2dce3d2bf1de372a085aa5a55368166641a89a03b01a48bad381"
      }
    ],
    "outputs": [
      {
        "type": "control",
        "id": "be087ac077ddeeb32a00946d39beff0e35a1be3711d4da4574d4dd3d5979d861",
        "position": 0,
        "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
        "asset_alias": "BTM",
        "asset_definition": {
          "decimals": 8,
          "description": "Bytom Official Issue",
          "name": "BTM",
          "symbol": "BTM"
        },
        "amount": 500000000,
        "account_id": "6b8bd994-960d-4658-897c-4f5fed4c7f5b",
        "account_alias": "test",
        "control_program": "0014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b35",
        "address": "bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr"
      },
      {
        "type": "control",
        "id": "79ab17691fb9a0e0a61f3defa1977801d4e4cd278614ab2b9f841340eb24f5fb",
        "position": 1,
        "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
        "asset_alias": "BTM",
        "asset_definition": {
          "decimals": 8,
          "description": "Bytom Official Issue",
          "name": "BTM",
          "symbol": "BTM"
        },
        "amount": 222596282217,
        "control_program": "0014c28fede9076c2bbc719c7fce59ef1a10baadcb5d",
        "address": "bn1qc287m6g8ds4mcuvu0l89nmc6zza2mj6atwflw5"
      }
    ],
    "size": 340
  }
}

# list-transactions

根据输入参数查询一组交易

# 请求参数

可选

  • String - id, 交易id
  • String - account_id, 账户id
  • Boolean - detail ,是否包含交易详细信息,默认false返回摘要信息,true则返回详细信息
  • Boolean - unconfirmed, 是否包含未确认交易,默认false不返回,true返回
  • Integer - from, 第一笔交易的序号
  • Integer - count, 返回交易数量
# 返回值
  • String - status, 状态信息

交易摘要信息

  • Array of Object- data
    • Object:(summary transaction)
      • String - tx_id, 交易hash
      • Integer - block_time, 区块产生的时间
      • Array of Object - inputs, 输入的摘要信息
        • String - type, 输入类型,包括花费输入'spend', 资产发行输入 'issue', 出块输入'coinbase, '取消投票输入'veto'
        • String - asset_id, 资产id
        • String - asset_alias, 资产别名
        • Integer - amount, 资产数量
        • Object - arbitrary, 附加信息,只有在输入类型是'coinbase'时存在
      • Array of Object - outputs, 输出的摘要信息
        • String - type,包括删除输出'retire',收款输出 'control',投票输出 'vote'.
        • String - asset_id, 资产id
        • String - asset_alias,资产别名
        • Integer - amount, 资产数量

交易详细信息

  • Array of Object- data
    • String - tx_id, 交易id
    • Integer - block_time, 区块产生的时间
    • String - block_hash, 该交易所处的区块哈希
    • Integer - block_height,该交易所处的区块高度
    • Integer - block_index, 该交易所处的区块中的位置
    • Integer - block_transactions_count,区块中交易数量
    • Integer - size, 交易体积
    • Array of Object - inputs, 交易的输入列表
      • String - type, 输入类型,包括花费输入'spend', 资产发行输入 'issue', 出块输入'coinbase, '取消投票输入'veto'
      • String - asset_id, 资产id
      • String - asset_alias, 资产别名
      • Object - asset_definition, 资产定义
      • Integer - amount, 资产数量
      • Object - issuance_program, 资产发行程序,只有在输入类型是 'issue'时存在
      • Object - control_program, 花费控制程序, 只有在输入类型是'spend'时存在
      • String - address, 账户地址, 只有在输入类型是'spend'时存在
      • String - spent_output_id,该输入指向的前一个输出, 只有在输入类型是'spend'时存在
      • String - account_id, 账户id
      • String - account_alias, 账户名称
      • Object - arbitrary, 附加信息,只有在输入类型是'coinbase'时存在
      • String - input_id, 输入id
      • Array of String - witness_arguments, 隔离见证参数,存签名信息
      • String - sign_data, 输入的签名数据
      • String - vote, 投票的节点公钥,只有在输入类型是'veto'时存在
    • Array of Object - outputs, 交易的输出列表
      • String - type, 输出类型,包括删除输出'retire',收款输出 'control',投票输出 'vote'.
      • String - id, 输出的id
      • Integer - position, 输出处于交易中的位置
      • String - asset_id, 资产id
      • String - asset_alias, 资产别名
      • Object - asset_definition,资产定义
      • Integer - amount, 资产数量
      • String - account_id, 账户id
      • String - account_alias, 账户别名
      • Object - control_program, 账户的控制程序
      • String - address, 账户的地址
      • String - vote, 投票的节点公钥,只有在输入类型是'vote'时存在
# 示例
// Request
curl -X POST list-transactions -d {}

// Result
{
      "tx_id": "dcaf26fd91c8f6ac6fa542ecbf024f0419788c89006c60d6f441f13c6a96673b",
      "block_time": 1629442644000,
      "inputs": [
        {
          "type": "spend",
          "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
          "asset_alias": "BTM",
          "amount": 223096731217
        }
      ],
      "outputs": [
        {
          "type": "control",
          "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
          "asset_alias": "BTM",
          "amount": 500000000,
          "account_id": "6b8bd994-960d-4658-897c-4f5fed4c7f5b",
          "account_alias": "test"
        },
        {
          "type": "control",
          "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
          "asset_alias": "BTM",
          "amount": 222596282217
        }
      ]
    }
// Request
curl -X POST list-transactions -d '{"id": "dcaf26fd91c8f6ac6fa542ecbf024f0419788c89006c60d6f441f13c6a96673b","detail": true}'

// Result
{
  "status": "success",
  "data": [
    {
      "tx_id": "dcaf26fd91c8f6ac6fa542ecbf024f0419788c89006c60d6f441f13c6a96673b",
      "block_time": 1629442644000,
      "block_hash": "9947f53d10c635f08f2906756cb173777a92b4ca4316812eaa6eebfdf9882156",
      "block_height": 812,
      "block_index": 1,
      "block_transactions_count": 2,
      "inputs": [
        {
          "type": "spend",
          "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
          "asset_alias": "BTM",
          "asset_definition": {
            "decimals": 8,
            "description": "Bytom Official Issue",
            "name": "BTM",
            "symbol": "BTM"
          },
          "amount": 223096731217,
          "control_program": "0014c28fede9076c2bbc719c7fce59ef1a10baadcb5d",
          "address": "bn1qc287m6g8ds4mcuvu0l89nmc6zza2mj6atwflw5",
          "spent_output_id": "9df43c51ce03c8e80b0702810b128909d5d24e83b4340e798bb5d3881d4cdfc7",
          "input_id": "cb3d07210d68f95d3fd669e4bcf9fe4214e1e0f579efa3371bf856521814be79",
          "witness_arguments": [
            "5b278f01c5cb2670d8f754f96f12471d036acce26aaf312b1a2b8c7b2afa33ae5934f91fa96d1e9a2c02ccbaa2b305d5bd90f93c608391f0f0e94e64324e8c09",
            "79efe42f0dbc49b84acf91b8c33f16c94a9a8a75fd3ffdbc7553766f00f275e1"
          ],
          "sign_data": "435328252f3c2dce3d2bf1de372a085aa5a55368166641a89a03b01a48bad381"
        }
      ],
      "outputs": [
        {
          "type": "control",
          "id": "be087ac077ddeeb32a00946d39beff0e35a1be3711d4da4574d4dd3d5979d861",
          "position": 0,
          "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
          "asset_alias": "BTM",
          "asset_definition": {
            "decimals": 8,
            "description": "Bytom Official Issue",
            "name": "BTM",
            "symbol": "BTM"
          },
          "amount": 500000000,
          "account_id": "6b8bd994-960d-4658-897c-4f5fed4c7f5b",
          "account_alias": "test",
          "control_program": "0014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b35",
          "address": "bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr"
        },
        {
          "type": "control",
          "id": "79ab17691fb9a0e0a61f3defa1977801d4e4cd278614ab2b9f841340eb24f5fb",
          "position": 1,
          "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
          "asset_alias": "BTM",
          "asset_definition": {
            "decimals": 8,
            "description": "Bytom Official Issue",
            "name": "BTM",
            "symbol": "BTM"
          },
          "amount": 222596282217,
          "control_program": "0014c28fede9076c2bbc719c7fce59ef1a10baadcb5d",
          "address": "bn1qc287m6g8ds4mcuvu0l89nmc6zza2mj6atwflw5"
        }
      ],
      "size": 340
    }
  ]
}

# build-transaction

根据输入参数构建一笔交易

# 请求参数

Object:

  • String - base_transaction, 交易基础数据,默认为空
  • Integer - ttl, 交易存活时间,UTXO在交易存活时间内会被锁定,不能用于构建另外一笔交易。如果在超过ttl时间未被提交上链,则UTXO会被自动解锁。默认的ttl为0,即不会被解锁。但钱包会每隔24小时清理这些ttl为0,但一直不提交上链的交易
  • Integer - time_range,指定的某个区块高度,在这个高度之前打包有效,如果超过这个高度就不会再被打包
  • Arrary of Object - actions: 操作
    • Object:
      • String - account_id | account_alias, 操作类型是spend_account,需要输入账户id或者账户别名
      • String - asset_id | asset_alias, 输入资产id或者资产别名
      • Integer - amount, 发送资产的数量
      • String- type,交易类型, 花费账户资产 'spend_account',创建资产 'issue', 指定UTXO来花费资产 'spend_account_unspent_output',发送资产到指定地址 'control_address',发送资产到指定程序 'control_program',删除资产 'retire',投票交易 'vote_output',取消投票交易'veto',注册合约交易'register_contract'
      • String - address, 接收者的地址,交易类型为 'control_address'
      • String - control_program, 接收者的控制程序,交易类型为'control_address'
      • String - use_unconfirmed, 是否使用未确认的UTXO,默认为false,交易类型为 'spend_account_unspent_output'
      • String - arbitrary, 额外的附加信息,交易类型是 'retire'
      • Arrary of Object - arguments, 合约参数,交易类型是 'issue'或者'spend_account_unspent_output,如果是非合约则为空
        • String- type, 参数类型, 包含'raw_tx_signature', 'data'两种
        • Object- raw_data,参数
          • String- xpub, 根公钥(类型是raw_tx_signature)
          • String- derivation_path, 派生路径(类型是 raw_tx_signature)
          • String- value, 二进制值(类型是data)
# 返回值
  • String - status, 状态信息
  • Object-data
    • Object - raw_transaction, 构建完成的原始交易
    • Object - signing_instructions,签名结构,用于签名交易的信息
# 示例
  • spend - 交易类型是spend
// Request
curl -X POST build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"6b8bd994-960d-4658-897c-4f5fed4c7f5b","amount":1000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"account_id":"6b8bd994-960d-4658-897c-4f5fed4c7f5b","amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","address":"bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr","type":"control_address"}],"ttl":0,"time_range": 43432}'
  • issue - 交易类型是issue
// Request
curl -X POST build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"6b8bd994-960d-4658-897c-4f5fed4c7f5b","amount":1000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"amount":10000,"asset_id":"0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5","type":"issue"},{"amount":10000,"asset_id":"0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5","address":"bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr","type":"control_address"}],"ttl":0,"time_range": 43432}'
  • address - 交易类型是address
// Request
curl -X POST build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"6b8bd994-960d-4658-897c-4f5fed4c7f5b","amount":1000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"account_id":"6b8bd994-960d-4658-897c-4f5fed4c7f5b","amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","address":"bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr","type":"control_address"}],"ttl":0,"time_range": 43432}'
  • retire - 交易类型是retire
// Request
curl -X POST build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"6b8bd994-960d-4658-897c-4f5fed4c7f5b","amount":1000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"account_id":"6b8bd994-960d-4658-897c-4f5fed4c7f5b","amount":99,"asset_id":"0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5","type":"spend_account"},{"amount":99,"asset_id":"0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5","arbitrary":"77656c636f6d65efbc8ce6aca2e8bf8ee69da5e588b0e58e9fe5ad90e4b896e7958c","type":"retire"}],"ttl":0,"time_range":43432}'
  • spend_account_unspent_output - 交易类型是spend_account_unspent_output(用户可以通过 list-unspent-outputs API获取UTXO列表)

注意:交易费用等于UTXO总数-输出的资产总数

// Request
curl -X POST build-transaction -d '{"base_transaction":null,"actions":[{"type":"spend_account_unspent_output","output_id":"ebf16bba6f4745f655d86d3bc2c5de79ae26845429b7a2ab425fcc609c8adc5e"},{"amount":1000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","address":"bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr","type":"control_address"}],"ttl":0,"time_range":0}'
{
  "status": "success",
  "data": {
    "raw_transaction": "0701000101a101035ebd2bce3858decfc86f282267ec4bb8da40cdd9dbda8b98a67576702afb49fdd6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c2d72f0101160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350040c8a73062a39dccc889dd8a4eaec5aecc352b7fc584469a768d9afe8368f1cfb45d7e50607f374f817638532ff3af854c3c030329ac3e8b242a5876cfe407262b01000101003cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0843d01160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350000",
    "signing_instructions": [
      {
        "position": 0,
        "witness_components": [
          {
            "type": "raw_tx_signature",
            "quorum": 1,
            "keys": [
              {
                "xpub": "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7",
                "derivation_path": [
                  "2c000000",
                  "99000000",
                  "01000000",
                  "00000000",
                  "01000000"
                ]
              }
            ],
            "signatures": null
          },
          {
            "type": "data",
            "value": "e231f38c7652312e2e68b1c30eb08bff5e957995e11c5f27126a5411fd5e4df9"
          }
        ]
      }
    ],
    "fee": 99000000,
    "allow_additional_actions": false
  }
}

# build-chain-transactions

构建链式交易,为了减少UTXO太碎带来的交易失败问题,通过链式交易自动将UTXO合并

# 请求参数
  • String - base_transaction, 交易基础数据,默认为空
  • Integer - ttl, 交易存活时间,UTXO在交易存活时间内会被锁定,不能用于构建另外一笔交易。如果在超过ttl时间未被提交上链,则UTXO会被自动解锁。默认的ttl为0,即不会被解锁。但钱包会每隔24小时清理这些ttl为0,但一直不提交上链的交易
  • Integer - time_range,指定的某个区块高度,在这个高度之前打包有效,如果超过这个高度就不会再被打包
  • Arrary of Object - actions: 操作
    • Object:
      • String - account_id | account_alias, 操作类型是spend_account,需要输入账户id或者账户别名
      • String - asset_id | asset_alias, 输入资产id或者资产别名
      • Integer - amount, 发送资产的数量
      • String- type,交易类型, 花费账户资产 'spend_account',创建资产 'issue', 指定UTXO来花费资产 'spend_account_unspent_output',发送资产到指定地址 'control_address',发送资产到指定程序 'control_program',删除资产 'retire',投票交易 'vote_output',取消投票交易'veto',注册合约交易'register_contract'
      • String - address, 接收者的地址,交易类型为 'control_address'
      • String - control_program, 接收者的控制程序,交易类型为'control_address'
      • String - use_unconfirmed, 是否使用未确认的UTXO,默认为false,交易类型为 'spend_account_unspent_output'
      • String - arbitrary, 额外的附加信息,交易类型是 'retire'
      • Arrary of Object - arguments, 合约参数,交易类型是 'issue'或者'spend_account_unspent_output,如果是非合约则为空
        • String- type, 参数类型, 包含'raw_tx_signature', 'data'两种
        • Object- raw_data,参数
          • String- xpub, 根公钥(类型是raw_tx_signature)
          • String- derivation_path, 派生路径(类型是 raw_tx_signature)
          • String- value, 二进制值(类型是data)
# 返回值
  • String - status, 状态信息
  • Object-data
    • Object - raw_transaction, 构建完成的原始交易
    • Object - signing_instructions,签名结构,用于签名交易的信息
# 示例
// Request
curl -X POST localhost:9888/build-chain-transactions -d '{"base_transaction":null,"actions":[{"account_id":"6b8bd994-960d-4658-897c-4f5fed4c7f5b","amount":1000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"account_id":"6b8bd994-960d-4658-897c-4f5fed4c7f5b","amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","address":"bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr","type":"control_address"}],"ttl":0,"time_range": 43432}'
// Result
{
  "status": "success",
  "data": [
    {
      "raw_transaction": "070100010160015e1d677df0a501a4f235d3a6170c296698bcfe16e32b3a1989414006a86fda6854ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8092f4010001160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350001000201003dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdd8cb70101160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b35000001003affffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6301160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350000",
      "signing_instructions": [
        {
          "position": 0,
          "witness_components": [
            {
              "type": "raw_tx_signature",
              "quorum": 1,
              "keys": [
                {
                  "xpub": "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7",
                  "derivation_path": [
                    "2c000000",
                    "99000000",
                    "01000000",
                    "00000000",
                    "01000000"
                  ]
                }
              ],
              "signatures": null
            },
            {
              "type": "data",
              "value": "e231f38c7652312e2e68b1c30eb08bff5e957995e11c5f27126a5411fd5e4df9"
            }
          ]
        }
      ],
      "fee": 1000000,
      "allow_additional_actions": false
    }
  ]
}

# sign-transaction

签名已经构建好的交易

# 请求参数
  • String - password, 密钥密码,用于解锁私钥进行签名
  • Object - transaction, 已经构造好的交易信息,即build-transaction接口的返回内容
# 返回值
  • String - status, 状态信息
  • Object- data
    • Boolean - sign_complete, 签名成功返回ture,否则false
    • Object - transaction, 签名后的交易
# 示例
// Request
curl -X POST sign-transaction -d '{"password":"123456","transaction":{"allow_additional_actions":false,"local":true,"raw_transaction":"0701000101a101035ebd2bce3858decfc86f282267ec4bb8da40cdd9dbda8b98a67576702afb49fdd6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c2d72f0101160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350040c8a73062a39dccc889dd8a4eaec5aecc352b7fc584469a768d9afe8368f1cfb45d7e50607f374f817638532ff3af854c3c030329ac3e8b242a5876cfe407262b01000101003cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0843d01160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350000","signing_instructions":[{"position":0,"witness_components":[{"type":"raw_tx_signature","quorum":1,"keys":[{"xpub":"25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7","derivation_path":["2c000000","99000000","01000000","00000000","01000000"]}],"signatures":null},{"type":"data","value":"e231f38c7652312e2e68b1c30eb08bff5e957995e11c5f27126a5411fd5e4df9"}]}],"fee":99000000}'

// Result
{
  "status": "success",
  "data": {
    "transaction": {
      "raw_transaction": "0701000101a101035ebd2bce3858decfc86f282267ec4bb8da40cdd9dbda8b98a67576702afb49fdd6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c2d72f0101160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350040c8a73062a39dccc889dd8a4eaec5aecc352b7fc584469a768d9afe8368f1cfb45d7e50607f374f817638532ff3af854c3c030329ac3e8b242a5876cfe407262b6302406639db659dce57f5b5bd4f1e6e3bff8562ecfeaa25d431403aeb71c63d898c505f1f70c271d200990bd330543a18dfe739a515859094bbb4ca9186a72d2b970020e231f38c7652312e2e68b1c30eb08bff5e957995e11c5f27126a5411fd5e4df90101003cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0843d01160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350000",
      "signing_instructions": [
        {
          "position": 0,
          "witness_components": [
            {
              "type": "raw_tx_signature",
              "quorum": 1,
              "keys": [
                {
                  "xpub": "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7",
                  "derivation_path": [
                    "2c000000",
                    "99000000",
                    "01000000",
                    "00000000",
                    "01000000"
                  ]
                }
              ],
              "signatures": [
                "6639db659dce57f5b5bd4f1e6e3bff8562ecfeaa25d431403aeb71c63d898c505f1f70c271d200990bd330543a18dfe739a515859094bbb4ca9186a72d2b9700"
              ]
            },
            {
              "type": "data",
              "value": "e231f38c7652312e2e68b1c30eb08bff5e957995e11c5f27126a5411fd5e4df9"
            }
          ]
        }
      ],
      "fee": 99000000,
      "allow_additional_actions": false
    },
    "sign_complete": true
  }
}

# sign-transactions

对多笔交易进行批量签名

# 请求参数
  • String - password, 密钥密码,用于解锁私钥进行签名
  • Object - transaction, 已经构造好的交易信息,即build-transaction接口的返回内容
# 返回值
  • String - status, 状态信息
  • Object- data
    • Boolean - sign_complete, 签名成功返回ture,否则false
    • Object - transaction, 签名后的交易
# 示例
// Request
curl -X POST localhost:9888/sign-transactions -d '{"password":"123456","transaction":{"allow_additional_actions":false,"local":true,"raw_transaction":"0701000101a101035ebd2bce3858decfc86f282267ec4bb8da40cdd9dbda8b98a67576702afb49fdd6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c2d72f0101160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350040c8a73062a39dccc889dd8a4eaec5aecc352b7fc584469a768d9afe8368f1cfb45d7e50607f374f817638532ff3af854c3c030329ac3e8b242a5876cfe407262b01000101003cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0843d01160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350000","signing_instructions":[{"position":0,"witness_components":[{"type":"raw_tx_signature","quorum":1,"keys":[{"xpub":"25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7","derivation_path":["2c000000","99000000","01000000","00000000","01000000"]}],"signatures":null},{"type":"data","value":"e231f38c7652312e2e68b1c30eb08bff5e957995e11c5f27126a5411fd5e4df9"}]}],"fee":99000000}}'

// Result
{
  "status": "success",
  "data": {
    "transaction": {
      "raw_transaction": "0701000101a101035ebd2bce3858decfc86f282267ec4bb8da40cdd9dbda8b98a67576702afb49fdd6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c2d72f0101160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350040c8a73062a39dccc889dd8a4eaec5aecc352b7fc584469a768d9afe8368f1cfb45d7e50607f374f817638532ff3af854c3c030329ac3e8b242a5876cfe407262b6302406639db659dce57f5b5bd4f1e6e3bff8562ecfeaa25d431403aeb71c63d898c505f1f70c271d200990bd330543a18dfe739a515859094bbb4ca9186a72d2b970020e231f38c7652312e2e68b1c30eb08bff5e957995e11c5f27126a5411fd5e4df90101003cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0843d01160014e0ac26c4ee20fa95ba1585b87414e92ddbbd2b350000",
      "signing_instructions": [
        {
          "position": 0,
          "witness_components": [
            {
              "type": "raw_tx_signature",
              "quorum": 1,
              "keys": [
                {
                  "xpub": "25bd0d1cefc98661c51dcd0174105775bc1357a76393cf4f85c14c69716e26c02c98550eb9ea10b851e34de6b2814a447b077b57e3ee56fc6d8a29715788e9c7",
                  "derivation_path": [
                    "2c000000",
                    "99000000",
                    "01000000",
                    "00000000",
                    "01000000"
                  ]
                }
              ],
              "signatures": [
                "6639db659dce57f5b5bd4f1e6e3bff8562ecfeaa25d431403aeb71c63d898c505f1f70c271d200990bd330543a18dfe739a515859094bbb4ca9186a72d2b9700"
              ]
            },
            {
              "type": "data",
              "value": "e231f38c7652312e2e68b1c30eb08bff5e957995e11c5f27126a5411fd5e4df9"
            }
          ]
        }
      ],
      "fee": 99000000,
      "allow_additional_actions": false
    },
    "sign_complete": true
  }
}

# list-account-votes

列出当前账户的投票交易

# 请求参数

二选一

  • String - account_alias, 账户别名
  • String - account_id, 账户id

# 返回值

  • String - status, 状态信息
  • Object- data
    • String - account_id, 账户id
    • String -account_alias, 账户别名
    • Integer - total_vote_number, 总投票数
    • Array of Object - vote_details, 投票列表
      • String -vote 投票的节点公钥
      • Integer - vote_number 投票数量

# 示例

// Request
curl -X POST list-account-votes -d '{"account_alias": "alice"}'

// Result
{
    "status": "success",
    "data": [
        {
            "account_id": "e894d0ac-7933-49de-b0f0-0f568d652988",
            "account_alias": "alice",
            "total_vote_number": 20000000000,
            "vote_details": [
                {
                    "vote": "2e171e9aed46633f3560cf4d207c4edb92e5ad6b6f63daee44aa0ed4c58f76fd4d0081f225d2b119ac398749dbc7aa113603bc7710693c54852d33b6b082daab",
                    "vote_number": 10000000000
                },
                {
                    "vote": "896285b552bfe0647c0effaee41e5ce98a77981396455259792300cfbc0988bfb1a723488cedf0e73c3220e273fb6843abfbee025d7401b67bf81641b208dfc1",
                    "vote_number": 10000000000
                }
            ]
        }
    ]
}

# submit-transaction

提交已签名交易

# 请求参数
  • Object - raw_transaction, 签名完成后的原始交易,在sign-transaction返回值中获取
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - tx_id, transaction id, 交易哈希
# 示例
// Request
curl -X POST submit-transaction -d '{"raw_transaction":"070100010161015fd4d47100a40069edb2541a820de335bc22093008d5ffb6b823ad11ebc6b42865ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0c5f8ed01000116001433cc42c8598e5b0bdf42a20c338c7a95aa535f7900630240c9e576b25d57bf84fddb52edd62e72011f4dee3ac278f081cce299d93edaca39898e4d870e91f69f5953939a3e58b51272fc6f5a683a499752baa203f16e650920e14d663c7f02be9cbdaf2f2dc8263aa00c177239866f1be8eb30e041b5a50a990101003dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0c5ef7301160014d950f1bc4a88692e20fed82f50fa123c164ea8780000"}'

// Result
{
  "status": "success",
  "data": {
    "tx_id": "85eed0e39d8bd533748541d91b9ab1cb7be0fa2528f7a8e52e0b3ac8732ea660"
  }
}

# submit-transactions

提交多笔交易

# 请求参数

Object:

  • Object - raw_transactions, 多笔签名后的原始交易,在sign-transactions返回值中获取
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - tx_id, transactions id, 交易哈希
# 示例
// Request
curl -X POST localhost:9888/submit-transactions -d '{"raw_transactions":["0701000201620160a0d36052ca3d1335120ae48e1ffb2fb6b25588628eff90fa88bef3117dfb4301ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80ddb2c490e906010116001431630464f2b2058fe3c1fe5bee00742eaf2da8d9630240acb57bc06f7e5de99ef3e630ce34fc74c33d4694301202968092ca50ae7842e3331bfeb0cf7b65f383e27670c4d58aeeeb0b77e5355957ca729298d2b4e2470c20a86ab33efa9d71994270898ad99f198d60889ef617d5eaf25e776929a89739190161015f72de2064ab999acf22c05b5cf9c7d53164f80038b46b1ce426708514a30a3485ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80d4f4f69901000116001431630464f2b2058fe3c1fe5bee00742eaf2da8d96302404298424e89e5528f1d0cdd9028489b9d9e3f031ec34a74440cacc7900dc1eac9359c408a4342fc6cef935d2978919df8b23f3912ac4419800d375fac06ddb50620a86ab33efa9d71994270898ad99f198d60889ef617d5eaf25e776929a897391901013fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8084c5b6aaea060116001431630464f2b2058fe3c1fe5bee00742eaf2da8d900","0701000101620160571cc5d99a2994ff6b192bc9387838a3651245cb66dad4a6bc5f660310cebfa9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8084c5b6aaea06000116001431630464f2b2058fe3c1fe5bee00742eaf2da8d96302408c742d77eba6c56a8db8c114e60be6c6263df6120aefd7538376129d04ec71b78b718c2085bba85254b44bf4600ba31d4c5a7869d0be0c46d88bd5eb27490e0820a86ab33efa9d71994270898ad99f198d60889ef617d5eaf25e776929a897391902013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80faafed99010116001431630464f2b2058fe3c1fe5bee00742eaf2da8d900013fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80ddb2c490e9060116001431630464f2b2058fe3c1fe5bee00742eaf2da8d900"]}'

// Result
{
	"status": "success",
	"data": {
		"tx_id": ["8524bf38701c17c57e2ad7368c0d6c815eb30e92713ff5dd86c1a931cddf2e95", "a0bbfb75c9a00bb2d4801aa95ed0479993a67acfd1cec5b77a8ff86966f52dac"]
	}
}

# estimate-transaction-gas

估算交易手续费,单位为neu(1BTM = 10^8NEU)

# 请求参数

Object:

  • Object - transaction_template, 构造的交易模板
# 返回值
  • String - status, 状态信息
  • Object-data
    • Integer - total_neu, 总共花费的gas费用,总花费=存储费用+虚拟机执行费用
    • Integer - storage_neu,存储交易花费的gas
    • Integer - vm_neu,虚拟机执行花费的gas
# 示例
// Request
curl -X POST estimate-transaction-gas -d '{"transaction_template":{"allow_additional_actions":false,"raw_transaction":"070100010161015fc8215913a270d3d953ef431626b19a89adf38e2486bb235da732f0afed515299ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8099c4d59901000116001456ac170c7965eeac1cc34928c9f464e3f88c17d8630240b1e99a3590d7db80126b273088937a87ba1e8d2f91021a2fd2c36579f7713926e8c7b46c047a43933b008ff16ecc2eb8ee888b4ca1fe3fdf082824e0b3899b02202fb851c6ed665fcd9ebc259da1461a1e284ac3b27f5e86c84164aa518648222602013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80bbd0ec980101160014c3d320e1dc4fe787e9f13c1464e3ea5aae96a58f00013cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8084af5f01160014bb93cdb4eca74b068321eeb84ac5d33686281b6500","signing_instructions":[{"position":0,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","0100000000000000"],"xpub":"cb4e5932d808ee060df9552963d87f60edac42360b11d4ad89558ef2acea4d4aaf4818f2ebf5a599382b8dfce0a0c798c7e44ec2667b3a1d34c61ba57609de55"}],"quorum":1,"signatures":null,"type":"raw_tx_signature"},{"type":"data","value":"1c9b5c1db7f4afe31fd1b7e0495a8bb042a271d8d7924d4fc1ff7cf1bff15813"}]}]}}'

// Result
{
  "status": "success",
  "data": {
    "storage_neu": 3840000,
    "total_neu": 5259000,
    "vm_neu": 1419000
  }
}

# create-access-token

创建访问令牌,提供远程访问全节点的方法,使用HTTP协议的basic authentication进行验证,带入请求头中

# 请求参数
  • String - id, token ID.

可选

  • String - type,token类型
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - token, 访问令牌, 账户名和密码用冒号分隔
    • String - id, token ID.
    • String - type, token类型
    • Object - created_at, token创建时间
# 示例

create access token.

// Request
curl -X POST create-access-token -d '{"id":"token1"}'

// Result
{
  "status": "success",
  "data": {
    "id": "token1",
    "token": "token1:e155ef989f80ab1c228362316a26ccd5ed0fa26d0ff431007acf39361853c912",
    "created_at": "2021-08-18T15:07:36.6947417+08:00"
  }
}

# list-access-tokens

列出所有可用的令牌信息

# 请求参数

# 返回值
  • String - status, 状态信息
  • Array of Object- data, access token列表
    • Object:
      • String - token, access token.
      • String - id, token ID.
      • String - type, token类型
      • Object - created_at, token创建时间
# 示例
// Request
curl -X POST list-access-tokens -d {}

// Result
{
  "status": "success",
  "data": [
    {
      "id": "token1",
      "token": "token1:e155ef989f80ab1c228362316a26ccd5ed0fa26d0ff431007acf39361853c912",
      "created_at": "2021-08-18T15:07:36.6947417+08:00"
    }
  ]
}

# delete-access-token

删除访问令牌

# 请求参数
  • String - id, token ID.
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST delete-access-token -d '{"id": "token1"}'

// Result
{
  "status": "success"
}

# check-access-token

校验令牌是否合法

# 请求参数

Object:

  • String - id, token ID.
  • String - secret, token验证的秘密, 冒号分隔后的第二部分
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST check-access-token -d '{"id": "token1", "secret": "1fee70f537128a201338bd5f25a3adbf33dad02eae4f4c9ac43f336a069df8f3"}'

// Result
{
  "status": "success"
}

# get-unconfirmed-transaction

通过交易id查询交易池中的未确认交易

# 请求参数

Object:

  • String - tx_id, 交易id
# 返回值
  • String-status, 状态信息
  • Object-data
    • String - id, 交易id
    • Integer - version, 交易版本
    • Integer - size, 交易体积
    • Integer - time_range, 指定的某个区块高度,在这个高度之前打包有效,如果超过这个高度就不会再被打包,默认为0
    • String - mux_id, 前一笔交易的UTXO id
    • Array of Object - inputs, 交易输入列表
    • Array of Object - outputs, 交易输出列表
# 示例
// Request
curl -X POST get-unconfirmed-transaction -d '{"tx_id": "382090f24fbfc2f737fa7372b9d161a43f00d1c597a7130a56589d1f469d04b5"}'

// Result
{
  "id": "382090f24fbfc2f737fa7372b9d161a43f00d1c597a7130a56589d1f469d04b5",
  "inputs": [
    {
      "address": "bn1qckpcdgjnunkpnavaep2yumka5r9dq4d7vnsx2j",
      "amount": 41250000000,
      "asset_definition": {},
      "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "control_program": "001400f7e1f338378834161b5bb73da251e6d0566396",
      "input_id": "a0c2fa0719bfe1446681537dcf1f8d0f03add093e29d12481eb807e07778d7b3",
      "spent_output_id": "161b44e547a6cc68d732eb64fa38031da98211a99319e088cfe632223f9ac6d8",
      "type": "spend",
      "witness_arguments": [
        "cf0e1b217ab92ade8e81fab10f9f307bb5cc1ad947b5629e3f7a760aba722f5044f2ab59ec92fa4264ff5811de4361abb6eabd7e75ffd28a813a98ceff434c01",
        "6890a19b21c326059eef211cd8414282a79d3b9203f2592064221fd360e778a7"
      ]
    }
  ],
  "mux_id": "842cd07eed050b547377b5b123f14a5ec0d76933d564f030cf4d5d5c15769645",
  "outputs": [
    {
      "address": "bn1qckpcdgjnunkpnavaep2yumka5r9dq4d7vnsx2j",
      "amount": 21230000000,
      "asset_definition": {},
      "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "control_program": "0014cdccda61b3c8716bd258f29089c5f7eb1be3fe08",
      "id": "a8f21ad24689c290634db85278f56d152efe6fe08bc194e5dee5127ed6d3ebee",
      "position": 0,
      "type": "control"
    },
    {
      "address": "bn1qckpcdgjnunkpnavaep2yumka5r9dq4d7vnsx2j",
      "amount": 20000000000,
      "asset_definition": {},
      "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "control_program": "001456f2543b189ee39b8663c0ca546272f45f282849",
      "id": "78219e422ea3257aeb32f6d952b5ce5560dab1d6440c9f3aebcdaad2a852d2a8",
      "position": 1,
      "type": "control"
    }
  ],
  "size": 664,
  "time_range": 0,
  "version": 1
}

# list-unconfirmed-transactions

列出所有交易池中未确认交易

# 请求参数

none

# 返回值
  • String-status, 状态信息
  • Object-data
    • Integer - total, 交易数量
    • Array of Object - tx_ids, 交易id列表
# 示例
// Request
curl -X POST list-unconfirmed-transactions -d {}

// Result
{
  "status": "success",
  "data": {
    "total": 1,
    "tx_ids": [
      "a8b6ba0e97956d97f18cb44c6b2a8351ba3ad6acf06e7264a239af8a81700175"
    ]
  }
}

# decode-raw-transaction

解码序列化的交易到json格式

# 请求参数

Object:

  • String - raw_transaction, 交易的十六进制字符串
# 返回值
  • String-status,状态信息
  • Object-data
    • String - tx_id, 交易id
    • Integer - version, 交易版本
    • String - size, 交易体积
    • String - time_range, 指定的某个区块高度,在这个高度之前打包有效,如果超过这个高度就不会再被打包,默认为0,即永远可以打包
    • String - fee, 交易手续费
    • Array of Object - inputs, 交易输入列表(具体结构参考 get-transaction API 描述)
    • Array of Object - outputs, 交易输出列表(具体结构参考 get-transaction API 描述)
# 示例
// Request
curl -X POST decode-raw-transaction -d '{"raw_transaction": "070100010161015fd4d47100a40069edb2541a820de335bc22093008d5ffb6b823ad11ebc6b42865ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0c5f8ed01000116001433cc42c8598e5b0bdf42a20c338c7a95aa535f790001000101003dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0c5ef7301160014d950f1bc4a88692e20fed82f50fa123c164ea8780000"}'

// Result
{
  "status": "success",
  "data": {
    "tx_id": "85eed0e39d8bd533748541d91b9ab1cb7be0fa2528f7a8e52e0b3ac8732ea660",
    "version": 1,
    "size": 171,
    "time_range": 0,
    "inputs": [
      {
        "type": "spend",
        "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
        "asset_definition": {},
        "amount": 499000000,
        "control_program": "001433cc42c8598e5b0bdf42a20c338c7a95aa535f79",
        "address": "bn1qx0xy9jze3edshh6z5gxr8rr6jk49xhmec2enaw",
        "spent_output_id": "8e84b6a3047e00a4c740d2741ad4cdbfa2aa74da774c3271f6f14376f0afa34c",
        "input_id": "3a82a64533706d2a1fa1297fe651efcc3a2e9ba6818b3c69247542812a50fbfb",
        "witness_arguments": null,
        "sign_data": "d7aa7dcbb6373c2e0f1e617cc894418dc41ada4c97a7159e4a5030a2a3307f0a"
      }
    ],
    "outputs": [
      {
        "type": "control",
        "id": "9077316730920c285def920534722e59fe0953c9e013394663780dfe7c9d714c",
        "position": 0,
        "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
        "asset_definition": {},
        "amount": 243000000,
        "control_program": "0014d950f1bc4a88692e20fed82f50fa123c164ea878",
        "address": "bn1qm9g0r0z23p5jug87mqh4p7sj8stya2rc48w7s7"
      }
    ],
    "fee": 256000000
  }
}

# get-block-count

返回最新的区块高度

# 请求参数

# 返回值
  • String-status,状态信息
  • Object-data
    • Integer - block_count, 最新的区块高度
# 示例
// Request
curl -X POST get-block-count

// Result
{
  "status": "success",
  "data": {
    "block_count": 23959
  }
}

# get-block-hash

获取最新的区块哈希

# 请求参数

# 返回值
  • String-status,状态信息
  • Object-data
    • String - block_hash, 最新的区块哈希
# 示例
// Request
curl -X POST get-block-hash

// Result
{
  "status": "success",
  "data": {
    "block_hash": "7bc31831bfc148db98684f6939c7756d9fa7b20c91efa1b6868953f4963f655e"
  }
}

# get-block

通过区块哈希或者区块高度查询区块详细信息

# 请求参数

二选一

  • String - block_hash, 区块哈希
  • Integer - block_height, 区块高度
# 返回值
  • String-status,状态信息
  • Object-data
    • String - hash, 区块哈希
    • Integer - size, 区块大小
    • Integer - version, 区块版本
    • Integer - height, 区块高度
    • String - validator,区块产生节点的公钥
    • String - previous_block_hash, 前一个区块哈希
    • Integer - timestamp, 区块产生的时间戳
    • String - transaction_merkle_root, 交易默克尔根
    • Array of Object - transactions, 区块内包含的交易列表
      • String - id, 交易id
      • Integer - version, 交易版本
      • Integer - size, 交易体积
      • Integer - time_range, 指定的某个区块高度,在这个高度之前打包有效,如果超过这个高度就不会再被打包 ,默认为0,即永远可以被打包
      • String - mux_id, 前一笔交易的UTXO id
      • Array of Object - inputs, 交易的输入列表
        • String - type, 输入类型,包括花费输入'spend', 资产发行输入 'issue', 出块输入'coinbase, '取消投票输入'veto' .
        • String - asset_id, 资产id
        • Object - asset_definition, 资产定义
        • Integer - amount, 资产数量
        • Object - issuance_program, 资产发行程序,只有在输入类型是 'issue'时存在
        • Object - control_program, 花费控制程序, 只有在输入类型是'spend'时存在
        • String - address, 账户地址, 只有在输入类型是'spend'时存在
        • String - spent_output_id, 该输入指向的前一个输出, 只有在输入类型是'spend'时存在
        • Object - arbitrary, 附加信息,只有在输入类型是'coinbase'时存在
        • String - input_id, 输入id
        • Array of String - witness_arguments, 隔离见证参数,存签名信息
        • String - sign_data,输入的签名数据
        • String - vote,投票的节点公钥,只有在输入类型是'veto'时存在
      • Array of Object - outputs, 交易的输出列表
        • String - type, 输出类型,包括删除输出'retire',收款输出 'control',投票输出 'vote'
        • String - id, 输出的id
        • Integer - position, 输出处于交易中的位置
        • String - asset_id, 资产id
        • Object - asset_definition, 资产定义
        • Integer - amount, 资产数量
        • Object - control_program,账户的控制程序
        • String - address, 账户的地址
        • String - vote,投票的节点公钥,只有在输入类型是'vote'时存在
# 示例
// Request
curl -X POST get-block -d '{"block_height": 43, "block_hash": "886a8e85b275e7d65b569ba510875c0e63dece1a94569914d7624c0dac8002f9"}'

// Result
{
  "status": "success",
  "data": {
    "hash": "c7bfc4f264c183bf67518496dad1860f83aced4bbb69d0d5483e4c5c6c5d4289",
    "size": 910,
    "version": 1,
    "height": 100,
    "validator": "1313379b05c38ff2d171d512f23f199f0f068a67d77b9d5b6db040f2da1edc0c35c68a21b068956f448fed6441b9c27294f1ca6aaedc2c580de322f3f0260c1f",
    "previous_block_hash": "b376ad51d35e81c65f333e9a3e45520ee9da30b3384aaf113f0ad9ff1b187666",
    "timestamp": 1629425448000,
    "transaction_merkle_root": "c47d425b3e2c04d19050ef98cf994a2402e915dacd420e64439a1d39a8cc4be4",
    "transactions": [
      {
        "id": "54f48bcc033886bc28fd7cfe2a15d3b82690280726c40ddc12045f86bcd3d08b",
        "version": 1,
        "size": 76,
        "time_range": 0,
        "inputs": [
          {
            "type": "coinbase",
            "asset_id": "0000000000000000000000000000000000000000000000000000000000000000",
            "asset_definition": {},
            "amount": 0,
            "arbitrary": "00313030",
            "input_id": "bdca065d4d6e282c0b385ef05ed3f1929ba3421a94d6f59ccdf3871d39f8e57b",
            "witness_arguments": null,
            "sign_data": "0000000000000000000000000000000000000000000000000000000000000000"
          }
        ],
        "outputs": [
          {
            "type": "control",
            "id": "15233511500ac1ad4968fdab41e770df106422caa56cf85929dcdbb957694e27",
            "position": 0,
            "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            "asset_definition": {},
            "amount": 0,
            "control_program": "00147979dd397652cc9e02e6f361614a645ea0f79cfc",
            "address": "bn1q09ua6wtk2txfuqhx7dskzjnyt6s0088ulmsrpr"
          }
        ],
        "mux_id": "b6f4a43731c1575ad6ff038b8c02c9cf2b18fd489261de33af04fb968defe50c"
      }
    ]
  }
}

# get-block-header

通过区块哈希或者区块高度来获得区块头信息

# 请求参数

二选一

  • String - block_hash, 区块哈希
  • Integer - block_height, 区块高度
# 返回值
  • String-status,状态信息
  • Object-data
    • Object - block_header, 区块头信息
# 示例
// Request
curl -X POST get-block-header -d '{"block_height": 43, "block_hash": "886a8e85b275e7d65b569ba510875c0e63dece1a94569914d7624c0dac8002f9"}'

// Result
{
  "status": "success",
  "data": {
    "block_header": "01012bb02f815ad8538d0fab91c822c4125aa10d2679eaf59cb806c8dad95b093be0e9b0ca9fedb42f20567572e2dbce3d88ee9fbd7dc76f40dbbde0164c05f060464f5b7f66347e283341400f022d806c1eb8e44ccf6d25e1b9e50adf4b2daf76e14c166b979c25117a0c0ee4ed1fd6690ba9ea230314c0338c3a6b1696c9eedff0aedcfac11e0644c8df0c0100"
  }
}

# net-info

查询当前节点的网络信息

# 请求参数

# 返回值
  • String-status,状态信息
  • Object- data
    • Boolean - listening, 节点是否在监听网络
    • Boolean - syncing, 节点是否在同步
    • Boolean - mining, 节点是否开启挖矿
    • String - node_xpub, 节点公钥
    • Integer - peer_count, 当前已连接的节点数量
    • Integer - highest_height, 当前同步的最高块
    • String - network_id, 网络id
    • Object - version_info, 版本信息
      • String - version, bytomd客户端版本
      • uint16 - update, 是否存在更新
        • 0: 无更新
        • 1: 小更新
        • 2: 重大更新
      • String - new_version, 最新 bytomd 客户端版本
# 示例
// Request
curl -X POST net-info

// Result
{
  "status": "success",
  "data": {
    "listening": true,
    "syncing": false,
    "mining": false,
    "node_xpub": "52db4dddde5d943e8815eb7874f98722e5696198c03c20a569ecff47c84e082103e609b7833b56f8e1fa38c1c91a82a7377758f5d8bf6e4c5fbaafc7ab289695",
    "peer_count": 0,
    "highest_height": 98613,
    "network_id": "mainnet",
    "version_info": {
      "version": "2.0.2+3f76ecfb",
      "update": 0,
      "new_version": "2.0.2+3f76ecfb"
    }
  }
}

# is-mining

查询挖矿状态

# 请求参数

# 返回值
  • String-status,状态信息
  • Object- data
    • Boolean - is_mining, 节点是否在挖矿
# 示例
// Request
curl -X POST is-mining

// Result
{
  "status": "success",
  "data": {
    "is_mining": false
  }
}

# set-mining

设置节点挖矿

# 请求参数

Object:

  • Boolean - is_mining, 设置是否挖矿,true为开启,false为关闭
# 返回值
  • String-status,状态信息
  • String- data,错误信息,成功返回空
# 示例
// Request
curl -X POST set-mining -d '{"is_mining": true}'

// Result
{
  "status": "success",
  "data": ""
}

# gas-rate

查询gas费率

# 请求参数

# 返回值
  • String-status,状态信息
  • Object- data
    • Integer - gas_rate,gas费率
# 示例
// Request
curl -X POST gas-rate -d '{}'

// Result
{
  "status": "success",
  "data": {
    "gas_rate": 200
  }
}

# verify-message

使用派生公钥验证签名信息

# 请求参数

Object:

  • String - address, 账户地址
  • String - derived_xpub, 派生公钥
  • String - message, 原始信息
  • String - signature, 签名.
# 返回值
  • Boolean - result, 验证结果
# 示例
// Request
curl -X POST verify-message -d '{"address":"bn1quzkzd38wyraftws4sku8g98f9hdm62e46v9enr", "derived_xpub":"6ff8c3d1321ce39a3c3550f57ba70b67dcbcef821e9b85f6150edb7f2f3f91009e67f3075e6e76ed5f657ee4b1a5f4749b7a8c74c8e7e6a1b0e5918ebd5df4d0", "message":"this is a test message", "signature":"74da3d6572233736e3a439166719244dab57dd0047f8751b1efa2da26eeab251d915c1211dcad77e8b013267b86d96e91ae67ff0be520ef4ec326e911410b609"}'

// Result
{
  "result": true
}

# list-peers

返回已经连接的节点列表

# 请求参数

# 返回值
  • String - status, 状态信息
  • Array of Object- data, 节点列表
    • Object:
      • String - peer_id, 节点id
      • String - moniker, 连接节点的名称
      • String - remote_addr, 连接节点的ip地址和端口
      • Integer - height, 连接节点的当前区块高度
      • String - ping, 连接节点的延迟
      • String - duration, 连接时长
      • Integer - total_sent, 总共发送的字节数
      • Integer - total_received, 总共接收的字节数
      • Integer - average_sent_rate, 平均发送速率
      • Integer - average_received_rate, 平均接收速率
      • Integer - current_sent_rate, 当前发送速率
      • Integer - current_received_rate, 当前接收速率
# 示例
// Request
curl -X POST list-peers -d '{}'

// Result
{
  "status": "success",
  "data": [
    {
      "peer_id": "88c0fda80b0415caa665f52f78b1864d97afbd8228ef108ae9afbb9ea63ebfc6",
      "moniker": "anonymous",
      "remote_addr": "139.196.235.27:46656",
      "height": 27315,
      "ping": "12.22s",
      "duration": "2h51m56.2s",
      "total_sent": 413033,
      "total_received": 840480,
      "average_sent_rate": 40,
      "average_received_rate": 81,
      "current_sent_rate": 29,
      "current_received_rate": 123
    }
  ]
}

# disconnect-peer

断开指定节点的连接

# 请求参数
  • String - peer_id, 节点id
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST disconnect-peer -d '{"peer_id":"29661E8BB9A8149F01C6594E49EA80C6B18BF247946A7E2E01D8235BBBFC3594"}'

// Result
{
  "status": "success"
}

# connect-peer

连接到指定的节点

# 请求参数

Object:

  • String - ip, 节点ip地址
  • Integer - port, 节点端口
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - peer_id, 节点id
    • String - remote_addr, 连接节点的ip地址和端开
    • Integer - height,连接节点的当前高度
    • Integer - delay,连接节点的延迟
# 示例
// Request
curl -X POST connect-peer -d '{"ip":"139.198.177.164", "port":46657}'

// Result
{
  "status": "success"
  "data": {
    "peer_id": "29661E8BB9A8149F01C6594E49EA80C6B18BF247946A7E2E01D8235BBBFC3594",
    "remote_addr": "139.198.177.164:46657",
    "height": 65941,
    "delay": 0
  }
}

# get-vote-result

查询指定区块高度的投票结果

# 请求参数

二选一

  • String - block_hash, 区块哈希
  • Integer - block_height, 区块高度
# 返回值
  • String - status, 状态信息
  • Array of Object- data, 投票列表
    • String - vote 投票的节点公钥
    • Integer - vote_number 投票数量
# 示例
// Request
curl -X POST get-vote-result -d '{"block_height": 100000}'

// Result
{
    "status": "success",
    "data": [
        {
            "vote": "aa5cb0d5d193a141ce66dd3448e8d74d73bed1131ea05b130c14c95ad04b0295f2d4d3f421ae10a2517f7431e0eca119fea509e0650bd20b4a64b856b5473f35",
            "vote_number": 10000000000
        },
        {
            "vote": "98e6ab8c654bb31e0c432a2c9ff13a6e3419dcb8a1df94f2839f41d79e94b6ca7a68f60b793d947195f761187b37275fbeb345041d5ea3039c5d328b63e3d489",
            "vote_number": 10000000000
        },
        {
            "vote": "896285b552bfe0647c0effaee41e5ce98a77981396455259792300cfbc0988bfb1a723488cedf0e73c3220e273fb6843abfbee025d7401b67bf81641b208dfc1",
            "vote_number": 10000000000
        }
    ]
}

# create-contract

创建一个注册合约,用于用户后续的合约部署和开发

# 请求参数
  • String - alias, 合约别名
  • String - contract, 合约内容
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - id, 合约id.
    • String - alias, 合约别名
    • String - contract, 合约内容
    • String - call_program, 合约调用程序
    • String - register_program, 合约注册程序
# 示例
// Request
curl -X POST create-contract -d '{"alias": "swap","contract": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e787403ae7cac00c0"}'

// Result
{
    "status": "success",
    "data": {
        "id": "4e4f02d43bf50171f7f25d046b7f016002da410fc00d2e8902e7b170c98cf946",
        "alias": "swap",
        "contract": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e787403ae7cac00c0",
        "call_program": "0462637270204e4f02d43bf50171f7f25d046b7f016002da410fc00d2e8902e7b170c98cf946",
        "register_program": "6a046263727001012820e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e787403ae7cac00c0"
    }
}

# update-contract-alias

更改合约别名

# 请求参数
  • String - id, 合约id
  • String - alias, 更改后的别名
# 返回值
  • String - status, 状态信息
# 示例
// Request
curl -X POST update-contract-alias -d '{"id": "4e4f02d43bf50171f7f25d046b7f016002da410fc00d2e8902e7b170c98cf946","alias":"lock"}'

// Result
{
    "status": "success"
}

# get-contract

根据合约id查询合约

# 请求参数
  • String - id, 合约id
# 返回值
  • String - status, 状态信息
  • Object- data
    • String - id, 合约id
    • String - alias,合约别名
    • String - contract, 合约内容
    • String - call_program, 合约调用程序
    • String - register_program, 合约注册程序
# 示例
// Request
curl -X POST get-contract -d '{"id": "4e4f02d43bf50171f7f25d046b7f016002da410fc00d2e8902e7b170c98cf946"}'

// Result
{
    "status": "success",
    "data": {
        "id": "4e4f02d43bf50171f7f25d046b7f016002da410fc00d2e8902e7b170c98cf946",
        "alias": "lock",
        "contract": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e787403ae7cac00c0",
        "call_program": "0462637270204e4f02d43bf50171f7f25d046b7f016002da410fc00d2e8902e7b170c98cf946",
        "register_program": "6a046263727001012820e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e787403ae7cac00c0"
    }
}

# list-contracts

查询节点中所有的合约

# 请求参数

# 返回值
  • String - status, 状态信息
  • Array of Object- data, 合约列表
    • `Object:
      • String - id, 合约id
      • String - alias,合约别名
      • String - contract, 合约内容
      • String - call_program, 合约调用程序
      • String - register_program, 合约注册程序
# 示例
// Request
curl -X POST get-contract -d '{}'

// Result
{
    "status": "success",
    "data": [
        {
            "id": "4e4f02d43bf50171f7f25d046b7f016002da410fc00d2e8902e7b170c98cf946",
            "alias": "lock",
            "contract": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e787403ae7cac00c0",
            "call_program": "0462637270204e4f02d43bf50171f7f25d046b7f016002da410fc00d2e8902e7b170c98cf946",
            "register_program": "6a046263727001012820e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e787403ae7cac00c0"
        }
    ]
}

# chain-status

返回链的状态

# 请求参数

# 返回值
  • String - status, 状态信息
  • Object-data
    • Integer - current_height, 当前最高区块
    • String - current_hash,当前最高区块的哈希
    • Integer - finalized_height, 最终确认的区块高度,除非2/3节点作恶,否则无法回滚
    • String - finalized_hash,最终确认的区块哈希
    • Integer - justified_height, 首次确认的区块高度,相当于比特币6个块的确认
    • String - justified_hash, 首次确认的区块哈希
# 示例
// Request
curl -X POST chain-status

// Result
{
    "status":"success",
    "data":{
        "current_height":146906,
 "current_hash":"3a7eaa77045a2aa3fb810a215f3049e84b5033dda78f0865298ed68b05258b9c",
        "finalized_height":146800,
 "finalized_hash":"e7d8b6b56b6aed64f37d9efd7ce8bb733ebbba22b7d7cca103136ae7def41cae",
        "justified_height":146900,
 "justified_hash":"b2c3439c61c83c7b50d9aee2d2197d6601734dcd4e11a228e33ff8f14c90df2f"
    }
}
上次更新: 2021/9/2下午5:25:12