介绍说明
USDT测试网使用的测试币 token_id 为1
获取当前账户的费用地址
获取当前账户的费用地址,如果不存在,则创建新的BTC地址。费用地址作用:
用来支付多签钱包转账的矿工费
当转出钱包内全部的USDT的时候, 钱包内剩余的 BTC 余额将全部转入到 费用地址中
建议费用地址充值 100000 聪
import requests
requests.get(
url="https://testnet.sectoken.io/wallet/usdt/fee/",
headers={"HMAC": "your token"}
)
curl "https://testnet.sectoken.io/wallet/usdt/fee/" \
-X GET \
-H "HMAC:your token" \
返回示例
{
"code": 200,
"data": {
"address": "2N91dXMR7p8ne2Asuy8vgkwZ4DtwVszeCDw",
"confirmed": "10000000"
"unconfirmed":"10000"
}
}
HTTP Request
GET https://testnet.sectoken.io/wallet/usdt/fee/
无请求参数
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
data | object | 返回内容 |
data 参数
参数名 | 参数类型 | 说明 |
---|---|---|
address | string | 费用地址 |
confirmed | string | 已确认可以使用的BTC余额 (最小单位) |
unconfirmed | string | 未确认不可用的BTC余额 (最小单位) |
创建usdt多签钱包
为当前用户创建一个 USDT 多签钱包
import requests
requests.post(
url="https://testnet.sectoken.io/wallet/usdt/create/",
headers={"HMAC": "your token"},
json={
"pubkeys": [
"03a6725ab3589cb91b416706fb23fe3f0b179d9d46af95d36606dc03cc24b99ec2",
"0392bdf172b6aeba9d68c93d1adc22c10ea865caacf0f601a31e938e053b537845"
],
"privkeys":[
"Y1QxVGFIaFZEMXVOR21xVG1OakNUZ3J6WUo1OHZSVUNGNldxc0FZclZTckxFNEF3cXZBeQ==",
"Y05LaHlwbnBKWDZkWEt5QmJuN2k0WVo0YnhUN2hlUUxOSDdhRjVhN0JLblFIeDJSV3VqSg==",
],
"wallet_name": "your wallet name",
}
)
curl "https://testnet.sectoken.io/wallet/usdt/create/" \
-H "HMAC:your token" \
-H "Content-Type:application/json" \
-X POST \
-d '{"pubkeys": ["03a6725ab3589cb91b416706fb23fe3f0b179d9d46af95d36606dc03cc24b99ec2", "0392bdf172b6aeba9d68c93d1adc22c10ea865caacf0f601a31e938e053b537845"], "privkeys": ["Y1QxVGFIaFZEMXVOR21xVG1OakNUZ3J6WUo1OHZSVUNGNldxc0FZclZTckxFNEF3cXZBeQ==", "Y05LaHlwbnBKWDZkWEt5QmJuN2k0WVo0YnhUN2hlUUxOSDdhRjVhN0JLblFIeDJSV3VqSg=="], "wallet_name": "your wallet name"}'
返回示例
{
"code": 200,
"data": {
"wallet_id": "926e4ac3939e351927cf11ef69005ddc",
"activate_code": "352147",
"server_pubkey": "xpub6AZMDpGgTSsnVxLt9YHE1uT8AF7KHUqQzAM7Fpe4qXpfGZFEcYpe9WRVKzpHFEi7n16h463FLAtQZ9LFeKXLNTwHCuRevoo58LBKFAjUZxK"
}
}
HTTP Request
POST https://testnet.sectoken.io/wallet/usdt/create/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
pubkeys | array | 是 | 公钥列表 |
privkeys | array | 否 | 私钥列表 |
wallet_name | string | 是 | 钱包名 |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
data | object | 返回内容 |
data 参数
参数名 | 参数类型 | 说明 |
---|---|---|
wallet_id | string | 钱包的id |
activate_code | string | 钱包激活码 |
server_pubkey | string | 钱包的xpub |
激活钱包
import requests
requests.post(
url="https://testnet.sectoken.io/wallet/usdt/activate/",
headers={"HMAC": "your token"},
json={
"wallet_id": "your wallet id",
"activate_code": "your activate code",
}
)
curl "https://testnet.sectoken.io/wallet/usdt/activate/" \
-H "HMAC:your token" \
-H "Content-Type:application/json" \
-X POST \
-d '{"wallet_id": "your wallet id", "activate_code": "your activate code"}'
返回示例
{
"code": 200,
"data": {
"address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN"
}
}
HTTP Request
POST https://testnet.sectoken.io/wallet/usdt/activate/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
wallet_id | string | 是 | 钱包id |
activate_code | string | 是 | 钱包激活码 |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
data | object | 返回内容 |
data 参数
参数名 | 参数类型 | 说明 |
---|---|---|
address | string | 钱包的地址 |
查看钱包信息
import requests
requests.get(
url="https://testnet.sectoken.io/wallet/usdt/detail/",
headers={"HMAC": "your token"},
params={"wallet_id": "your wallet id"}
)
curl "https://testnet.sectoken.io/wallet/usdt/detail/?wallet_id=your_wallet_id" \
-H "HMAC:your token" \
-X GET
{
"code": 200,
"data": {
"wallet_id": "926e4ac3939e351927cf11ef69005ddc",
"wallet_name": "UsdtTest",
"address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
"balance": "97000",
"send_max": "0",
"send_day_max": "0",
"send_day_limit": 0,
"freeze_overtime": 0
}
}
HTTP Request
GET https://testnet.sectoken.io/wallet/usdt/detail/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
wallet_id | string | 是 | 钱包id |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
data | object | 返回内容 |
data 参数
参数名 | 参数类型 | 说明 |
---|---|---|
wallet_id | string | 钱包id |
wallet_name | string | 钱包名 |
address | string | 钱包地址 |
balance | string | 钱包余额,单位为最小单位 |
send_max | string | 单次转账上限,"0"为无上限 |
send_day_limit | integer | 单日转账次数上限,0为无上限 |
send_day_max | string | 单日转账上限,"0"为无上限 |
freeze_overtime | integer | 钱包冻结截止时间,0为未冻结 |
查看钱包列表
import requests
requests.get(
url="https://testnet.sectoken.io/wallet/usdt/wallet_list/?page=1,
headers={"HMAC": "your token"}
)
curl "https://testnet.sectoken.io/wallet/usdt/wallet_list/?page=1" \
-X GET \
-H "HMAC:your token"
返回示例
{
"code": 200,
"data": [
{
"wallet_name": "TestSeven",
"wallet_id": "2cc5abb2b9932ca1ec5513ad1a9685f9",
"address":"0x32FfC556A1E1deEfE1084A0E276501d0B347bb39",
"create_time": "2019-10-09T02:27:18.465"
}
]
}
HTTP Request
GET https://testnet.sectoken.io/wallet/usdt/wallet_list/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
page | integer | 否 | 页码,默认显示所有钱包列表 |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
data | array | 返回内容 |
data 参数
参数名 | 参数类型 | 说明 |
---|---|---|
wallet_id | string | 钱包的id |
wallet_name | string | 钱包名 |
address | string | 钱包地址 |
create_time | string | 钱包创建时间 |
构建交易单
当转出钱包内全部的USDT的时候, 钱包内剩余的 BTC 余额将全部转入到 费用地址中
import requests
requests.post(
url="https://testnet.sectoken.io/wallet/usdt/dotx/",
headers={"HMAC": "your token"},
json={
"wallet_id": "your wallet id",
"to_address": "destination address",
"value": "1000000000",
"feerate": 1,
"memo":"abcdefg"
}
)
curl "https://testnet.sectoken.io/wallet/usdt/dotx/" \
-X POST \
-H "Content-Type:application/json" \
-H "HMAC:your token" \
-d '{"wallet_id": "your wallet id", "to_address": "destination address", "value": "1000000000", "feerate": 1, "memo":"abcdefg"}'
返回示例
{
"code": 200,
"data": {
"unsigned_tx": {
"inputs": [
{
"txid": "4d626a3304ff16bd9e8b563fe96817b14f43dc0bbd08d52d1dd48abd7d75b239",
"index": 2,
"value": "540"
},
{
"txid": "565fa9d010a86a363bb14cd677958093056b0f2ff2703a7adf54e72e75c8cdbc",
"index": 1,
"value": "1000"
}
],
"scripts": [
"522103a6725ab3589cb91b416706fb23fe3f0b179d9d46af95d36606dc03cc24b99ec2210392bdf172b6aeba9d68c93d1adc22c10ea865caacf0f601a31e938e053b5378452103a5d8b0d33032480c167478da2d2935d630e45626a5341ce99f1635485591d15e53ae",
"522103a6725ab3589cb91b416706fb23fe3f0b179d9d46af95d36606dc03cc24b99ec2210392bdf172b6aeba9d68c93d1adc22c10ea865caacf0f601a31e938e053b5378452103a5d8b0d33032480c167478da2d2935d630e45626a5341ce99f1635485591d15e53ae"
],
"outputs": [
{
"address": "2NBZYNybgWhdbwXLhEpraaUdBJ6qs8Pcwnz",
"value": "614"
},
{
"address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
"value": "540"
},
{
"address": "6f6d6e6900000000000000010000000000000a8c",
"value": "0"
}
]
},
"fee": 349,
"privkey": "Y1QxVGFIaFZEMXVOR21xVG1OakNUZ3J6WUo1OHZSVUNGNldxc0FZclZTckxFNEF3cXZBeQ=="
}
}
HTTP Request
POST https://testnet.sectoken.io/wallet/usdt/dotx/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
wallet_id | string | 是 | 钱包id |
to_address | string | 是 | 收款地址 |
value | string | 是 | 转账金额,最小单位 |
memo | string | 否 | 备注信息 |
feerate | integer | 否 | 转账速度,1快速0普通,默认为0 |
total | boolean | 否 | 全部转出, 默认为 False |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
data | object | 返回内容 |
data 参数
参数名 | 参数类型 | 说明 |
---|---|---|
unsigned_tx | object | 待签名的信息 |
privkey | string | 创建钱包时上传的私钥密文,如果创建钱包时没有上传,则为空 |
提交签名信息
用户在本地对交易单进行签名,并将签名后的数据提交Sectoken,Sectoken对签名进行验证后,将交易广播到区块链上
import requests
requests.post(
url="https://testnet.sectoken.io/wallet/usdt/send/"
headers={"HMAC": "your token"},
json={
"wallet_id": "your wallet id",
"signed_tx": "0b1e9cf915d8d04592c81e4accf06194ca3069c38c53ecf2fabe149e3612284532369a161599127a44e85b5a7039c9426ddd516273b07ddb82a11e10800ae01a00"
}
)
curl "https://testnet.sectoken.io/wallet/usdt/send/" \
-X POST \
-H "Content-Type:application/json" \
-H "HMAC:your token" \
-d '{"wallet_id": "your wallet id", "signed_tx": "0b1e9cf915d8d04592c81e4accf06194ca3069c38c53ecf2fabe149e3612284532369a161599127a44e85b5a7039c9426ddd516273b07ddb82a11e10800ae01a00"}'
返回示例
{
"code": 200,
"data": {
"txid": "1c93e587fb3193969fb1f775835f07fb4517ffd24afd36df4b118ab52c9ba63f",
"is_sent": true
}
}
HTTP Request
POST https://testnet.sectoken.io/wallet/usdt/send/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
wallet_id | string | 是 | 钱包id |
signed_tx | string | 是 | 签名结果 |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
data | object | 返回内容 |
data 参数
参数名 | 参数类型 | 说明 |
---|---|---|
is_sent | bool | 是否广播。如果签名数量未达到广播限制,说明未最终签名成功,返回false,否则返回true。 |
txid | string | 交易单的txid,可以在区块浏览器上进行查找 |
新增钱包WebHook
添加 一个 webhook, 当触发指定类型的事件的时候,Sectoken 将会向指定的URL发送一条请求信息,每个钱包最多绑定10条webhook
import requests
requests.post(
url="https://testnet.sectoken.io/wallet/usdt/webhook_add/",
headers={"HMAC": "your token"},
json={
"wallet_id": "your wallet id",
"url": "https://your.server.com/webhook",
"label": "test callback",
"type": "deposit",
}
)
curl "https://testnet.sectoken.io/wallet/usdt/webhook_add/" \
-H "HMAC:your token" \
-H "Content-Type:application/json" \
-X POST \
-d '{"wallet_id": "your wallet id", "url":"https://your.server.com/webhook", "label":"test callback", "type":"deposit"}'
返回示例
{
"code": 200,
"data": {
"callbackid": "da0e3f3530cb7f63695d8eaad351fdc1"
}
}
HTTP Request
POST https://testnet.sectoken.io/wallet/usdt/webhook_add/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
wallet_id | string | 是 | 钱包id |
url | string | 是 | 用户自定义URL,必须使用HTTP或者HTTPS协议 |
type | string | Yes | deposit 或者 withdraw |
label | string | Optional | webhook标签 |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看 错误码 |
data | object | 返回内容 |
Data 参数
参数名 | 参数类型 | 说明 |
---|---|---|
callbackid | string | callback id |
获取钱包WebHook
获取钱包的Webhook设置列表
import requests
requests.get(
url="https://testnet.sectoken.io/wallet/usdt/webhook_list/",
headers={"HMAC": "your token"},
params={"wallet_id": "your wallet id"}
)
curl "https://testnet.sectoken.io/wallet/usdt/webhook_list/?wallet_id=your_wallet_id" \
-H "HMAC:your token" \
-X GET
返回示例
{
"code": 200,
"data": [
{
"label": "test callback",
"url": "https://your.server.com/webhook",
"type": "deposit",
"token": "usdt",
"callbackid": "da0e3f3530cb7f63695d8eaad351fdc1",
"wallet_id": "your wallet id"
"create_time": "2019-10-31T19:54:22.977"
}
]
}
HTTP Request
GET https://testnet.sectoken.io/wallet/usdt/webhook_list/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
wallet_id | string | 是 | 钱包ID |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
data | array | 返回内容 |
Data参数
参数名 | 参数类型 | 说明 |
---|---|---|
label | string | webhook 标签 |
url | string | webhook 目标地址 |
type | string | 交易单状态,收款或付款 |
token | string | 币种信息 |
callbackid | string | callback id |
wallet_id | string | 钱包ID |
create_time | string | 创建时间 |
删除钱包WebHook
删除钱包的Webhook
import requests
requests.post(
url="https://testnet.sectoken.io/wallet/usdt/webhook_del/",
headers={"HMAC": "your token"},
json={
"callbackid": "your callback id",
}
)
curl "https://testnet.sectoken.io/wallet/usdt/webhook_del/" \
-H "HMAC:your token" \
-H "Content-Type:application/json" \
-X POST \
-d '{"callbackid": "your callback id"}'
返回示例
{
"code": 200,
}
HTTP Request
POST https://testnet.sectoken.io/wallet/usdt/webhook_del/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
callbackid | string | 是 | callback id |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
交易Callback通知
当用户钱包发生交易时,会向指定的url发送HTTP POST请求,请求头content-type为application/json。
此url由用户指定,用户须部署服务接收HTTP POST请求。同时需先添加钱包Webhook
请求body示例
Deposit Example:
{
"wallet_id": "6004e156344ec27cad24a8df5bbaa5ab",
"txid": "d1372a31c23a064953aa61144d1f37297cda7e0222c73fe428499fa36dcd8e3b",
"height": 4340000,
"dst_address": "2NCZhNEVm2QJJmBwvL2JC7mpNavR8sJNNLm",
"src_address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
"type": "deposit",
"timestamp": 1872340000,
"value": "10000",
"coin_type": "USDT",
"decimal": 8
}
Withdraw Example:
{
"wallet_id": "6004e156344ec27cad24a8df5bbaa5ab",
"txid": "d1372a31c23a064953aa61144d1f37297cda7e0222c73fe428499fa36dcd8e3b",
"height": 4340000,
"dst_address": "2NCZhNEVm2QJJmBwvL2JC7mpNavR8sJNNLm",
"src_address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
"type": "withdraw",
"timestamp": 1872340000,
"value": "10000",
"coin_type": "USDT",
"decimal": 8
}
参数说明
参数名 | 参数类型 | 说明 |
---|---|---|
wallet_id | string | 用户钱包id |
txid | string | 交易id |
height | integer | 交易所在区块高度 |
dst_address | string | 交易目的地址 |
src_address | string | 交易来源地址 |
type | string | 交易状态,withdraw 转出 deposit收款 |
timestamp | integer | 交易时间戳 |
value | string | 交易金额 |
coin_type | string | 币种类型 |
decimal | integer | 精度 |
callbackid | string | Callback id |
获取交易记录
import requests
requests.get(url="https://testnet.sectoken.io/flow/record/usdt/",
headers={"HMAC": "your token"},
params={
"wallet_id": "b81d38f5f250c36a05da0d0e1f9bd394",
"year": "2019",
"month": "10"
}
)
curl "https://testnet.sectoken.io/flow/record/usdt/?wallet_id=b81d38f5f250c36a05da0d0e1f9bd394&year=2019&month=10" \
-H "HMAC:your token"
{
"code": 200,
"data": [
{
"txid": "791cf3d20239523a21db332863b61c7728fadc3045f96cade72d4e509d1839f8",
"src_address": "2N5JY64urDm63s8kBijvp4B8P7KZMxn33e9",
"dst_address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
"value": "2700",
"timestamp": 1574244951,
"type": "withdraw",
"height": 1609149,
"memo": "",
"coin_type": "USDT",
"decimal": 8
},
{
"txid": "a62c383a41fd85fd5730a2c1e12e77389e40c63e1248415c5575e7b51eb7de3e",
"src_address": "2N5JY64urDm63s8kBijvp4B8P7KZMxn33e9",
"dst_address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
"value": "300",
"timestamp": 1574243041,
"type": "withdraw",
"height": 1609147,
"memo": "",
"coin_type": "USDT",
"decimal": 8
}
]
}
HTTP Request
GET https://testnet.sectoken.io/flow/record/usdt/
请求参数
参数名 | 参数类型 | 必填 | 说明 |
---|---|---|---|
wallet_id | string | 是 | 钱包id |
year | string | 是 | 年份 |
month | string | 是 | 月份 |
day | string | 否 | 日期 |
返回参数
参数名 | 参数类型 | 说明 |
---|---|---|
code | integer | 返回码,200成功,其他失败,请查看错误码 |
data | array | 返回内容 |
data 参数
参数名 | 参数类型 | 说明 |
---|---|---|
txid | string | 交易单id |
src_address | string | 交易来源地址 |
dst_address | string | 交易目的地址 |
value | string | 交易金额 |
timestamp | integer | 交易时间 |
type | string | 交易状态,withdraw 转出 deposit收款 |
height | integer | 交易区块高度 |
memo | string | 备注信息,区块连上可查的 |
decimal | integer | 精度 |
coin_type | string | 币种信息 |
错误码
当发生错误时返回的错误码
错误码 | 错误说明 |
---|---|
4000 | 请求参数错误 |
5000 | 未知错误, 请联系Sectoken |
4201 | 钱包不存在 |
4202 | 钱包冻结中 |
4204 | 钱包余额不足 |
4209 | 钱包激活码错误 |
4210 | 钱包Webhook数目超限 |
4401 | 用户验证失败 |
4402 | 此钱包不属于当前账户 |
4403 | 钱包个数达到上限 |
4404 | 用户权限不足 |
4503 | 不能转账给钱包自己 |
4504 | 签名错误 |
4506 | 无效公钥 |
4507 | 私钥密文必须base64 |
4508 | Webhook不存在 |
4512 | 无法广播已经广播过的交易单 |
4513 | Unspent已使用 |
4601 | 当前用户没有费用地址 |
4602 | 费用地址余额不足 |
4603 | 无可用unspent |