Пример #1
0
def create_sub_aggregate(data):
    """创建子账户-聚合
    该接口创建一个子账户和观察者,并设置自动提现地址"""
    api_key = data["api_key"]
    secret_key = data["secret_key"]
    account = data["account"]
    observer_name = data["obsname"]
    withdraw_address = data["withdraw_address"]
    tonce = get_time_stamp()
    if data.get("tonce"):
        tonce = data.get("tonce")
    url = base_url + "openapi/v1/account/sub/aggregate"
    body = {
        "tonce": tonce,
        "account": account,
        "observer_name": observer_name,
        "withdraw_address": withdraw_address
    }
    sign = hash_encrypt(secret_key, json.dumps(body))
    header = {
        "X-API-KEY": api_key,
        "X-SIGNATURE": sign,
        "Content-Type": "application/json"
    }
    res = send_post(url, body, header)
    return res
Пример #2
0
def set_wallet_payment_address(data):
    """设置自动提现地址"""
    api_key = data["api_key"]
    secret_key = data["secret_key"]
    coin = data["coin"]
    address = data["address"]
    payment_password = data["payment_password"]
    url = base_url + "openapi/v1/wallet/payment/address"
    tonce = get_time_stamp()
    if data.get("tonce"):
        tonce = data.get("tonce")
    body = {
        "tonce": tonce,
        "coin": coin,
        "address": address,
        "payment_password": payment_password
    }
    sign = hash_encrypt(secret_key, json.dumps(body))
    header = {
        "X-API-KEY": api_key,
        "X-SIGNATURE": sign,
        "Content-Type": "application/json"
    }
    res = send_post(url, body, header)
    return res
Пример #3
0
def create_observer(data):
    """创建观察者"""
    api_key = data["api_key"]
    secret_key = data["secret_key"]
    obsname = data["obsname"]
    tonce = get_time_stamp()
    if data.get("tonce"):
        tonce = data.get("tonce")
    url = base_url + "openapi/v1/account/observer"
    body = {"tonce": tonce, "name": obsname}
    sign = hash_encrypt(secret_key, json.dumps(body))
    header = {
        "X-API-KEY": api_key,
        "X-SIGNATURE": sign,
        "Content-Type": "application/json"
    }
    res = send_post(url, body, header)
    return res
Пример #4
0
def create_account_sub(data):
    """创建子账户"""
    api_key = data["api_key"]
    secret_key = data["secret_key"]
    account = data["account"]
    tonce = get_time_stamp()
    if data.get("tonce"):
        tonce = data.get("tonce")
    url = base_url + "openapi/v1/account/sub"
    body = {"tonce": tonce, "account": account}
    sign = hash_encrypt(secret_key, json.dumps(body))
    header = {
        "X-API-KEY": api_key,
        "X-SIGNATURE": sign,
        "Content-Type": "application/json"
    }
    res = send_post(url, body, header)
    return res
Пример #5
0
def get_account_sub(data):
    """获取子账户列表"""
    api_key = data["api_key"]
    secret_key = data["secret_key"]
    page = data["page"]
    limit = data["limit"]
    tonce = get_time_stamp()
    if data.get("tonce"):
        tonce = data.get("tonce")
    url = base_url + "openapi/v1/account/sub"
    param = {"tonce": tonce, "page": page, "limit": limit}
    # 加密参数
    query_string = parse.urlencode(param)
    sign = hash_encrypt(secret_key, query_string)
    header = {
        "X-API-KEY": api_key,
        "X-SIGNATURE": sign,
    }
    res = send_get(url, param, header)
    return res
Пример #6
0
def delete_account_group(data):
    """删除矿工分组"""
    api_key = data["api_key"]
    secret_key = data["secret_key"]
    group_id = data["group_id"]
    tonce = get_time_stamp()
    if data.get("tonce"):
        tonce = data.get("tonce")
    url = base_url + "openapi/v1/account/group/{0}".format(group_id)
    param = {"tonce": tonce}
    # 加密参数
    query_string = parse.urlencode(param)
    sign = hash_encrypt(secret_key, query_string)
    header = {
        "X-API-KEY": api_key,
        "X-SIGNATURE": sign,
        "Content-Type": "application/json"
    }
    res = send_delete(url, param, header)
    return res
Пример #7
0
def wallet_sweep(data):
    """结算钱包余额"""
    api_key = data["api_key"]
    secret_key = data["secret_key"]
    coin = data["coin"]
    tonce = get_time_stamp()
    if data.get("tonce"):
        tonce = data.get("tonce")

    url = base_url + "openapi/v1/wallet/sweep"
    body = {
        "tonce": tonce,
        "coin": coin,
    }
    sign = hash_encrypt(secret_key, json.dumps(body))
    header = {
        "X-API-KEY": api_key,
        "X-SIGNATURE": sign,
        "Content-Type": "application/json"
    }
    res = send_post(url, body, header)
    return res
Пример #8
0
def put_account_group(data):
    """移动矿工分组"""
    api_key = data["api_key"]
    secret_key = data["secret_key"]
    worker_ids = data["worker_ids"]
    group_id = data["group_id"]
    tonce = get_time_stamp()
    if data.get("tonce"):
        tonce = data.get("tonce")
    url = base_url + "openapi/v1/account/group"
    body = {
        "tonce": tonce,
        "worker_ids": worker_ids,
        "group_id": group_id,
    }
    sign = hash_encrypt(secret_key, json.dumps(body))
    header = {
        "X-API-KEY": api_key,
        "X-SIGNATURE": sign,
        "Content-Type": "application/json"
    }
    res = send_put(url, body, header)
    return res
Пример #9
0
def create_account_group(data):
    """新建矿工分组"""
    api_key = data["api_key"]
    secret_key = data["secret_key"]
    coin = data["coin"]
    group_name = data["group_name"]
    tonce = get_time_stamp()
    if data.get("tonce"):
        tonce = data.get("tonce")
    url = base_url + "openapi/v1/account/group"
    body = {
        "tonce": tonce,
        "coin": coin,
        "group_name": group_name,
    }
    sign = hash_encrypt(secret_key, json.dumps(body))
    header = {
        "X-API-KEY": api_key,
        "X-SIGNATURE": sign,
        "Content-Type": "application/json"
    }
    res = send_post(url, body, header)
    return res