Example #1
0
        error_body = result_obj['error']
        print(error_body)

    r.raise_for_status()

    result_obj = r.json()
    print(result_obj)
    userInfo = result_obj["data"]
    user_uuid = userInfo["user_id"]
    return user_uuid


mixin_api_robot = MIXIN_API()
mixin_api_robot.appid = mixin_config.mixin_client_id
mixin_api_robot.secret = mixin_config.mixin_client_secret
mixin_api_robot.sessionid = mixin_config.mixin_pay_sessionid
mixin_api_robot.private_key = mixin_config.private_key
mixin_api_robot.asset_pin = mixin_config.mixin_pay_pin
mixin_api_robot.pin_token = mixin_config.mixin_pin_token
#http://travistidwell.com/jsencrypt/demo/
private_key = """-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDnfy/s9NjXQK3knnsr9+vuB1XQQUeKoWCFcEBO7iD4KRbJ2mwC
Bx92iOEVpaVMxS2bykbczXGnnG6NnQBwPx4cx3Z+N/ibG+YkDakAg1F00D9JvPcb
oRFy/GRAvtm+dj3GBa74c1S1J4XbXq5H1nqlraZh/hrhCs3pV+H2ooCUpQIDAQAB
AoGAB2zG5ry7r7u9WBXVMYXUJWBK2lEdsE6Yv+7nwSBWIl9/AZ5l1HLSCYU+Yulb
MekpG1QTjcVxHcUgrp4Yg4EiwA3tNuSTnjomph696HaA04aX7JRWpJX7lPNIbBGL
2QUkOo5uoyrvqAgLJq4dvcpWBzOwI/yJACS4kqMukjY3jUECQQD8qLb+g8Ar/Ezp
70/dYkcdEDbT8p6XlEAI8R3X+L5itcgDl6RMinPXIzXcRIGTZzoTeFXZzvr3XC+6
7nf/P3y9AkEA6o7V3VJps6ShoG8CMlJPoL0uKK+cYeMk9jSdqzZtUnc435nvXMOP
ifgdcFZMtReeDrClBrQRORyNEXpEU6IaCQJADDmRmSEA1GABzLPilmCh9jsJnBm6
KLVon8Yi3odPlvEau2nD7lwonLk8aur5pgsxmS2SYdaM+BkCyjWtorEMtQJBAJwS
import uuid
import websocket
import time
import _thread
from io import BytesIO
import gzip

import base64

from flask import session
import random

m_robot = MIXIN_API()
m_robot.appid = m_config.mixin_client_id
m_robot.secret = m_config.mixin_client_secret
m_robot.sessionid = m_config.mixin_pay_sessionid
m_robot.private_key = m_config.private_key
m_robot.asset_pin = m_config.mixin_pay_pin
m_robot.pin_token = m_config.mixin_pin_token

#==transferTo,转账函数==
def transferTo(robot, config, to_user_id, to_asset_id,to_asset_amount,memo):

    encrypted_pin = robot.genEncrypedPin()
    encrypted_pin = encrypted_pin.decode()
    body = {'asset_id': to_asset_id, 'counter_user_id':to_user_id, 'amount':str(to_asset_amount), 'pin':encrypted_pin, 'trace_id':str(uuid.uuid1())}
    body_in_json = json.dumps(body)

    encoded = robot.genPOSTJwtToken('/transfers', body_in_json, config.mixin_client_id)
    r = requests.post('https://api.mixin.one/transfers', json = body, headers = {"Authorization":"Bearer " + str(encoded)[2:-1]})