NAV Navbar
python javascript go

关于 Cobo Custody WaaS API

概述

Cobo Custody 支持通过 REST API 的方式来使用 Cobo Custody 的 WaaS 服务。其中包括50多种主流区块链和1000多种代币的收币、发币等功能。 第三方应用可以把它想象成支付宝或者微信支付接口,便于基于Cobo Custody开发加密货币相关应用,比如加密货币交易所、对冲基金、支付平台、抵押借贷平台、云算力、矿池钱包等等。 第三方开发者也可以把数字资产存储在Cobo Custody,充分利用Cobo全球领先的热温冷分离、HSM银行级加密机以及全球多地的私钥分布存储保障资产安全。

除了REST API,Cobo Custody还提供基于Web的管理界面 https://home.custody.cobo.com/ ,便于管理人员手工收发、配置风控策略,如限额限速、白名单、多人审核等,此外还提供资金归集、低额提醒、统计报表等功能。以下是Web管理界面截图:

WebHome

如何开通账户

用户可以通过官方网站 https://cobo.com/custody/ 申请开通Custody账户,我们的服务人员会与您取得联系。

Sandbox测试环境 (免费试用)

为方便开发者测试,我们提供 Sandbox 测试环境供所有开发者使用,您可以在该链接 https://cobo.com/custody/ 中申请或发送申请邮件至 custody@cobo.com, 我们的工作人员会协助您开通测试账户。

测试环境Web管理界面请访问: https://home.sandbox.cobo.com/

五种语言的开发SDK

Cobo Custody 提供五种编程语言(Python, JavaScript, Golang, JAVA, PHP)的用户端代码供第三方开发者使用,以下是不同语言对应的URL。

Python:https://github.com/CoboCustody/cobo-python-api/

JavaScript:https://github.com/CoboCustody/cobo-js-api/

Golang:https://github.com/CoboCustody/cobo-go-api/

JAVA:https://github.com/CoboCustody/cobo-java-api/

PHP:https://github.com/CoboCustody/cobo-php-api/

API 签名认证

Cobo 使用 ECDSA 签名进行验证,您在 Cobo Custody 开通账户以后,可以在您本地生成公私钥对,参考该URL下Cobo提供的例程:https://github.com/CoboCustody/,如有任何疑问,也可以联系我们的工作人员协助您。 您可以通过 Custody Web 管理界面录入您的公钥 API Key (可选择类型:仅查询;查询&提现)。 API Secret 请您自己妥善保管,不要透露给任何人,避免资产损失! Cobo 强烈建议您绑定您的IP地址白名单以及启用“API回调”中的提现确认。 WebApi

Cobo Custody 的 API 请求,除公开的 API 外都需要携带 API key 以及签名

签名前准备的数据如下: HTTP_METHOD + | + HTTP_REQUEST_PATH + | + TIMESTAMP + | + PARAMS 连接完成后,对数据进行 ECDSA 签名,签名后的 bytes 进行 Hex 编码。

HTTP HOST

HTTP_METHOD

GET, POST 需要大写 请注意: Cobo POST接口不支持JSON数据格式, 请使用表单提交数据

HTTP_REQUEST_PATH

请求URL的PATH部分, 例如https://api.sandbox.cobo.com/v1/test/ 为 /v1/test/

NONCE

访问 API 时的 UNIX EPOCH 时间戳 (精确到毫秒)

PARAMS

如果请求数据为: {  "username": "username",  "password": "password" }

则先将 key 按照字母排序,然后进行 url 参数化,即:
password=password
username=username

因为 p 在字母表中的排序在 u 之前,所以 password 要放在 username 之前,然后使用 & 进行连接,即:
password=password&username=username

请求参数,POST, GET 都一样,需要把所有参数都拿出来,签名规则如下: 所有请求的 key 按照字母顺序排序,然后进行 url 参数化,并使用 & 连接。

完整示例

对于如下的请求:

Method URL Nonce
POST https://api.sandbox.cobo.com/v1/custody/test/ 1537498830736

参数

Parameter Value
type limit
side buy
amount 100.0
price 100.0
symbol btcusdt

签名前的准备数据如下: POST|/v1/custody/test/|1537498830736|amount=100.0&price=100.0&side=buy&symbol=btcusdt&type=limit

使用您本地生成的 API Key 私钥(API SECRET),对数据使用私钥进行 ECDSA 签名,并对二进制结果进行 Hex 编码, 即生成了用于向 API 服务器进行验证的最终签名 (可参考 Cobo 例程:https://github.com/CoboCustody/ )

将 Api key, nonce和右边生成的 signature 按上面的名称放入Header中, 即可通过签名验证

Cobo 验签公钥可以在 “Web 管理界面 - 钱包 - API 回调” 页面获取 (* Sandbox 和 Prod 环境不同)

账户&地址

查询账户详情

HTTP Request

GET /v1/custody/org_info/

request(
    "GET",
    "/v1/custody/org_info/",
    {},
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/org_info/', {}, api_key, api_secret, host)
    .then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/org_info/", map[string]string{})

请求参数

参数 类型 必须 描述

响应结果

{
    "success": true,
    "result": {
        "name": "test",
        "assets": [
            {
                "coin": "ETH",
                "display_code": "ETH",
                "description": "Ethereum",
                "decimal": 18,
                "can_deposit": true,
                "can_withdraw": true,
                "balance": "0",
                "abs_balance": "0",
                "fee_coin": "ETH",
                "abs_estimate_fee": "0.0003648",
                "confirming_threshold": 12,
                "dust_threshold": 1,
                "token_address": "",
                "require_memo": false
            },
            {
                "coin": "BTC_USDT",
                "display_code": "USDT",
                "description": "Tether",
                "decimal": 8,
                "can_deposit": true,
                "can_withdraw": true,
                "balance": "740145525",
                "abs_balance": "7.40145525",
                "fee_coin": "BTC",
                "abs_estimate_fee": "0.00015044",
                "confirming_threshold": 3,
                "dust_threshold": 1,
                "token_address": "31",
                "require_memo": false
            },
            {
                "coin": "BTC",
                "display_code": "BTC",
                "description": "Bitcoin",
                "decimal": 8,
                "can_deposit": true,
                "can_withdraw": true,
                "balance": "102730",
                "abs_balance": "0.0010273",
                "fee_coin": "BTC",
                "abs_estimate_fee": "0.00013513",
                "confirming_threshold": 3,
                "dust_threshold": 546,
                "token_address": "",
                "require_memo": false
            }
        ]
    }
}
属性 类型 含义解释
coin String 币种代号
display_code String 币种缩写(非唯一,可能变化,仅供参考)
description String 币种名称全称(非唯一,可能变化,仅供参考)
decimal Int 币种精度
can_deposit bool 是否可以充值
can_withdraw bool 是否可以提现
balance String 当前余额
abs_balance String 余额绝对值
fee_coin String 手续费币种
abs_estimate_fee String 预估手续费
confirming_threshold Int 对于设置监听确认详情的钱包, 会返回币种确认数阈值
dust_threshold Int 币种最小支持的交易额
token_address String 币种可能有的合约地址 (主链币为null)
require_memo String 币种需要配合memo进行入账地址拼接

查询账户某币种详情

HTTP Request

GET /v1/custody/coin_info/

request(
    "GET",
    "/v1/custody/coin_info/",
    {
        "coin": "ETH"
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/coin_info/', {
    "coin": "ETH"
}, api_key, api_secret, host)
    .then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/coin_info/", map[string]string{
    "coin": "ETH",
})

请求参数

参数 类型 必须 描述
coin String 币种代号

响应结果

{
    "success": true,
    "result": {
        "coin": "ETH",
        "display_code": "ETH",
        "description": "Ethereum",
        "decimal": 18,
        "can_deposit": true,
        "can_withdraw": true,
        "require_memo": false,
        "balance": "0",
        "abs_balance": "0",
        "fee_coin": "ETH",
        "abs_estimate_fee": "0.0003648",
        "confirming_threshold": 12,
        "dust_threshold": 0,
        "token_address": ""
    }
}
属性 类型 含义解释
coin String 币种代号
display_code String 币种缩写(非唯一,可能变化,仅供参考)
description String 币种名称全称(非唯一,可能变化,仅供参考)
decimal Int 币种精度
can_deposit bool 是否可以充值
can_withdraw bool 是否可以提现
balance String 当前余额
abs_balance String 余额绝对值
fee_coin String 手续费币种
abs_estimate_fee String 预估手续费
confirming_threshold Int 对于设置监听确认详情的钱包, 会返回币种确认数阈值
dust_threshold Int 币种最小支持的交易额
token_address String 币种可能有的合约地址 (主链币为null)
require_memo String 币种需要配合memo进行入账地址拼接

获取新充值地址

对于BTC地址,支持生成 segwit(3地址)和 native_segwit(bc1地址),具体传参见下方。 (* Cobo支持向任意BTC地址类型提现)

HTTP Request

POST /v1/custody/new_address/

request(
    "POST",
    "/v1/custody/new_address/",
    {
        "coin": "BTC"
        "native_segwit": 1
    },
    api_key, api_secret, host
)
coboFetch('POST', '/v1/custody/new_address/',
        {
            "coin": "BTC"
            "native_segwit": 1
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("POST", "/v1/custody/new_address/", map[string]string{
    "coin": "BTC",
    "native_segwit": 1
})

请求参数

参数 类型 必须 描述
coin String 币种代号
native_segwit bool 仅对BTC有效,为空则返回Cobo默认地址格式(segwit 3地址),非空则为 native_segwit(bc1 地址)

响应结果

{
    "success": true,
    "result": {
        "coin": "BTC",
        "address": "bc1qzet2qmpxa3scehtf6y9eye7qexhx4pzph8vlms"
    }
}

属性 类型 含义解释
coin String 币种代号
address String 地址(如果有Memo,竖线隔开)

批量获取新充值地址

单次请求此接口最多可生成1000个地址 (对于BTC地址,支持生成 segwit(3地址)和 native_segwit(bc1地址),具体传参见下方。 (* Cobo支持向任意BTC地址类型提现))

HTTP Request

POST /v1/custody/new_addresses/

request(
    "POST",
    "/v1/custody/new_addresses/",
    {
        "coin": "ETH"
        "count": 4

    },
    api_key, api_secret, host
)
coboFetch('POST', '/v1/custody/new_addresses/',
        {
            "coin": "ETH"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("POST", "/v1/custody/new_addresses/", map[string]string{
    "coin": "ETH",
})

请求参数

参数 类型 必须 描述
coin String 币种代号
count Int 地址数量(传指定地址数量,最多1000个)
native_segwit bool 仅对BTC有效,为空则返回Cobo默认地址格式(segwit 3地址),非空则为 native_segwit(bc1 地址)

响应结果

{
    "success": true,
    "result": {
        "coin": "ETH",
        "addresses":[
            "0x544094588811118b7701cf4a9dea056e775b4b4e",
            "0x580f33154fddf59ede21b95cd6c615df138ef160",
            "0xcec381336e22643bd0b4d779bc26a6c7a1fee23d",
            "0xa4a98b46507bb768b75c23ea3dc1a34fb150e3bd"
        ]
    }
}

属性 类型 含义解释
coin String 币种代号
addresses String 地址(如果有Memo,竖线隔开)

验证地址归属

可用此接口验证某地址是否为您当前 Cobo Custody 钱包的地址

HTTP Request

GET /v1/custody/address_info/

request(
    "GET",
    "/v1/custody/address_info/",
    {
        "coin": "ETH",
        "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/address_info/',
        {
            "coin": "ETH",
            "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/address_info/", map[string]string{
    "coin": "ETH",
    "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",
})

Parameters

参数 类型 必须 描述
coin String 币种代号
address String 地址(如果有Memo,竖线隔开)

Response

{
    "success": true,
    "result": {
        "coin": "ETH",
        "address": "0x544094588811118b7701cf4a9dea056e775b4b4e"
    }
}
----
{
    "success": false,
    "error_code": 12015,
    "error_description": "0x544094588811118b7701cf4a9dea056e775b4b4e is not Cobo Address of Coin ETH",
    "error_message": "0x544094588811118b7701cf4a9dea056e775b4b4e is not Cobo Address of Coin ETH"
}
属性 类型 含义解释
coin String 币种代号
address String 地址(如果有Memo,竖线隔开)

批量验证地址归属

可用此接口批量验证某些地址是否为您当前 Cobo Custody 钱包的地址,多地址间逗号隔开,仅返回其中正确归属您的地址

HTTP Request

GET /v1/custody/addresses_info/

request(
    "GET",
    "/v1/custody/addresses_info/",
    {
        "coin": "ETH",
        "address": "0x544094588811118b7701cf4a9dea056e775b4b4e,0x33bb80427711adc881b56a209a374b00388f8a99,0x70099565fe19464b544ccb6ad8080891863eb080,0xafe68A8F8B339D7bbb30A9e486c0c06c3964Cd7B",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/addresses_info/',
        {
            "coin": "ETH",
            "address": "0x544094588811118b7701cf4a9dea056e775b4b4e,0x33bb80427711adc881b56a209a374b00388f8a99,0x70099565fe19464b544ccb6ad8080891863eb080,0xafe68A8F8B339D7bbb30A9e486c0c06c3964Cd7B",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/addresses_info/", map[string]string{
    "coin": "ETH",
    "address": "0x544094588811118b7701cf4a9dea056e775b4b4e,0x33bb80427711adc881b56a209a374b00388f8a99,0x70099565fe19464b544ccb6ad8080891863eb080,0xafe68A8F8B339D7bbb30A9e486c0c06c3964Cd7B",
})

Parameters

参数 类型 必须 描述
coin String 币种代号
address String 地址(如果有Memo,竖线隔开),多地址逗号隔开

Response

{
    "success": true,
    "result": {
        "coin": "ETH",
        "addresses": "0x544094588811118b7701cf4a9dea056e775b4b4e,0x33bb80427711adc881b56a209a374b00388f8a99,0x70099565fe19464b544ccb6ad8080891863eb080"
    }
}

属性 类型 含义解释
coin String 币种代号
address String 仅返回其中正确归属的地址,多地址逗号隔开(如果有Memo,竖线隔开)

验证地址合法性

可用此接口验证某地址是否为一个合法地址,部分Memo币的Memo是否合法(如XRP)

HTTP Request

GET /v1/custody/is_valid_address/

request(
    "GET",
    "/v1/custody/is_valid_address/",
    {
        "coin": "ETH",
        "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/is_valid_address/',
        {
            "coin": "ETH",
            "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/is_valid_address/", map[string]string{
    "coin": "ETH",
    "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",
})

Parameters

参数 类型 必须 描述
coin String 币种代号
address String 地址(如果有Memo,竖线隔开)

Response

{
    "success": true,
    "result": true
}
----
{
    "success": true,
    "result": false
}

查看地址总表

HTTP Request

GET /v1/custody/address_history/

request(
    "GET",
    "/v1/custody/address_history/",
    {
        "coin": "ETH",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/address_history/',
        {
            "coin": "ETH",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/address_history/", map[string]string{
    "coin": "ETH",
})

Parameters

参数 类型 必须 描述
coin String 币种代号

Response

{
    "success": true,
    "result": [{
        "coin": "ETH",
        "address": "0x544094588811118b7701cf4a9dea056e775b4b4e"
    }, {
        "coin": "ETH",
        "address": "0x644094588811118b7701cf4a9dea056e775b4b4e"
    }, {
        "coin": "ETH",
        "address": "0x574094588811118b7701cf4a9dea056e775b4b4e"
    }]
}
属性 类型 含义解释
coin String 币种代号
address String 地址(如果有Memo,竖线隔开)

测试

为更好的聚焦主流公链的维护,测试环境仅支持 BTC, ETH, EOS_EOS, TRON, TETH, XTN 6条公链,如果您有特殊的不在此列的公链测试需求,可联系我们的客服人员。

获取测试币

Cobo 在 Sandbox 环境支持 TETH(ETH测试币), XTN(BTC测试币), 客户可以通过第三方网站获取测试币并在测试环境浏览器查看您的测试结果,以下网站供参考(部分网站可能有IP限频):

TETH(ETH测试币)-Ropsten

浏览器: https://ropsten.etherscan.io/

测试币申请链接(仅供参考):https://faucet.ropsten.be/

XTN(BTC测试币)-Testnet

浏览器: https://live.blockcypher.com/btc-testnet/

测试币申请链接(仅供参考):

https://tbtc.bitaps.com/

https://testnet-faucet.mempool.co/

https://bitcoinfaucet.uo1.net/send.php

Loop 联盟

查看 Loop 联盟地址详情

对于参与Loop的客户, 可以通过该接口判断某个提现目标地址是否是 Loop 地址 当您的用户在您的提币页面输入目标地址后,您可调用此接口验证,如果为 Loop 联盟地址,您可以在前端页面上告知用户 “Loop 联盟转账,无矿工费,极速到账!”, 并减免掉相关手续费。

如果不是 Loop 联盟地址,您依然可以继续使用 Custody 提币接口提币,该交易会被自动判定为上链交易,需要支付手续费。

更多 Loop 相关信息以及申请加入 Loop 联盟, 请见: https://loop.top/

HTTP Request

GET /v1/custody/internal_address_info/

request(
    "GET",
    "/v1/custody/internal_address_info/",
    {
        "coin": "ETH",
        "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",

    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/internal_address_info/',
        {
            "coin": "ETH",
            "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",

        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/internal_address_info/", map[string]string{
    "coin": "ETH",
    "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",

})

Parameters

参数 类型 必须 描述
coin String 币种代号
address String 地址(也支持将memo竖线附在address后)
memo String memo

Response

{
    "success": true,
    "result": {
        "coin": "ETH",
        "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",
        "is_internal_address": true,
        "internal_org": "CoboWalletProduction",
        "internal_wallet": "CoboWalletProduction"
    }
}
属性 类型 含义解释
coin String 币种代号
address String 充值地址
is_internal_address Bool 是否是 Loop 地址
internal_org String Loop 地址所属 Org 机构
internal_wallet String Loop 地址所属 Wallet 钱包

批量验证 Loop 联盟地址

对于参与 Loop的客户, 可以通过该接口批量判断某些提现目标地址是否是 Loop 地址

HTTP Request

GET /v1/custody/internal_address_info_batch/

request(
    "GET",
    "/v1/custody/internal_address_info_batch/",
    {
        "coin": "ETH",
        "address": "0x544094588811118b7701cf4a9dea056e775b4b4e,0x777094588811118b7701cf4a9dea056e775b4b4e",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/internal_address_info_batch/',
        {
            "coin": "ETH",
            "address": "0x544094588811118b7701cf4a9dea056e775b4b4e,0x777094588811118b7701cf4a9dea056e775b4b4e",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/internal_address_info_batch/", map[string]string{
    "coin": "ETH",
    "address": "0x544094588811118b7701cf4a9dea056e775b4b4e,0x777094588811118b7701cf4a9dea056e775b4b4e",
})

Parameters

参数 类型 必须 描述
coin String 币种代号
address String 地址(如果有Memo,竖线隔开),多个地址用逗号分隔

Response

{
    "success": true,
    "result": [{
        "coin": "ETH",
        "address": "0x544094588811118b7701cf4a9dea056e775b4b4e",
        "is_internal_address": true,
    }, {
        "coin": "ETH",
        "address": "0x777094588811118b7701cf4a9dea056e775b4b4e",
        "is_internal_address": false
    }]
}
属性 类型 含义解释
coin String 币种代号
address String 充值地址
is_internal_address Bool 是否是 Loop 地址

Loop 联盟交易浏览器

为了方便您的用户查询交易,Loop为您提供了官方的交易浏览器。您可以在您的平台为用户提供链接查询交易详情,链接拼接格式:https://loop.top/tx/[Loop_ID] 如 https://loop.top/tx/L456e5cb652dcfe557a43fd9d8e48627

交易

获取已入账交易详情(deposit&withdraw)

只有满足了币种确认数阈值,成功入账的交易会在此显示。 对于来自 Cobo 平台的充值,相比起其他的平台外充值,会提前确认入账(即无需达到通用确认数阈值即可入账)。 由于确认数阈值有可能动态调整(与链的稳定性、分叉风险相关),建议您不要以固定的确认数阈值校验,以 Cobo 确认的交易为准(即本接口能查询到的交易)。

*已经确认了的交易不会再推送后续的确认数值变化

HTTP Request

GET /v1/custody/transaction/

request(
    "GET"
    " /v1/custody/transaction/ "
    {
        "id": "20210112173820000166329000003582",

    },
    api_key, api_secret, host
)
coboFetch(
    "GET"
    " /v1/custody/transaction/ "
    {
        "id": "20210112173820000166329000003582",

    },
    api_key, api_secret, host
).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
request(
    "GET"
    " /v1/custody/transaction/ "
    {
        "id": "20210112173820000166329000003582",

    })

请求参数

参数 类型 必须 描述
id String Cobo提供交易唯一ID(2019xxxxx)

响应结果

{
    "success": true,
    "result": {
        "id": "20210112173820000166329000003582",
        "coin": "BTC",
        "display_code": "BTC",
        "description": "Bitcoin",
        "decimal": 8,
        "address": "19AR6YWEGbSoY8UT9Ksy9WrmrZPD5sL4Ku",
        "source_address": "bc1q0qfzuge7vr5s2xkczrjkccmxemlyyn8mhx298v",
        "side": "withdraw",
        "amount": "80000",
        "abs_amount": "0.0008",
        "txid": "239861be9a4afe080c359b7fe4a1d035945ec46256b1a0f44d1267c71de8ec28",
        "vout_n": 0,
        "request_id": "web_send_by_user_327_1610444045047",
        "status": "success",
        "abs_cobo_fee": "0",
        "created_time": 1610444045158,
        "last_time": 1610445878970,
        "confirmed_num": 3,
        "tx_detail": {
            "txid": "239861be9a4afe080c359b7fe4a1d035945ec46256b1a0f44d1267c71de8ec28",
            "blocknum": 665711,
            "blockhash": "00000000000000000007137dde44472364eb80126b7d98c12ffb8d37ba11ad33",
            "fee": 0,
            "actualgas": 17812,
            "gasprice": 1,
            "hexstr": ""
        },
        "source_address_detail": "bc1q0qfzuge7vr5s2xkczrjkccmxemlyyn8mhx298v",
        "memo": "",
        "confirming_threshold": 3,
        "fee_coin": "BTC",
        "fee_amount": 50000,
        "fee_decimal": 8,
        "type": "external"
    }
}
属性 类型 含义解释
id String Cobo 提供交易唯一ID(2019xxxxx)
coin String 币种代号(Cobo内部代号, 每个币唯一,可在web搜索查看)
display_code String 币种缩写 (非唯一,可能变化,仅供参考)
description String 币种名称全称 (非唯一,可能变化,仅供参考)
decimal Int 币种精度
address String 充值目标地址
memo String 对于部分memo或tag币种, 返回memo或tag字符串
source_address String 源地址
source_address_detail String 逗号分割,所有来源地址
side enum(deposit / withdraw) 交易类型
amount String 交易金额数值 (注意这里的数值包含小数位, 例如BTC的decimal为8位,则这里的100000000代表1个BTC)
abs_amount String 交易金额绝对值 (绝对值, 交易1.5个BTC,这里就是1.5)
abs_cobo_fee String Cobo手续费绝对值 (绝对值, 手续费0.00005个BTC,这里就是0.00005)
txid String 区块链交易ID,在对应的公链上可以查询到
vout_n String 对于一笔交易可以有多个入账地址的公链,这个表示这笔交易在公链Transaction 的 Index
request_id String 提现请求的请求Id
status enum(success / failed / pending) 交易状态
created_time Long 交易创建时间
last_time Long 交易成功(失败)时间
confirming_threshold Int 币种确认数阈值(有可能动态变化)
confirmed_num Int 币种确认数
tx_detail String 交易详情
fee_coin String 交易费币种代号(Cobo内部代号, 每个币种唯一)
fee_amount Int 交易费数值 (注意这里的数值包含小数位, 例如BTC的decimal为8位,则这里的100000000实际为1个BTC)
fee_decimal Int 交易费币种小数点位数
type String external表示上链交易;internal表示 Loop 交易

通过ID查询获取已确认交易记录列表(deposit&withdraw)

满足了 Cobo 要求的确认数阈值,成功入账的交易会在此显示

HTTP Request

GET /v1/custody/transactions_by_id/

request(
    'GET',
    '/v1/custody/transactions_by_id/',
    {
        "coin": "BTC_USDT",
        "side": "deposit",
        "max_id": 20181114112147059335000000359061
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/transactions_by_id/',
        {
            "coin": "BTC_USDT",
            "side": "deposit",
            "max_id": 20181114112147059335000000359061

        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/transactions_by_id/", map[string]string{
    "coin": "BTC_USDT",
    "side": "deposit",
    "max_id": 20181114112147059335000000359061
})

请求参数

参数 类型 必须 描述
coin String 币种代号, 不传返回所有币种
side enum(deposit / withdraw) 充值/提现
address String 充值(提现)地址, 不传则返回所有地址的记录
max_id String 交易记录的Id上限, 不传则默认返回最新记录
min_id String 交易记录的Id下限, 若传该字段则排序也会由时间倒序变为时间正序, 不传则默认返回最新记录
limit Int 每页大小, 不传则默认为50, 最大也是50
include_financial String 请求所有交易, 如果传入, 返回所有交易(包括Staking、Trading)

响应结果

{
"success": true,
"result": [{
    "id": "20181114112147059335000000359061",
    "coin": "BTC_USDT",
    "display_code": "USDT",
    "description": "Tether",
    "decimal": 8,
    "address": "18bpqEgCJ17TwxDwT26YjQnSBFVgcLBimE",
    "memo": "",
    "source_address": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
    "source_address_detail": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
    "side": "deposit",
    "amount": "100000000",
    "abs_amount": "1",
    "abs_cobo_fee": "0.0005",
    "txid": "73ea2bcb20b36115bc50588a8bcdbfbaaeb3d75656c2b104ef4a1234e5dbe550",
    "vout_n": 0,
    "request_id": null,
    "status": "success",
    "created_time": 1542165707058,
    "last_time": 1542165707058,
    "confirming_threshold": 3,
    "confirmed_num": 3,
    "fee_coin": "BTC",
    "fee_amount": 546,
    "fee_decimal": 8,
    "type": "external"
}, {
    }]
}

通过时间查询获取已确认交易记录列表(deposit&withdraw)

满足了 Cobo 要求的确认数阈值,成功入账的交易会在此显示

HTTP Request

GET /v1/custody/transactions_by_time/

request(
    'GET',
    '/v1/custody/transactions_by_time/',
    {
        "coin": "BTC_USDT",
        "side": "deposit",
        "begin_time": 1542165707058
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/transactions_by_time/',
        {
            "coin": "BTC_USDT",
            "side": "deposit",
            "begin_time": 1542165707058
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/transactions_by_time/", map[string]string{
    "coin": "BTC_USDT",
    "side": "deposit",
    "begin_time": 1542165707058
})

请求参数

参数 类型 必须 描述
coin String 币种代号, 不传返回所有币种
side enum(deposit / withdraw) 充值/提现
address String 充值(提现)地址, 不传则返回所有地址的记录
begin_time Long 开始时间戳(毫秒), 如果传入, 交易确认时间小于等于这个的交易不会返回
end_time Long 结束时间戳(毫秒), 如果传入, 交易确认时间大于等于这个的交易不会返回
limit Int 每页大小, 不传则默认为50, 最大也是50
include_financial String 请求所有交易, 如果传入, 返回所有交易(包括Staking、Trading)

响应结果

{
"success": true,
"result": [{
    "id": "20181114112147059335000000359061",
    "coin": "BTC_USDT",
    "display_code": "USDT",
    "description": "Tether",
    "decimal": 8,
    "address": "18bpqEgCJ17TwxDwT26YjQnSBFVgcLBimE",
    "memo": "",
    "source_address": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
    "source_address_detail": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
    "side": "deposit",
    "amount": "100000000",
    "abs_amount": "1",
    "abs_cobo_fee": "0.0005",
    "txid": "73ea2bcb20b36115bc50588a8bcdbfbaaeb3d75656c2b104ef4a1234e5dbe550",
    "vout_n": 0,
    "request_id": null,
    "status": "success",
    "created_time": 1542165707058,
    "last_time": 1542165707058,
    "confirming_threshold": 3,
    "confirmed_num": 3,
    "fee_coin": "BTC",
    "fee_amount": 546,
    "fee_decimal": 8,
    "type": "external"
}, {
    }]
}

获取确认中的交易记录列表(deposit&withdraw)

获取确认中(还未入账)的交易记录列表,达到确认数阈值后该记录将转移到 transaction_history 列表

HTTP Request

GET /v1/custody/pending_transactions/

request(
    'GET',
    '/v1/custody/pending_transactions/',
    {
        "coin": "ETH",
        "side": "deposit",

    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/pending_transactions/',
        {
            "coin": "ETH",
            "side": "deposit",

        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/pending_transactions/", map[string]string{
    "coin": "ETH",
    "side": "deposit",

})

请求参数

参数 类型 必须 描述
coin String 币种代号, 不传返回所有币种
side enum(deposit / withdraw) 充值/提现
max_id String 交易记录的Id上限, 不传则默认返回最新记录
min_id String 交易记录的Id下限, 若传该字段则排序也会由时间倒序变为时间正序, 不传则默认返回最新记录
limit Int 每页大小, 不传则默认为50, 最大也是50

响应结果

{
        "success": true,
        "result": [{
            "id": "20181114112147059335000000359061",
            "coin": "BTC_USDT",
            "display_code": "USDT",
            "description": "Tether",
            "decimal": 8,
            "address": "18bpqEgCJ17TwxDwT26YjQnSBFVgcLBimE",
            "memo": "",
            "source_address": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
            "source_address_detail": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
            "side": "deposit",
            "amount": "100000000",
            "abs_amount": "1",
            "txid": "73ea2bcb20b36115bc50588a8bcdbfbaaeb3d75656c2b104ef4a1234e5dbe550",
            "vout_n": 0,
            "request_id": null,
            "status": "pending",
            "created_time": 1542165707058,
            "last_time": 1542165707058,
            "confirming_threshold": 3,
            "confirmed_num": 3,
            "type": "external"
        }, {
        }]
}

获取确认中的交易详情(deposit&withdraw)

对于启用了监听确认详情的钱包, 可以根据确认数回调信息内的id进行详情查询, 但是若确认数不足阈值, 则交易实际上未入账, 并无法由transaction系列接口获取(该接口实现方式与原来的‘/v1/custody/deposit_info/’保持一致, 原deposit_info接口使用不受影响,建议您使用此新接口 )

HTTP Request

GET /v1/custody/pending_transaction/

request(
    "GET",
    "/v1/custody/pending_transaction/",
    {
        "id": "20181114112147059335000000359061"
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/pending_transaction/',
        {
            "id": "20181114112147059335000000359061"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/pending_transaction/", map[string]string{
    "id": "20181114112147059335000000359061"
})

请求参数

参数 类型 必须 描述
id String Cobo提供唯一ID(2019xxxxx)

响应结果

{
    "success": true,
    "result": {
    "id": "20181114112147059335000000359061",
    "coin": "BTC_USDT",
    "display_code": "USDT",
    "description": "Tether",
    "decimal": 8,
    "address": "18bpqEgCJ17TwxDwT26YjQnSBFVgcLBimE",
    "memo": "",
    "source_address": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
    "source_address_detail": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
    "side": "deposit",
    "amount": "100000000",
    "abs_amount": "1",
    "txid": "73ea2bcb20b36115bc50588a8bcdbfbaaeb3d75656c2b104ef4a1234e5dbe550",
    "vout_n": 0,
    "request_id": null,
    "status": "pending",
    "created_time": 1542165707058,
    "last_time": 1542165707058,
    "confirming_threshold": 3,
    "confirmed_num": 3,
    "type": "external"
    }
}

获取已确认交易记录列表(deposit&withdraw)

满足了 Cobo 要求的确认数阈值,成功入账的交易会在此显示(注意:该接口准备废弃,建议使用 /v1/custody/transactions_by_id/ 和 /v1/custody/transactions_by_time/)

HTTP Request

GET /v1/custody/transaction_history/

request(
    'GET',
    '/v1/custody/transaction_history/',
    {
        "coin": "BTC_USDT",
        "side": "deposit"
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/transaction_history/',
        {
            "coin": "BTC_USDT",
            "side": "deposit"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/transaction_history/", map[string]string{
    "coin": "BTC_USDT",
    "side": "deposit",
})

请求参数

参数 类型 必须 描述
coin String 币种代号, 不传返回所有币种
side enum(deposit / withdraw) 充值/提现
address String 充值(提现)地址, 不传则返回所有地址的记录
max_id String 交易记录的Id上限, 不传则默认返回最新记录
min_id String 交易记录的Id下限, 若传该字段则排序也会由时间倒序变为时间正序, 不传则默认返回最新记录
limit Int 每页大小, 不传则默认为50, 最大也是50
begin_time Long 开始时间戳(毫秒), 如果传入, 交易确认时间小于这个的交易不会返回
end_time Long 结束时间戳(毫秒), 如果传入, 交易确认时间大于这个的交易不会返回
include_financial String 请求所有交易, 如果传入, 返回所有交易(包括Staking、Trading)

响应结果

{
"success": true,
"result": [{
    "id": "20181114112147059335000000359061",
    "coin": "BTC_USDT",
    "display_code": "USDT",
    "description": "Tether",
    "decimal": 8,
    "address": "18bpqEgCJ17TwxDwT26YjQnSBFVgcLBimE",
    "memo": "",
    "source_address": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
    "source_address_detail": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
    "side": "deposit",
    "amount": "100000000",
    "abs_amount": "1",
    "abs_cobo_fee": "0.0005",
    "txid": "73ea2bcb20b36115bc50588a8bcdbfbaaeb3d75656c2b104ef4a1234e5dbe550",
    "vout_n": 0,
    "request_id": null,
    "status": "success",
    "created_time": 1542165707058,
    "last_time": 1542165707058,
    "confirming_threshold": 3,
    "confirmed_num": 3,
    "fee_coin": "BTC",
    "fee_amount": 546,
    "fee_decimal": 8,
    "type": "external"
}, {
    }]
}

提现

提交提现申请

HTTP Request

POST /v1/custody/new_withdraw_request/

request(
    "POST",
    "/v1/custody/new_withdraw_request/",
    {
        "coin": "ETH",
        "address": "0x8e2782aabdf80fbb69399ce3d9bd5ae69a60462c",
        "amount": "100000000000000",
        "request_id": "unique_123456",
        "memo": "hello test"

    },
    api_key, api_secret, host
)
coboFetch('POST', '/v1/custody/new_withdraw_request/',
        {
            "coin": "ETH",
            "address": "0x8e2782aabdf80fbb69399ce3d9bd5ae69a60462c",
            "amount": "100000000000000",
            "request_id": "unique_123456",
            "memo": "hello test"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("POST", "/v1/custody/new_withdraw_request/", map[string]string{
    "coin": "ETH",
    "address": "0x8e2782aabdf80fbb69399ce3d9bd5ae69a60462c",
    "amount": "100000000000000",
    "request_id": "unique_123456",
    "memo": "hello test",
})

请求参数

参数 类型 必须 描述
coin String 币种代号
request_id String 提现申请Id 【Cobo 确认您提现请求的唯一标识,应与您的用户提币行为一一对应,防止重发!!!建议使用 uuid 保证唯一性 且 小于等于120字符】
address String 提现地址
amount String 提现数额,【注意要提前乘以相应币种的decimal】, 例如提现1BTC, amount传100000000
memo String 交易memo(在某些币种里面也叫tag), 当提现EOS, XRP, IOST等币时,根据情况传入
force_external String 非空传值表示强制上链(任意值),对于开启联盟的客户,可以根据情况将交易通过上链的形式发起
force_internal String 非空传值表示强制Loop联盟交易(任意值),已开启Loop联盟的客户,可以根据情况传入,Cobo会将不是联盟交易地址的交易返回失败

响应结果

{
  "success": true,
  "result": ""
}

获取提现信息

HTTP Request

GET /v1/custody/withdraw_info_by_request_id/

request(
    "GET",
    "/v1/custody/withdraw_info_by_request_id/",
    {
        "request_id": "unique_123456"
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/withdraw_info_by_request_id/',
        {
            "request_id": "unique_123456"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/withdraw_info_by_request_id/", map[string]string{
    "request_id": "unique_123456",
})

请求参数

参数 类型 必须 描述
request_id String 提现申请Id

响应结果

{
    "success": true,
    "result": {
        "id": "",
        "coin": "BTC_USDT",
        "display_code": "USDT",
        "description": "Tether",
        "decimal": 8,
        "address": "18bpqEgCJ17TwxDwT26YjQnSBFVgcLBimE",
        "memo": "",
        "source_address": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
        "source_address_detail": "1F5i9mdCAsU2EfQtXYpwZgW2UFzS8A2EMn",
        "side": "withdraw",
        "amount": "100000000",
        "abs_amount": "1",
        "txid": "73ea2bcb20b36115bc50588a8bcdbfbaaeb3d75656c2b104ef4a1234e5dbe550",
        "vout_n": 0,
        "request_id": "test_request_id",
        "status": "pending",
        "created_time": 1542165707058,
        "last_time": 1542165707058,
        "confirming_threshold": 3,
        "confirmed_num": 3,
        "type": "external"
    }
}

Staking

获取某一在售产品详情

HTTP Request

GET v1/custody/staking_product/

request(
    "GET",
    "/v1/custody/staking_product/",
    {
        "product_id": 2751,
        "language": "zh",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/staking_product/',
        {
            "product_id": 2751,
            "language": "zh",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/staking_product/", map[string]string{
    "product_id": 2751,
    "language": "zh",
})

Parameters

参数 类型 必须 描述
product_id String 产品ID
language String 描述语言(zh或en, 默认en)

Response

{
    "success": true,
    "result": {
        "product_id": 2751,
        "name": "ZEL PPS",
        "description": "30 ZEL\u8d77\u6295\uff0c\u9636\u68af\u6536\u76ca\u7387\uff0c\u8d28\u62bc\u8d8a\u591a\uff0c\u6536\u76ca\u7387\u8d8a\u9ad8\n\u8d28\u62bc\u540e\u7b2c\u4e8c\u5929\u5f00\u59cb\u4ea7\u751f\u6536\u76ca\uff0c\u6bcf\u5929\u6839\u636e\u5168\u7f51\u6536\u76ca\u60c5\u51b5\u53d1\u653e\u6536\u76ca\uff0c\u9009\u62e9\u3010\u5230\u671f\u540e\u81ea\u52a8\u7eed\u671f\u3011\uff0c\u65e0\u7f1d\u8854\u63a5\u4e0b\u4e00\u671f\u6536\u76ca\n\u968f\u65f6\u53ef\u5212\u51fa\uff0cT+1\u5230\u8d26\uff0c\u6536\u76ca\u5468\u671f\u5185\u53d6\u51fa\u635f\u5931\u5f53\u671f\u6536\u76ca\n\u6bcf\u6b21\u53d6\u51fa\u8d4e\u56de\u8d39: 10 ZEL",
        "doc_src": "https://support.cobo.com/hc/zh-cn/articles/360025623074",
        "coin": "ZEL",
        "coin_decimal": 8,
        "reward_coin": "ZEL",
        "reward_coin_decimal": 8,
        "unstake_fee": "1000000000",
        "min_amount": "3000000000",
        "rate": "0.1351459495",
        "rate_type": 2,
        "days": 20,
        "stake_type": "masternode",
        "lockup": false,
        "start_stake_time": 1573455600000,
        "stop_stake_time": 1573542000000,
        "start_staking_time": 1573574400000,
        "stop_staking_time": 1575302400000,
        "liquidate_time": 1575388800000,
        "reward_liquidate_time": 1575388800000,
        "product_group": "ZEL--PPS"
    }
}
属性 类型 含义解释
product_id Int 币种代号
name String 产品名
description String 产品介绍
doc_src String 产品说明文档
coin String 币种
coin_decimal Int 币种 Decimal 精度
reward_coin String 收益币种
reward_coin_decimal Int 收益币种 Decimal 精度
unstake_fee String 赎回费
min_amount String 最低质押金额
rate String 年化利率
rate_type Int 1:固定收益率 2:浮动收益率
days Int 收益周期
stake_type String Staking 类型(主节点,代投票等)
lockup Bool 是否锁定
start_stake_time Int 产品起售时间(毫秒时间戳)
stop_stake_time Int 产品止售时间(毫秒时间戳)
start_staking_time Int 产品开始计息时间(毫秒时间戳)
stop_staking_time Int 产品终止计息时间(毫秒时间戳)
liquidate_time Int 本金到账时间(毫秒时间戳)
reward_liquidate_time Int 利息到账时间(毫秒时间戳)
product_group String 产品group name

获取所有在售产品

HTTP Request

GET /v1/custody/staking_products/

request(
    "GET",
    "/v1/custody/staking_products/",
    {
        "coin": "ZEL",
        "language": "zh",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/staking_products/',
        {
            "coin": "ZEL",
            "language": "zh",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/staking_products/", map[string]string{
    "coin": "ZEL",
    "language": "zh",
})

Parameters

参数 类型 必须 描述
coin String 币种Code
language String 描述语言(zh或en, 默认en)

Response

{   "success": true,   "result": [{ "product_id": 2751, "name": "ZEL PPS", "description": "30 ZEL\u8d77\u6295\uff0c\u9636\u68af\u6536\u76ca\u7387\uff0c\u8d28\u62bc\u8d8a\u591a\uff0c\u6536\u76ca\u7387\u8d8a\u9ad8\n\u8d28\u62bc\u540e\u7b2c\u4e8c\u5929\u5f00\u59cb\u4ea7\u751f\u6536\u76ca\uff0c\u6bcf\u5929\u6839\u636e\u5168\u7f51\u6536\u76ca\u60c5\u51b5\u53d1\u653e\u6536\u76ca\uff0c\u9009\u62e9\u3010\u5230\u671f\u540e\u81ea\u52a8\u7eed\u671f\u3011\uff0c\u65e0\u7f1d\u8854\u63a5\u4e0b\u4e00\u671f\u6536\u76ca\n\u968f\u65f6\u53ef\u5212\u51fa\uff0cT+1\u5230\u8d26\uff0c\u6536\u76ca\u5468\u671f\u5185\u53d6\u51fa\u635f\u5931\u5f53\u671f\u6536\u76ca\n\u6bcf\u6b21\u53d6\u51fa\u8d4e\u56de\u8d39: 10 ZEL", "doc_src": "https://support.cobo.com/hc/zh-cn/articles/360025623074", "coin": "ZEL", "coin_decimal": 8, "reward_coin": "ZEL", "reward_coin_decimal": 8, "unstake_fee": "1000000000", "min_amount": "3000000000", "rate": "0.1351459495", "rate_type": 2, "days": 20, "stake_type": "masternode", "lockup": false, "start_stake_time": 1573455600000, "stop_stake_time": 1573542000000, "start_staking_time": 1573574400000, "stop_staking_time": 1575302400000, "liquidate_time": 1575388800000, "reward_liquidate_time": 1575388800000, "product_group": "ZEL PPS"   },{}] }

Parameters

参数详见staking_product

Stake 质押

可以通过该接口,参与在售产品的质押

HTTP Request

POST /v1/custody/staking_stake/

request(
    "POST",
    "/v1/custody/staking_stake/",
    {
        "product_id": 2751
        "amount": 4000000000
    },
    api_key, api_secret, host
)
coboFetch('POST', '/v1/custody/staking_stake/',
        {
            "product_id": 2751
            "amount": 4000000000
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("POST", "/v1/custody/staking_stake/", map[string]string{
    "product_id": 2751
    "amount": 4000000000
})

Parameters

参数 类型 必须 描述
product_id Int 产品ID
amount Int 质押额度

Response

{
    "success": true,
    "result": null
}

Unstake 赎回

可以通过该接口,从非锁定的在售产品中解除质押

HTTP Request

POST /v1/custody/staking_unstake/

request(
    "POST",
    "/v1/custody/staking_unstake/",
    {
        "product_id": 2751
        "amount": 4000000000
    },
    api_key, api_secret, host
)
coboFetch('POST', '/v1/custody/staking_unstake/',
        {
            "product_id": 2751
            "amount": 4000000000
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("POST", "/v1/custody/staking_unstake/", map[string]string{
    "product_id": 2751
    "amount": 4000000000
})

Parameters

参数 类型 必须 描述
product_id Int 产品ID
amount Int 解除质押额度

Response

{
    "success": true,
    "result": null
}

查询质押中的数据

可以通过该接口获得所有质押期间的数据

HTTP Request

GET /v1/custody/stakings/

request(
    "GET",
    "/v1/custody/stakings/",
    {
        "coin": "ZEL",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/stakings/',
        {
            "coin": "ZEL",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/stakings/", map[string]string{
    "coin": "ZEL",
})

Parameters

参数 类型 必须 描述
coin String 币种代号
language String 描述语言(zh或en, 默认en)

Response

{
    "success": true,
    "result": [{
        "staking_id": 444,
        "coin": "ZEL",
        "coin_decimal": 8,
        "amount": 4000000000,
        "reward_coin": "ZEL",
        "reward_coin_decimal": 8,
        "reward_amount": 500,
        "product": {
        }
    }, {}, {}]
}
属性 类型 含义解释
staking_id Int 质押ID
coin String 币种代号
coin_decimal Int 币种Decimal 精度
amount Int 质押金额
reward_coin String 收益币种
reward_coin_decimal Int 收益币种Decimal 精度
reward_amount String 预估收益
product Dict 详见staking_product

查询赎回期间的数据

可以通过该接口获得所有解除质押到账期间的数据

HTTP Request

GET /v1/custody/unstakings/

request(
    "GET",
    "/v1/custody/unstakings/",
    {
        "coin": "ZEL",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/unstakings/',
        {
            "coin": "ZEL",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/unstakings/", map[string]string{
    "coin": "ZEL",
})

Parameters

参数 类型 必须 描述
coin String 币种代号

Response

{
    "success": true,
    "result": [{
        "coin": "ZEL",
        "coin_decimal": 8,
        "amount": 4000000000,
        "unstake_time": 1575388800000,
        "liquidate_time": 1575388800000
    }, {}, {}]
}
属性 类型 含义解释
coin String 币种代号
coin_decimal Int 币种Decimal
amount Int 赎回金额
unstake_time Int 赎回时间(毫秒时间戳)
liquidate_time Int 到账时间(毫秒时间戳)

查询质押历史

可以通过该接口获得所有质押历史

HTTP Request

GET /v1/custody/staking_history/

request(
    "GET",
    "/v1/custody/staking_history/",
    {
        "coin": "ZEL",
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/staking_history/',
        {
            "coin": "ZEL",
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/staking_history/", map[string]string{
    "coin": "ZEL",
})

Parameters

参数 类型 必须 描述
coin String 币种代号
type String stake
max_id String id最大限制
limit String 列表大小限制,最大有效值为50
product_id Int 产品id

Response

{
    "success": true,
    "result": [
    {
        "activity_id": "20191112000112159193000000094747",
        "coin": "ZEL",
        "amount": "1424658",
        "type": "unstake",
        "time": 1573488072058,
        "product": {

        }
    }, {}, {}]
}
属性 类型 含义解释
id String 行为编号
coin String 币种代号
amount String 行为金额
type String 行为类型 (stake unstake reward fee)
time Int 时间(毫秒时间戳)
product Dict 详见staking_product

Trading

Trading 是 Cobo Custody 基于资产托管服务,为交易团队、基金、资产管理平台、投资方等提供的交易所资产托管服务。解决投资人和交易团队信任问题,方便跨所划转,为交易团队提供更优费率、提高资金利用率。 更多介绍见: Trading 介绍

资方可使用当前钱包 Operate 类型的 API Key 【钱包-API 中创建】进行如下所有操作,对该钱包下所有投资组合及投资组合内账户生效。 交易员(如量化团队)可使用某一 portfolio 投资组合的 API Key 【Trading-某portfolio-API 中创建】, 仅对该投资组合及投资组合内账户生效。

下方所需的参数,如 portfolio_id, exchange_account_token 可在 Web 界面获取:

1.资方 investor1 investor2

2.交易员 trader1 trader2

从资方钱包向交易所充值(仅资方)

仅资方有权限从资方的钱包向某个投资组合注入资金

HTTP Request

POST /v1/custody/trading_deposit/

request(
    "POST",
    "/v1/custody/trading_deposit/",
    {
        "exchange_account_token": "token",
        "coin": "BTC",
        "amount": "100000000",
        "request_id": "UNIQUE_ID_FOR_DEPOSIT"
    },
    api_key, api_secret, host
)
coboFetch('POST', '/v1/custody/trading_deposit/',
        {
            "exchange_account_token": "token",
            "coin": "BTC",
            "amount": "100000000",
            "request_id": "UNIQUE_ID_FOR_DEPOSIT"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("POST", "/v1/custody/trading_deposit/", map[string]string{
    "exchange_account_token": "token",
    "coin": "BTC",
    "amount": "100000000",
    "request_id": "UNIQUE_ID_FOR_DEPOSIT"
})

Parameters

参数 类型 必须 描述
exchange_account_token String 目标交易所子账户token
coin String 币种
amount Int 传参金额,带decimal (例如1BTC, amount传100000000)
request_id String 充值唯一id

Response

{
    "success": true,
    "result": {
        "request_id": "UNIQUE_ID_FOR_DEPOSIT",
        "coin": "BTC",
        "amount": 100000000,
        "abs_amount": "1",
        "status": "ok",
        "fee": 500000,
        "abs_fee": "0.0005",
        "estimated_amount_received": "99950000"
    }
}
属性 类型 含义解释
request_id String 请求唯一ID
coin String 币种
amount Int 传参金额 带decimal
abs_amount String 传参金额 不考虑decimal
status String 状态,包括 ok, pending, failed, human_check
fee Int 手续费 带decimal
abs_fee String 手续费 不考虑decimal
estimated_amount_received Int 预估到账金额 带decimal

查询 Trading 充值(仅资方)

HTTP Request

GET /v1/custody/trading_deposit_info/

request(
    "GET",
    "/v1/custody/trading_deposit_info/",
    {
        "request_id": "UNIQUE_ID_FOR_DEPOSIT"
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/trading_deposit_info/',
        {
            "request_id": "UNIQUE_ID_FOR_DEPOSIT"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/trading_deposit_info/", map[string]string{
    "request_id": "UNIQUE_ID_FOR_DEPOSIT"
})

Parameters

参数 类型 必须 描述
request_id String 充值唯一id

Response

同trading_deposit

交易所跨所划转

资方和交易员身份都可以通过此接口在某一投资组合下的账户之间划转,可以跨所(可能需要等待上链交易时长),但不能跨投资组合划转

HTTP Request

POST /v1/custody/trading_transfer/

request(
    "POST",
    "/v1/custody/trading_transfer/",
    {
        "from_exchange_account_token": "from_token",
        "to_exchange_account_token": "to_token",
        "coin": "BTC",
        "amount": "100000000",
        "request_id": "UNIQUE_ID_FOR_TRANSFER"
    },
    api_key, api_secret, host
)
coboFetch('POST', '/v1/custody/trading_transfer/',
        {
            "from_exchange_account_token": "from_token",
            "to_exchange_account_token": "to_token",
            "coin": "BTC",
            "amount": "100000000",
            "request_id": "UNIQUE_ID_FOR_TRANSFER"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("POST", "/v1/custody/trading_transfer/", map[string]string{
    "from_exchange_account_token": "from_token",
    "to_exchange_account_token": "to_token",
    "coin": "BTC",
    "amount": "100000000",
    "request_id": "UNIQUE_ID_FOR_TRANSFER"
})

Parameters

参数 类型 必须 描述
from_exchange_account_token String 源目交易所子账户token
to_exchange_account_token String 目标交易所子账户token
coin String 币种
amount Int 传参金额,带decimal (例如1BTC, amount传100000000)
request_id String 划转唯一id

Response

{
    "success": true,
    "result": {
        "request_id": "UNIQUE_ID_FOR_TRANSFER",
        "coin": "BTC",
        "amount": 100000000,
        "abs_amount": "1",
        "status": "ok",
        "fee": 500000,
        "abs_fee": "0.0005",
        "estimated_amount_received": "99950000"
    }
}
属性 类型 含义解释
request_id String 请求唯一ID
coin String 币种
amount Int 传参金额 带decimal
abs_amount String 传参金额 不考虑decimal
status String 状态,包括 ok, pending, failed, human_check
fee Int 手续费 带decimal
abs_fee String 手续费 不考虑decimal
estimated_amount_received Int 预估到账金额 带deciaml

查询 Trading 划转

HTTP Request

GET /v1/custody/trading_transfer_info/

request(
    "GET",
    "/v1/custody/trading_transfer_info/",
    {
        "request_id": "UNIQUE_ID_FOR_TRANSFER"
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/trading_transfer_info/',
        {
            "request_id": "UNIQUE_ID_FOR_TRANSFER"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/trading_transfer_info/", map[string]string{
    "request_id": "UNIQUE_ID_FOR_TRANSFER"
})

Parameters

参数 类型 必须 描述
request_id String 划转唯一id

Response

同trading_transfer

从交易所提现回资方钱包

资方和交易员身份都可以通过此接口从某账户提现回资方钱包。注意:此处提现仅能将资金返回到资方注入资产的钱包,资方可自行操作,或者由交易员主动发起还款、清算

HTTP Request

POST /v1/custody/trading_withdraw/

request(
    "POST",
    "/v1/custody/trading_withdraw/",
    {
        "exchange_account_token": "token",
        "coin": "BTC",
        "amount": "100000000",
        "request_id": "UNIQUE_ID_FOR_WITHDRAW"
    },
    api_key, api_secret, host
)
coboFetch('POST', '/v1/custody/trading_withdraw/',
        {
            "exchange_account_token": "token",
            "amount": "100000000",
            "coin": "BTC",
            "request_id": "UNIQUE_ID_FOR_WITHDRAW"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("POST", "/v1/custody/trading_withdraw/", map[string]string{
    "exchange_account_token": "token",
    "coin": "BTC",
    "amount": "100000000",
    "request_id": "UNIQUE_ID_FOR_WITHDRAW"
})

Parameters

参数 类型 必须 描述
exchange_account_token String 提现from交易所子账户token(token 可在 Web 查看)
coin String 币种
amount Int 传参金额,带 decimal (例如1BTC, amount传100000000)
request_id String 自定义的提现唯一id (uuid)

Response

{
    "success": true,
    "result": {
        "request_id": "UNIQUE_ID_FOR_WITHDRAW",
        "coin": "BTC",
        "amount": 100000000,
        "abs_amount": "1",
        "status": "ok",
        "fee": 500000,
        "abs_fee": "0.0005",
        "estimated_amount_received": "99950000"
    }
}
属性 类型 含义解释
request_id String 请求唯一ID
coin String 币种
amount Int 传参金额 带decimal
abs_amount String 传参金额 不考虑decimal
status String 状态,包括 ok, pending, failed, human_check
fee Int 手续费 带decimal
abs_fee String 手续费 不考虑decimal
estimated_amount_received Int 预估到账金额 带decimal

查询 Trading 提现

HTTP Request

GET /v1/custody/trading_withdraw_info/

request(
    "GET",
    "/v1/custody/trading_withdraw_info/",
    {
        "request_id": "UNIQUE_ID_FOR_WITHDRAW"
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/trading_withdraw_info/',
        {
            "request_id": "UNIQUE_ID_FOR_WITHDRAW"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/trading_withdraw_info/", map[string]string{
    "request_id": "UNIQUE_ID_FOR_WITHDRAW"
})

Parameters

参数 类型 必须 描述
request_id String 提现唯一id

Response

同 trading_withdraw

查询 Trading_Portfolio 余额

资方可查询当前钱包下所有的投资组合余额, 交易员仅能查询当前投资组合余额

HTTP Request

GET /v1/custody/summary_trading_portfolio_balance/

request(
    "GET",
    "/v1/custody/summary_trading_portfolio_balance/",
    {
        "portfolio_id": "UNIQUE_ID_FOR_PORTFOLIO"
    },
    api_key, api_secret, host
)
coboFetch('GET', '/v1/custody/summary_trading_portfolio_balance/',
        {
            "portfolio_id": "UNIQUE_ID_FOR_PORTFOLIO"
        },
        api_key, api_secret, host
    ).then(res => {
        res.json().then((data)=>{
            console.log(JSON.stringify(data, null, 4));
        })
    }).catch(err => {
        console.log(err)
    });
Request("GET", "/v1/custody/summary_trading_portfolio_balance/", map[string]string{
    "portfolio_id": "UNIQUE_ID_FOR_PORTFOLIO"
})

Parameters

参数 类型 必须 描述
portfolio_id String Investor Role参数为必填,Trader Role无需传参 投资组合唯一id

Response

{
    "success": true,
    "result": {
        "portfolio_id": "cobo_test2",
        "portfolio_name": "",
        "exchange_accounts": [
            {
                "BTC": 2069698,
                "coins": [
                    {
                        "coin_code": "BTC",
                        "decimal": 8,
                        "coin_balance": 2028291,
                        "coin_withdrawable": 210000,
                        "BTC": 2028291
                    },
                    {
                        "coin_code": "TRON",
                        "decimal": 6,
                        "coin_balance": 138900000,
                        "coin_withdrawable": 138899000,
                        "BTC": 41407
                    }
                ],
                "exchange_account_is_mortgage": false,
                "exchange_account_token": "binance_team_vgi8s1",
                "exchange_account_status": "enabled",
                "exchange_account_name": "t_team_test_001@cobo.com",
                "exchange": "binance"
            }

属性 类型 含义解释
portfolio_id String 投资组合唯一id
portfolio_name String 投资组合名称
exchange_accounts String portfolio下所有交易账户资产详情
exchange_account_is_mortgage String False: 资方和交易员都允许提现返款至资方来源钱包;True: (仅用于质押型资产),仅允许交易员返款,资方不能主动发起提现
exchange_account_token String 交易账户token
exchange_account_status String 交易账户状态
exchange_account_name String 交易账户名称
exchange String 交易所

错误代码

当Cobo发生错误的时候,会返回给客户端统一格式的数据

{
    "success": false,
    "error_code": 1000,
    "error_description": "Unknown internal error"
}
Cobo错误代码 含义解释
1000 Unknown internal error -- 内部错误 (请联系Cobo)
1003 API params is missing or null -- Api参数错误或缺失
12000 Signature headers miss -- Api签名Header缺失
12001 Signature verify fail -- Api签名验证失败
12002 Coin not supported -- 币种不支持
12003 Permission deny -- 没有权限
12004 Transaction not exist -- 交易不存在
12005 Signature permission deny -- Api key没有权限
12006 Permission deny -- 没有权限
12007 Insufficient balance — 余额不足
12008 Coin is suspended temporarily — 币种暂时不可用
12009 Duplicate withdraw request id — 重复的提现ID
12010 Account has been frozen — 账户已被冻结
12011 Amount below coin dust — 金额过小
12012 Invalid address — 地址不合法
12013 Address not in whitelist — 地址不在白名单内
12014 Transaction fee invalid — 手续费设置错误
12015 Address does not exist — 地址不存在
12200 staking product not exist — Staking产品不存在
12201 invalid staking amount — Staking 非法金额
12202 invalid staking status — Staking 状态无法执行对应操作
<!-- 12250
HTTP错误代码 含义解释
400 Bad Request -- 错误的请求
401 Unauthorized -- API key 或者签名,时间戳有误
403 Forbidden -- 禁止访问
404 Not Found -- 未找到请求的资源
405 Method Not Allowed -- 使用的 HTTP 方法不适用于请求的资源
406 Not Acceptable -- 请求的内容格式不是 JSON
429 Too Many Requests -- 请求受限,请降低请求频率
500 Internal Server Error -- 服务内部错误,请稍后再进行尝试
503 Service Unavailable -- 服务不可用,请稍后再进行尝试

交易通知解决方案

当Cobo收到充值(提现)成功(达到确认数阈值)的交易时,会向您指定的 url 发送 Http(s) 消息, 发送数据内容和 Transaction 格式一致,格式为 Json (注:右边示例仅供参考,请以具体返回内容为准,不同交易类型返回内容可能不同)。当您收到消息且处理完成后,需要给 Cobo 返回 http code 为 200 的 response, body 为 ok (注: 返回的 body 仅需要 ok 字符串,不要json) ,否则Cobo会继续推送同样的消息。

如果您需要获取交易成功前的中间状态(确认数变化),您可以在 API 回调中开启 “交易通知-包含区块确认数状态)”, Cobo 会在确认数递增时逐个通知一个 status 为 pending 的通知, 还会包含返回币种的确认数阈值 "confirming_threshold" (本通知每次确认数变化只推送一次).

PendingPush

Cobo 验签公钥可以在 “Web 管理界面 - 钱包 - API 回调” 页面获取 (* Sandbox 和 Prod 环境不同)

完整示例

{
    "id": "20201207150724000192033000003701",
    "coin": "TRON",
    "display_code": "TRX",
    "description": "TRON",
    "decimal": 6,
    "address": "TZAt997umXasPUfxUZYKQKcGwjmYpJzX6V",
    "source_address": "TWDchZBmYvTQBeXD4w8rRUowDv5ka8kiFU",
    "side": "deposit",
    "amount": "1",
    "abs_amount": "0.000001",
    "txid": "6c2df6f6cf7fe8fe1e8559c11679a5a5b90768d1c128ffb3dd66d6f3cb910775",
    "vout_n": 0,
    "request_id": null,
    "status": "success",
    "abs_cobo_fee": "0",
    "created_time": 1607324928585,
    "last_time": 1607324928585,
    "confirmed_num": 27,
    "tx_detail": {
        "txid": "6c2df6f6cf7fe8fe1e8559c11679a5a5b90768d1c128ffb3dd66d6f3cb910775",
        "blocknum": 25660684,
        "blockhash": "0000000001878d0c83fb9640712d3354a0a1912dfd5884959d3c1a16b6f62e1c",
        "hexstr": ""
    },
    "source_address_detail": "TWDchZBmYvTQBeXD4w8rRUowDv5ka8kiFU",
    "confirming_threshold": 27,
    "type": "external"
}

Cobo 收到地址 TZAt997umXasPUfxUZYKQKcGwjmYpJzX6V 入账 0.000001 个 trx, 交易 Hash 为 6c2df6f6cf7fe8fe1e8559c11679a5a5b90768d1c128ffb3dd66d6f3cb910775 , 如果这个地址属于某个合作商户, 则Cobo会给该商户指定的Url发送 Http(s) Post请求,Body 为 ->

注意

  1. 当商户收到 Cobo 的通知之后, 需要根据里面具体的 Id 字段调用 Cobo 交易查询接口, 才能够确认交易的正确性,不能仅依靠通知接口入账出账!!!

  2. 对于交易成功的消息,Cobo 推送采用至少成功一次的策略(确认数变化通知除外), 如果商户不给Cobo返回 ok 或者 Http 请求超时, Cobo 都会认为推送失败,一段时间内继续推送(推送间隔时间逐次递增,推送总数超过 14 次以后,标记为推送失败不再推送,如果您需要再次推送,请在 Web - 钱包 - API 回调历史中 找到该条记录,点击 “重新推送“)。

  3. 对于交易确认中的消息,Cobo 只会在区块确认数变化时推送一次,不会依赖商户返回结果重复推送。

  4. 对于已达到确认数阈值状态为 ”成功“ 的交易,Cobo 不会再继续推送此交易的链上确认数变化。

  5. 由于网络延迟等不可预测原因,回调可能重复多次,注意需要根据 id 字段作为交易的唯一 key ,并合理使用数据库的读写锁机制,防止重复入账;

  6. 应尽量使用 https 协议,防止中间人劫持。并且对于 Cobo 的回调消息内容,使用 Cobo pubkey 进行验签。(SDK内已有验签逻辑,推荐直接使用SDK)

提现确认解决方案

当Cobo收到提现请求时, 会向合作机构制定的 url 发送 http(s) 信息, 发送数据内容和WithdrawRequest 内容一致, 格式为Json。当机构收到消息后, 需要给Cobo 返回 http code 为 200 的 response, body 为 ok(允许交易) 或 deny(拒绝交易),Cobo会根据反馈,对提现请求进行后续步骤或拦截。如果没有收到您的明确返回,Cobo会在一段时间内继续推送(推送间隔时间逐次递增,推送总数超过 14 次以后,标记为推送失败不再推送,此提现请求将处于 ‘等待二次确认回调’ 状态,如果您需要再次推送,请联系 Cobo 处理)。提现确认样例 ->

注意

  1. 添加的回调 URL 应该是一台与存储 API Key 私钥隔离的服务器(防止其中一台服务器被攻破的单点风险),比如隔离的风控引擎服务等;

  2. 所有的提现请求,建议检查 request_id、to_addr、amount是否合法,是否与自己的业务请求一致; 是否通过了您的内部业务风控&审核逻辑。

  3. 应尽量使用 https 协议,防止中间人劫持。并且对于 Cobo 的回调消息内容,使用 Cobo pubkey 进行验签。(SDK内已有验签逻辑,推荐使用SDK)

{
        "id": "",
        "coin": "BTC_USDT",
        "display_code": "USDT",
        "description": "Tether",
        "decimal": 8,
        "address": "18bpqEgCJ17TwxDwT26YjQnSBFVgcLBimE",
        "memo": "",
        "source_address": "",
        "source_address_detail": "",
        "side": "withdraw",
        "amount": "100000000",
        "abs_amount": "1",
        "txid": "",
        "vout_n": 0,
        "request_id": "test_request_id",
        "status": "pending",
        "created_time": 1542165707058,
        "last_time": 1542165707058,
        "confirming_threshold": 3,
        "confirmed_num": 0,
        "type": "external"
}

Cobo返回校验方案

当客户收到Cobo的返回数据后, 为防止攻击导致的数据篡改,Cobo 的每个 response (HTTP返回 & 回调消息)都会有椭圆曲线签名,对应的校验参数在 Http Header中: BIZ_TIMESTAMP, BIZ_RESP_SIGNATURE, 客户可以根据这两个参数校验返回值,具体校验方式可以在相应 Client demo 中可以看到: https://github.com/cobowallet/custody-clients/

Cobo 验签公钥可以在 “Web 管理界面 - 钱包 - API 回调” 页面获取 (* Sandbox 和 Prod 环境不同)

附录

coin 是 Cobo 内部币种代号,可以唯一标识一个数字货币,是您与 Cobo 对接交互的标识,一般不会变化。 display_code 表示数字货币的名称缩写(非唯一,可能变化,仅供参考), description表示数字货币的全称(非唯一,可能变化,仅供参考)。 例如: Tron在上主网之前发行的是以太坊上的Token,上主网之后变成在主网上的代币,此时,这两种代币的 display_code 和 description 都一样,但 coin 不一样。 Coin 作为您与 Cobo 交互的指定值,但是您可以采用其他字段或 mapping 您自己的字段在您的前端展示给用户。

在数字货币世界里面,每种币都有一个最小单位,例如比特币是聪,1BTC = 100000000聪。在Cobo里面,所有的币种的数量都是以币种的最小单位为基准表示的,这是为了避免所有可能由于浮点数的误用导致的问题,所以当转账1BTC时,交易记录里面的Amount为100000000,同时为了客户理解的方便, 也提供了 abs_amount, 表示真实的数值。客户接入时,可以按自己的偏好选择。

两者之间的换算方式是: abs_amount = amount / pow(10, decimal)

由于区块链本身及Cobo Custody自身业务的飞速发展, Cobo Custody很难保证现有返回字段能够完全满足客户的需求,因此Cobo会在保证向前兼容(老的字段不能删除且意义不会改变)的前提下, 在返回值中新增字段, 接入方需要对这种变化保持兼容