diff --git a/README.md b/README.md index 08b434f..fecf273 100644 --- a/README.md +++ b/README.md @@ -13,46 +13,21 @@ community development resource: - mixin_dev_resource: https://github.com/myrual/mixin_dev_resource - MiXin_Player:https://github.com/albertschr/MiXin_Player +## deps -## install pip if it is missing in your OS -``` -$ curl “https://bootstrap.pypa.io/get-pip.py" -o “get-pip.py” -$ python get-pip.py -``` -### install python27 and pip on centos6.8 -https://gist.github.com/dalegaspi/dec44117fa5e7597a559 -``` -yum install gcc -yum install gcc-c++ -yum install python-devel -``` -## pre request -``` -pip2.7 install web.py -pip2.7 install PyJWT -pip2.7 install websocket-client -pip2.7 install requests -pip2.7 install pycrypto -pip2.7 install cryptography -pip2.7 install pycrypto ecdsa -``` +* python2.7 +* pip2.7 - -## run robot -``` -python home_cnb_robot.py +## pre-request ``` - -## run robot as long as possible -``` -nohup python home_cnb_robot.py & +pip2.7 install -r requirements.txt ``` -## kill program +## run robot ``` -ls -ef -kill prociess id +./run.sh ``` +## 参考 -[中文搭建教程](https://www.jianshu.com/p/727cca139a57) +* [中文搭建教程](https://www.jianshu.com/p/727cca139a57) diff --git a/home_cnb.py b/home_cnb.py index d3d5835..cff462d 100644 --- a/home_cnb.py +++ b/home_cnb.py @@ -1,76 +1,45 @@ -# -*- coding: utf-8 -*- +#!/usr/bin/env python +#coding: utf-8 + import web import json import requests -import jwt -import datetime -import calendar -import hashlib -import base64 -import Crypto -import time import uuid import mixin_config - - +import mixin_asset_list urls = ( '/', 'index', '/auth','auth', - '/CNB', 'balanceOfCNB', '/depositCNB','depositCNB', - '/billionCNB','depositBillionCNB', - '/millionCNB','depositMillionCNB' - ) class index: def GET(self): - web.seeother('https://mixin.one/oauth/authorize?client_id=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&scope=PROFILE:READ') -class balanceOfCNB: - def GET(self): - raise web.seeother('https://mixin.one/oauth/authorize?client_id=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&scope=PROFILE:READ') - def GETlistAsset(self): - raise web.seeother('https://mixin.one/oauth/authorize?client_id=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&scope=PROFILE:READ+ASSETS:READ') + web.seeother('https://mixin.one/oauth/authorize?client_id='+mixin_config.mixin_client_id+'&scope=PROFILE:READ+PHONE:READ+ASSETS:READ') class depositCNB: def GET(self): - raise web.seeother('https://mixin.one/pay?recipient=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&asset=965e5c6e-434c-3fa9-b780-c50f43cd955c&amount=5000&trace=' + str(uuid.uuid1()) + '&memo=TEXT') - -class depositBillionCNB: - def GET(self): - raise web.seeother('https://mixin.one/pay?recipient=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&asset=965e5c6e-434c-3fa9-b780-c50f43cd955c&amount=' + str(10 * 10000 * 10000)+ '&trace=' + str(uuid.uuid1()) + '&memo=DepositeCNBV') - - -class depositMillionCNB: - def GET(self): - raise web.seeother('https://mixin.one/pay?recipient=3c5fd587-5ac3-4fb6-b294-423ba3473f7d&asset=965e5c6e-434c-3fa9-b780-c50f43cd955c&amount=' + str(1000 * 1000)+ '&trace=' + str(uuid.uuid1()) + '&memo=DepositeCNBV') - - - + raise web.seeother('https://mixin.one/pay?recipient='+mixin_config.mixin_client_id+'&asset='+mixin_asset_list.CNB_ASSET_ID+'&amount=5000&trace=' + str(uuid.uuid1()) + '&memo=depositCNB') class auth: def GET(self): mixindata = web.input(code = "no") - print(mixindata) if mixindata.code == "no": - return "I don't know you, can not give your bonus" + return "invalid code" - r = requests.post('https://api.mixin.one/oauth/token', json = {"client_id": mixin_config.mixin_client_id, "code": mixindata.code,"client_secret": mixin_config.mixin_client_secret}) + r = requests.post('https://api.mixin.one/oauth/token', json = {"client_id": mixin_config.mixin_client_id, "code": mixindata.code, "client_secret": mixin_config.mixin_client_secret}) result = r.json() - print(result) + print(result) if "data" not in result or "access_token" not in result["data"]: return "I don't know you, can not give your bonus" + access_token = result["data"]["access_token"] personinfo = requests.get('https://api.mixin.one/me', headers = {"Authorization":"Bearer " + access_token}) - userid = personinfo.json()["data"]["user_id"] - print(personinfo.json()) - xin_asset_id = "c94ac88f-4671-3976-b60a-09064f1811e8" - print("check my mixin assets") - cnb_asset_id = '965e5c6e-434c-3fa9-b780-c50f43cd955c' - sendmessage_body = {} - + userid = personinfo.json()["data"]["user_id"] + print(personinfo.json()) return "You are " + userid + if __name__ == "__main__": app = web.application(urls, globals()) app.run() diff --git a/home_of_cnb_robot.py b/home_of_cnb_robot.py index 4d56a44..b34d0bf 100644 --- a/home_of_cnb_robot.py +++ b/home_of_cnb_robot.py @@ -1,4 +1,6 @@ -# -*- coding: utf-8 -*- +#!/usr/bin/env python +#coding: utf-8 + import websocket import requests import json @@ -21,22 +23,21 @@ except ImportError: import _thread as thread import time -btccash_asset_id = "fd11b6e3-0b87-41f1-a41f-f0e9b49e5bf0" from sqlalchemy import create_engine - from sqlalchemy import Column, Integer, String from sqlalchemy.orm import relationship from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base from database_type import * + engine = create_engine('sqlite:///sqlalchemy_home_of_cnb.db') # Create all tables in the engine. This is equivalent to "Create Table" # statements in raw SQL. Base.metadata.create_all(engine) Base.metadata.bind = engine - + DBSession = sessionmaker(bind=engine) # A DBSession() instance establishes all conversations with the database # and represents a "staging zone" for all the objects loaded into the @@ -47,10 +48,6 @@ # session.rollback() session = DBSession() - - -admin_conversation_id = "" - mixin_api_robot = MIXIN_API() mixin_api_robot.appid = mixin_config.mixin_client_id mixin_api_robot.secret = mixin_config.mixin_client_secret @@ -59,37 +56,8 @@ mixin_api_robot.asset_pin = mixin_config.mixin_pay_pin mixin_api_robot.pin_token = mixin_config.mixin_pin_token -myConfig = mixin_config.user_mixin_config() -myConfig.mixin_client_id = mixin_config.mixin_client_id -myConfig.mixin_pay_sessionid= mixin_config.mixin_pay_sessionid -myConfig.mixin_pin_token= mixin_config.mixin_pin_token -myConfig.mixin_pay_pin = mixin_config.mixin_pay_pin -myConfig.private_key = mixin_config.private_key -myConfig.deviceID = "" -myConfig.keyForAES = "" -myConfig.asset_pin = "841316" - - freeBonusTimeTable = {} -def transferTo(robot, config, to_user_id, to_asset_id,to_asset_amount,memo): - encrypted_pin = robot.genEncrypedPin_extConfig(config) - 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_extConfig('/transfers', body_in_json, config) - r = requests.post('https://api.mixin.one/transfers', json = body, headers = {"Authorization":"Bearer " + encoded}) - result_obj = r.json() - if 'error' in result_obj: - error_body = result_obj['error'] - error_code = error_body['code'] - if error_code == 20119: - print("to :" + to_user_id + " with asset:" + to_asset_id + " amount:" + to_asset_amount) - print(result_obj) - return False - else: - return True - def writeMessage(websocketInstance, action, params): Message = {"id":str(uuid.uuid1()), "action":action, "params":params} Message_instring = json.dumps(Message) @@ -99,7 +67,6 @@ def writeMessage(websocketInstance, action, params): gzip_obj.close() websocketInstance.send(fgz.getvalue(), opcode=websocket.ABNF.OPCODE_BINARY) - def sendUserAppButton(websocketInstance, in_conversation_id, to_user_id, realLink, text4Link, colorOfLink = "#d53120"): btn = '[{"label":"' + text4Link + '","action":"' + realLink + '","color":"' + colorOfLink + '"}]' params = {"conversation_id": in_conversation_id,"recipient_id":to_user_id,"message_id":str(uuid.uuid4()),"category":"APP_BUTTON_GROUP","data":base64.b64encode(btn)} @@ -113,44 +80,36 @@ def sendUserContactCard(websocketInstance, in_conversation_id, to_user_id, to_sh def sendUserText(websocketInstance, in_conversation_id, to_user_id, textContent): params = {"conversation_id": in_conversation_id,"recipient_id":to_user_id ,"message_id":str(uuid.uuid4()),"category":"PLAIN_TEXT","data":base64.b64encode(textContent)} return writeMessage(websocketInstance, "CREATE_MESSAGE",params) + def sendGroupText(websocketInstance, in_conversation_id, textContent): params = {"conversation_id": in_conversation_id,"message_id":str(uuid.uuid4()),"category":"PLAIN_TEXT","data":base64.b64encode(textContent)} return writeMessage(websocketInstance, "CREATE_MESSAGE",params) -def sendGroupPay(webSocketInstance, in_config, in_conversation_id, inAssetName, inAssetID, inPayAmount, linkColor = "#0CAAF5"): - payLink = "https://mixin.one/pay?recipient=" + in_config.mixin_client_id + "&asset=" + inAssetID + "&amount=" + str(inPayAmount) + '&trace=' + str(uuid.uuid1()) + '&memo=PRS2CNB' +def sendGroupPay(webSocketInstance, in_conversation_id, inAssetName, inAssetID, inPayAmount, linkColor = "#0CAAF5"): + payLink = "https://mixin.one/pay?recipient=" + mixin_config.mixin_client_id + "&asset=" + inAssetID + "&amount=" + str(inPayAmount) + '&trace=' + str(uuid.uuid1()) + '&memo=PRS2CNB' btn = '[{"label":"' + inAssetName + '","action":"' + payLink + '","color":"' + linkColor + '"}]' gameEntranceParams = {"conversation_id": in_conversation_id,"message_id":str(uuid.uuid4()),"category":"APP_BUTTON_GROUP","data":base64.b64encode(btn)} writeMessage(webSocketInstance, "CREATE_MESSAGE",gameEntranceParams) return - - - - def sendUserSticker(websocketInstance, in_conversation_id, to_user_id, album_id, sticker_name): realStickerObj = {} realStickerObj['album_id'] = album_id realStickerObj['name'] = sticker_name - btnJson = json.dumps(realStickerObj) params = {"conversation_id": in_conversation_id,"recipient_id":to_user_id,"message_id":str(uuid.uuid4()),"category":"PLAIN_STICKER","data":base64.b64encode(btnJson)} return writeMessage(websocketInstance, "CREATE_MESSAGE",params) - -def sendUserGameEntrance(webSocketInstance, in_config, in_conversation_id, to_user_id, inAssetName, inAssetID, inPayAmount, linkColor = "#0CAAF5"): - payLink = "https://mixin.one/pay?recipient=" + in_config.mixin_client_id + "&asset=" + inAssetID + "&amount=" + str(inPayAmount) + '&trace=' + str(uuid.uuid1()) + '&memo=PRS2CNB' +def sendUserPayAppButton(webSocketInstance, in_conversation_id, to_user_id, inAssetName, inAssetID, inPayAmount, linkColor = "#0CAAF5"): + payLink = "https://mixin.one/pay?recipient=" + mixin_config.mixin_client_id + "&asset=" + inAssetID + "&amount=" + str(inPayAmount) + '&trace=' + str(uuid.uuid1()) + '&memo=PRS2CNB' btn = '[{"label":"' + inAssetName + '","action":"' + payLink + '","color":"' + linkColor + '"}]' gameEntranceParams = {"conversation_id": in_conversation_id,"recipient_id":to_user_id,"message_id":str(uuid.uuid4()),"category":"APP_BUTTON_GROUP","data":base64.b64encode(btn)} writeMessage(webSocketInstance, "CREATE_MESSAGE",gameEntranceParams) -sendUserPayAppButton = sendUserGameEntrance - def showReceipt(websocketInstance, inConversationID, reply_user_id, reply_snapShotID): payLink = "https://mixin.one/snapshots/" + reply_snapShotID shortSnapShort = reply_snapShotID[0:13] + "..." btn = '[{"label":"Your receipt:' + shortSnapShort + '","action":"' + payLink + '","color":"#0CAAF5"}]' - params = {"conversation_id": inConversationID,"recipient_id":reply_user_id,"message_id":str(uuid.uuid4()),"category":"APP_BUTTON_GROUP","data":base64.b64encode(btn)} writeMessage(websocketInstance, "CREATE_MESSAGE",params) @@ -163,12 +122,8 @@ def replayMessage(websocketInstance, msgid): gzip_obj.write(Message_instring) gzip_obj.close() websocketInstance.send(fgz.getvalue(), opcode=websocket.ABNF.OPCODE_BINARY) - - - return -replyMessage = replayMessage def buildConversationId(robot_id, user_id): n = md5.new() n.update(user_id) @@ -180,25 +135,6 @@ def buildConversationId(robot_id, user_id): conver_id = uuid.UUID(bytes=result_new) return str(conver_id) -def listAssets(robot, config): - encoded = robot.genGETJwtToken('/assets', "", config.mixin_client_id) - r = requests.get('https://api.mixin.one/assets', headers = {"Authorization":"Bearer " + encoded, "Mixin-Device-Id":config.admin_uuid}) - print(r.status_code) - if r.status_code != 200: - error_body = result_obj['error'] - print(error_body) - - r.raise_for_status() - - result_obj = r.json() - print(result_obj) - assets_info = result_obj["data"] - asset_list = [] - for singleAsset in assets_info: - if singleAsset["balance"] != "0": - asset_list.append((singleAsset["symbol"], singleAsset["balance"])) - return asset_list - def recordFreeBonus(in_user_id): hashOfUserID = hashlib.sha256(in_user_id).hexdigest() thisFreshMan = session.query(Freshman).filter_by(userid = hashOfUserID).first() @@ -215,185 +151,125 @@ def recordFreeBonus(in_user_id): def notFreshMen(in_user_id): hashOfUserID = hashlib.sha256(in_user_id).hexdigest() thisFreshMan = session.query(Freshman).filter_by(userid = hashOfUserID).first() - if thisFreshMan != None and thisFreshMan.bonusCounter > 20: - return True - return False + return thisFreshMan != None and thisFreshMan.bonusCounter > 20 def on_message(ws, message): - global admin_conversation_id - inbuffer = StringIO(message) f = gzip.GzipFile(mode="rb", fileobj=inbuffer) rdata_injson = f.read() + print("recv msg:", rdata_injson) rdata_obj = json.loads(rdata_injson) action = rdata_obj["action"] - print(rdata_obj) if action not in ["ACKNOWLEDGE_MESSAGE_RECEIPT" ,"CREATE_MESSAGE", "LIST_PENDING_MESSAGES"]: print("unknow action") - print(rdata_obj) return + if action == "ACKNOWLEDGE_MESSAGE_RECEIPT": return - if action == "CREATE_MESSAGE" and 'error' in rdata_obj: - msgid = rdata_obj["data"]["message_id"] - data = rdata_obj["data"] - typeindata = data["type"] - categoryindata = data["category"] - dataindata = data["data"] - conversationid = data["conversation_id"] - replayMessage(ws, msgid) - print(data) - return - - if action == "CREATE_MESSAGE" and 'error' not in rdata_obj: - msgid = rdata_obj["data"]["message_id"] + + if action == "CREATE_MESSAGE": data = rdata_obj["data"] + msgid = data["message_id"] typeindata = data["type"] categoryindata = data["category"] + userId = data["user_id"] + conversationId = data["conversation_id"] dataindata = data["data"] - conversationid = data["conversation_id"] + realData = base64.b64decode(dataindata) + print("msg b64 data decoded:", realData) replayMessage(ws, msgid) - if data['user_id'] == mixin_config.admin_uuid: - admin_conversation_id = data["conversation_id"] + if 'error' in rdata_obj: + return - if categoryindata not in ["SYSTEM_ACCOUNT_SNAPSHOT", "PLAIN_TEXT", "SYSTEM_CONVERSATION", "PLAIN_STICKER","PLAIN_IMAGE", "PLAIN_CONTACT"]: + if categoryindata not in ["SYSTEM_ACCOUNT_SNAPSHOT", "PLAIN_TEXT", "SYSTEM_CONVERSATION", "PLAIN_STICKER", "PLAIN_IMAGE", "PLAIN_CONTACT"]: print("unknow category") - print(rdata_obj) return + if categoryindata == "PLAIN_IMAGE" or categoryindata == "SYSTEM_CONVERSATION": - realData = base64.b64decode(dataindata) sysConversationObj = json.loads(realData) if sysConversationObj["action"] == "ADD": - sendGroupText(ws, conversationid, "hello") + sendGroupText(ws, conversationId, "hello") if categoryindata == "SYSTEM_ACCOUNT_SNAPSHOT" and typeindata == "message": - - realData = base64.b64decode(dataindata) realAssetObj = json.loads(realData) - userid = realAssetObj["counter_user_id"] + counterUserId = realAssetObj["counter_user_id"] asset_amount = realAssetObj["amount"] + #showReceipt(ws, conversationId, counterUserId, realAssetObj["snapshot_id"]) if realAssetObj["asset_id"] == mixin_asset_list.CNB_ASSET_ID: - showReceipt(ws, conversationid, userid, realAssetObj["snapshot_id"]) if asset_amount == "1": - transferTo(mixin_api_robot, myConfig, userid, realAssetObj["asset_id"],"2","pay 1 get 2") + mixin_api_robot.transferTo(counterUserId, realAssetObj["asset_id"], "2", "pay 1 get 2") return - - transferTo(mixin_api_robot, myConfig, userid, realAssetObj["asset_id"],asset_amount,"rollback") - sendUserText(ws, data['conversation_id'], data['user_id'], str(realAssetObj)) + else: + mixin_api_robot.transferTo(counterUserId, realAssetObj["asset_id"], asset_amount, "rollback") + #sendUserText(ws, counterUserId, counterUserId, str(realAssetObj)) + return if categoryindata == "PLAIN_STICKER": - typeindata = data["type"] - categoryindata = data["category"] - conversationid = data["conversation_id"] - data['user_id'] == mixin_config.admin_uuid - - ConversationId = data['conversation_id'] - realStickerData = base64.b64decode(dataindata) - realStickerObj = json.loads(realStickerData) - sendUserText(ws, data['conversation_id'], data['user_id'], str(realStickerObj)) - - if realStickerObj['album_id'] == "eb002790-ef9b-467d-93c6-6a1d63fa2bee": - if realStickerObj['name'] == 'no_money': - sendUserAppButton(ws, ConversationId, data['user_id'], "https://babelbank.io", u"数字资产抵押贷款了解一下?".encode('utf-8')) - if realStickerObj['name'] in ['capital_predator', 'capital_cattle', 'capital_cat']: - now = datetime.datetime.now() - if notFreshMen(data['user_id']): - sendUserText(ws, data['conversation_id'], data['user_id'], u"新手期已过,没有奖励了".encode("utf-8")) - return - recordFreeBonus(data['user_id']) - - if data['user_id'] in freeBonusTimeTable: - oldtime = freeBonusTimeTable[data['user_id']] - if (now - oldtime).total_seconds() < 10 * 60: - btn = u"发动机过热,冷却中".encode('utf-8') - params = {"conversation_id": data['conversation_id'],"recipient_id":data['user_id'],"message_id":str(uuid.uuid4()),"category":"PLAIN_TEXT","data":base64.b64encode(btn)} - writeMessage(ws, "CREATE_MESSAGE",params) - return - freeBonusTimeTable[data['user_id']] = now - btn = u"浑身掉钱的大佬就是很任性,10分钟以后继续尝试".encode('utf-8') - params = {"conversation_id": data['conversation_id'],"recipient_id":data['user_id'],"message_id":str(uuid.uuid4()),"category":"PLAIN_TEXT","data":base64.b64encode(btn)} - writeMessage(ws, "CREATE_MESSAGE",params) - bonus = str(random.randint(0,12345)) - transferTo(mixin_api_robot, myConfig, data['user_id'] , mixin_asset_list.CNB_ASSET_ID,bonus,"you are rich") + realStickerObj = json.loads(realData) + sendUserText(ws, conversationId, userId, str(realStickerObj)) if categoryindata == "PLAIN_TEXT" and typeindata == "message": - if data['user_id'] in ["7921bb6f-f2e0-4ecd-a58e-e126c0437ed2", "f4456f2f-5b05-4779-9307-f037e712356b", "9478537e-6171-455f-a219-9bfb843e35d8", "f875e041-34b4-4edc-aed5-9e0188dd88da"]: + realData = realData.lower() + if realData in ['?', '?', 'help', u'帮助'.encode('utf-8')]: + introductionContent = u"""本机器人代码 https://github.com/hxzqlh/mixin_client_demo 机器人可以理解区块链系列贴纸:向资本大鳄低头;买币是第一生产力;不玩了,不玩了,没钱了。输入 contact/sticker/link/paycnb/payeos/payprs/bonus 可获取各种例子""".encode('utf-8') + sendUserText(ws, conversationId, userId, introductionContent) return - ConversationId = data['conversation_id'] - realData = base64.b64decode(dataindata) - if '?' == realData or u'?'.encode('utf-8') == realData or 'help' == realData or 'Help' == realData or u'帮助'.encode('utf-8') == realData: - btn = u"发送区块链系列贴纸有奇效:向大鳄/大喵/大牛低头;买币是第一生产力;不玩了,不玩了,没钱了".encode('utf-8') - params = {"conversation_id": data['conversation_id'],"recipient_id":data['user_id'],"message_id":str(uuid.uuid4()),"category":"PLAIN_TEXT","data":base64.b64encode(btn)} - writeMessage(ws, "CREATE_MESSAGE",params) - return if 'sticker' == realData: + # TODO 买币是第一生产力 sticker_blockchain_album_id = "eb002790-ef9b-467d-93c6-6a1d63fa2bee" - sendUserSticker(ws, data['conversation_id'], data['user_id'], sticker_blockchain_album_id, 'productive') + sendUserSticker(ws, conversationId, userId, sticker_blockchain_album_id, 'productive') return + if 'contact' == realData: - laoshe_user_id_in_contact_card_in_uuid_format = "99cf45c4-a64b-4aa1-8f9b-40c3e21d6468" - zhuzi_user_id_in_contact_card_in_uuid_format = "b4450d4c-9218-4d30-995f-83e14b29e9ad" - robot_cnb_atm_user_id_in_contact_card_in_uuid_format = "4055702e-09d3-418d-8956-38cf637ae204" - sendUserContactCard(ws, data['conversation_id'], data['user_id'],laoshe_user_id_in_contact_card_in_uuid_format) + sendUserContactCard(ws, conversationId, userId, mixin_config.admin_uuid) return if 'link' == realData: - sendUserAppButton(ws, ConversationId, data['user_id'], "http://dapai.one:8080", u"了解我的user id".encode('utf-8')) + sendUserAppButton(ws, conversationId, userId, "http://hxzqlh.com", u"了解下我?".encode('utf-8')) return + if 'paycnb' == realData: - sendUserPayAppButton(ws, myConfig, ConversationId, data['user_id'], u"付1CNB,得2CNB".encode('utf-8'),mixin_asset_list.CNB_ASSET_ID, 1, "#ff0033") + sendUserPayAppButton(ws, conversationId, userId, u"付1CNB,得2CNB".encode('utf-8'),mixin_asset_list.CNB_ASSET_ID, 1, "#ff0033") return + if 'payeos' == realData: - sendUserPayAppButton(ws, myConfig, ConversationId, data['user_id'], u"付0.001EOS并闪电退款".encode('utf-8'),mixin_asset_list.EOS_ASSET_ID, 0.001, "#ff0033") + sendUserPayAppButton(ws, conversationId, userId, u"付0.001EOS并闪电退款".encode('utf-8'),mixin_asset_list.EOS_ASSET_ID, 0.001, "#ff0033") return + if 'payprs' == realData: - sendUserPayAppButton(ws, myConfig, ConversationId, data['user_id'], u"付0.01PRS并闪电退款".encode('utf-8'),mixin_asset_list.PRS_ASSET_ID, 0.01, "#ff0033") + sendUserPayAppButton(ws, conversationId, userId, u"付0.01PRS并闪电退款".encode('utf-8'),mixin_asset_list.PRS_ASSET_ID, 0.01, "#ff0033") return - if 'robot' == realData: - sendUserContactCard(ws, data['conversation_id'], data['user_id'],robot_cnb_atm_user_id_in_contact_card_in_uuid_format) - return - if 'friendsofju' == realData.lower() or 'friendsofxiaodong' == realData.lower() or 'friendsoflaoshe' == realData.lower() or 'friendsofzhuzi' == realData.lower(): - if notFreshMen(data['user_id']): - sendUserText(ws, data['conversation_id'], data['user_id'], u"新手期已过,没有奖励了".encode("utf-8")) + + if 'bonus' == realData: + if notFreshMen(userId): + sendUserText(ws, conversationId, userId, u"新手期已过,没有奖励了".encode("utf-8")) return - recordFreeBonus(data['user_id']) + + recordFreeBonus(userId) now = datetime.datetime.now() - if data['user_id'] in freeBonusTimeTable: - oldtime = freeBonusTimeTable[data['user_id']] + if userId in freeBonusTimeTable: + oldtime = freeBonusTimeTable[userId] if (now - oldtime).total_seconds() < 60 * 10: - btn = u"点钞机过热,冷却中".encode('utf-8') - params = {"conversation_id": data['conversation_id'],"recipient_id":data['user_id'],"message_id":str(uuid.uuid4()),"category":"PLAIN_TEXT","data":base64.b64encode(btn)} - writeMessage(ws, "CREATE_MESSAGE",params) + sendUserText(ws, conversationId, userId, u"点钞机过热,冷却中".encode('utf-8')) return - freeBonusTimeTable[data['user_id']] = now - btn = u"与大佬做朋友就是好,10分钟以后再来一发".encode('utf-8') - params = {"conversation_id": data['conversation_id'],"recipient_id":data['user_id'],"message_id":str(uuid.uuid4()),"category":"PLAIN_TEXT","data":base64.b64encode(btn)} - writeMessage(ws, "CREATE_MESSAGE",params) - bonus = str(random.randint(0,12345)) - transferTo(mixin_api_robot, myConfig, data['user_id'] , mixin_asset_list.CNB_ASSET_ID,bonus,"you are rich") - - if 'ye' == realData and data['user_id'] == mixin_config.admin_uuid: - for eachNonZeroAsset in listAssets(mixin_api_robot, mixin_config): - sendUserText(ws, data['conversation_id'], data['user_id'], str(eachNonZeroAsset)) - - introductionContent = u"CNB是数字货币社区行为艺术作品产生的token。由老社发行,zhuzi撰写白皮书,西乔设计logo,霍大佬广为宣传。本机器人代码 https://github.com/myrual/mixin_client_demo \n机器人可以理解区块链系列贴纸:向大鳄/大喵/大牛低头;不玩了,不玩了,没钱了\n 输入 contact\sticker\link\paycnb\payeos\payprs\ robot 可获取各种例子".encode('utf-8') - #convID = data['conversation_id']#buildConversationId(mixin_config.mixin_client_id, data['userid']) - convID = buildConversationId(myConfig.mixin_client_id, data['user_id']) - - sendUserText(ws, convID, data['user_id'], introductionContent) - return - + + freeBonusTimeTable[userId] = now + sendUserText(ws, conversationId, userId, u"与大佬做朋友就是好,10分钟以后再来一发".encode('utf-8')) + bonus = str(random.randint(10,100)) + mixin_api_robot.transferTo(userId, mixin_asset_list.CNB_ASSET_ID, bonus, "you are rich") + + if 'robot' == realData and userId == mixin_config.admin_uuid: + for eachNonZeroAsset in mixin_api_robot.listAssets(): + sendUserText(ws, conversationId, userId, str(eachNonZeroAsset)) + return + elif categoryindata == "PLAIN_TEXT": print("PLAIN_TEXT but unkonw:") - print(rdata_obj) -SocketStatus = 0 def on_error(ws, error): - SocketStatus = SocketStatus + 1 - print("error") print(error) def on_close(ws): @@ -403,37 +279,29 @@ def on_data(ws, readableString, dataType, continueFlag): return def on_open(ws): - - def run(*args): - print("run") + print("ws open") Message = {"id":str(uuid.uuid1()), "action":"LIST_PENDING_MESSAGES"} Message_instring = json.dumps(Message) fgz = StringIO() gzip_obj = gzip.GzipFile(mode='wb', fileobj=fgz) gzip_obj.write(Message_instring) gzip_obj.close() - ws.send(fgz.getvalue(), opcode=websocket.ABNF.OPCODE_BINARY) while True: - a = 1 time.sleep(1) thread.start_new_thread(run, ()) - if __name__ == "__main__": while True: - encoded = mixin_api_robot.genGETJwtToken('/', "", str(uuid.uuid4())) - websocket.enableTrace(True) + #websocket.enableTrace(True) ws = websocket.WebSocketApp("wss://blaze.mixin.one/", - on_message = on_message, - on_error = on_error, - on_close = on_close, - header = ["Authorization:Bearer " + encoded], - subprotocols = ["Mixin-Blaze-1"], - on_data = on_data) + on_message = on_message, + on_error = on_error, + on_close = on_close, + header = ["Authorization:Bearer " + encoded], + subprotocols = ["Mixin-Blaze-1"], + on_data = on_data) ws.on_open = on_open ws.run_forever() - print("run") - diff --git a/mixin_api.py b/mixin_api.py index 47566c5..84c74f4 100644 --- a/mixin_api.py +++ b/mixin_api.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python +#coding: utf-8 + from Crypto.PublicKey import RSA import base64 from Crypto.Cipher import PKCS1_OAEP @@ -14,43 +17,6 @@ import json import ssl - - -def transferTo(robot, config, to_user_id, to_asset_id,to_asset_amount,memo): - encrypted_pin = robot.genEncrypedPin_extConfig(config) - 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()), 'memo':memo} - body_in_json = json.dumps(body) - - encoded = robot.genPOSTJwtToken_extConfig('/transfers', body_in_json, config) - r = requests.post('https://api.mixin.one/transfers', json = body, headers = {"Authorization":"Bearer " + encoded}) - result_obj = r.json() - if 'error' in result_obj: - error_body = result_obj['error'] - error_code = error_body['code'] - if error_code == 20119: - print("to :" + to_user_id + " with asset:" + to_asset_id + " amount:" + to_asset_amount) - print(result_obj) - return False - else: - return True - - -def transferToFromPub(robot, config, to_user_id, to_asset_id,to_asset_amount,memo, trace_uuid=""): - encrypted_pin = robot.genEncrypedPin_extConfig(config) - if trace_uuid == "": - 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()), 'memo':memo} - else: - body = {'asset_id': to_asset_id, 'counter_user_id':to_user_id, 'amount':str(to_asset_amount), 'pin':encrypted_pin, 'trace_id':trace_uuid, 'memo':memo} - - body_in_json = json.dumps(body) - - encoded = robot.genPOSTJwtToken_extConfig('/transfers', body_in_json, config) - r = requests.post('https://api.mixin.one/transfers', json = body, headers = {"Authorization":"Bearer " + encoded}) - result_obj = r.json() - print(result_obj) - return result_obj - - class MIXIN_API: def __init__(self): self.appid = "" @@ -59,141 +25,47 @@ def __init__(self): self.asset_pin = "" self.pin_token = "" self.private_key = "" - self.keyForAES = "" - - def generateSig(self, method, uri, body): - hashresult = hashlib.sha256(method + uri+body).hexdigest() - #print("generate sha256 for sig" + " with: " + method + uri + body) - #print(hashresult) - return hashresult - - def genGETPOSTSig(self, methodstring, uristring, bodystring): - jwtSig = self.generateSig(methodstring, uristring, bodystring) - #print(methodstring + " sig:" + jwtSig) - #print("method:" + methodstring) - #print("uri :" + uristring) - #print("body :" + bodystring) - return jwtSig + def __genSig(self, method, uri, body): + hashresult = hashlib.sha256(method + uri + body).hexdigest() + return hashresult def genGETSig(self, uristring, bodystring): - return self.genGETPOSTSig("GET", uristring, bodystring) + return self.__genSig("GET", uristring, bodystring) def genPOSTSig(self, uristring, bodystring): - return self.genGETPOSTSig("POST", uristring, bodystring) - def genGETJwtToken(self, uristring, bodystring, jti): - jwtSig = self.genGETSig(uristring, bodystring) - iat = datetime.datetime.utcnow() - exp = datetime.datetime.utcnow() + datetime.timedelta(seconds=200) - encoded = jwt.encode({'uid':self.appid, 'sid':self.sessionid,'iat':iat,'exp': exp, 'jti':jti,'sig':jwtSig}, self.private_key, algorithm='RS512') - #print("get jwt token with") - #print("appid:" + self.appid) - #print("sid :" + self.sessionid) - #print("iat :" + str(iat)) - #print("exp :" + str(exp)) - #print("jti :" + jti) - #print("sig :" + jwtSig) - #print("priv :" + self.private_key) - #print("RS512") - #print("====>" + encoded) - return encoded - def genGETJwtToken_extConfig(self, uristring, bodystring, ext_config): - jwtSig = self.genGETSig(uristring, bodystring) + return self.__genSig("POST", uristring, bodystring) + + def __genJwtToken(self, method, uristring, bodystring, jti): + jwtSig = self.__genSig(method, uristring, bodystring) iat = datetime.datetime.utcnow() exp = datetime.datetime.utcnow() + datetime.timedelta(seconds=200) - encoded = jwt.encode({'uid':ext_config.mixin_client_id, 'sid':ext_config.mixin_pay_sessionid,'iat':iat,'exp': exp, 'jti':ext_config.mixin_client_id,'sig':jwtSig}, ext_config.private_key, algorithm='RS512') - #print("get jwt token with") - #print("appid:" + self.appid) - #print("sid :" + self.sessionid) - #print("iat :" + str(iat)) - #print("exp :" + str(exp)) - #print("jti :" + jti) - #print("sig :" + jwtSig) - #print("priv :" + self.private_key) - #print("RS512") - #print("====>" + encoded) + encoded = jwt.encode({'uid':self.appid, 'sid':self.sessionid,'iat':iat,'exp': exp, 'jti':jti,'sig':jwtSig}, self.private_key, algorithm='RS512') return encoded + def genGETJwtToken(self, uristring, bodystring, jti): + return self.__genJwtToken("GET", uristring, bodystring, jti) + + def genPOSTJwtToken(self, uristring, bodystring, jti): + return self.__genJwtToken("POST", uristring, bodystring, jti) def genGETListenSignedToken(self, uristring, bodystring, jti): jwtSig = self.genGETSig(uristring, bodystring) iat = datetime.datetime.utcnow() exp = datetime.datetime.utcnow() + datetime.timedelta(seconds=200) - encoded = jwt.encode({'uid':self.appid, 'sid':self.sessionid,'iat':iat,'exp': exp, 'jti':jti,'sig':jwtSig}, self.private_key, algorithm='RS512') + encoded = jwt.encode({'uid':self.appid, 'sid':self.sessionid,'iat':iat,'exp': exp, 'jti':jti,'sig':jwtSig}, self.private_key, algorithm='RS512') privKeyObj = RSA.importKey(self.private_key) signer = PKCS1_v1_5.new(privKeyObj) signature = signer.sign(encoded) return signature - - def genPOSTJwtToken(self, uristring, bodystring, jti): - jwtSig = self.genPOSTSig(uristring, bodystring) - iat = datetime.datetime.utcnow() - exp = datetime.datetime.utcnow() + datetime.timedelta(seconds=200) - encoded = jwt.encode({'uid':self.appid, 'sid':self.sessionid,'iat':iat,'exp': exp, 'jti':jti,'sig':jwtSig}, self.private_key, algorithm='RS512') - return encoded - - def genPOSTJwtToken_extConfig(self, uristring, bodystring, ext_config): - jwtSig = self.genPOSTSig(uristring, bodystring) - iat = datetime.datetime.utcnow() - exp = datetime.datetime.utcnow() + datetime.timedelta(seconds=200) - encoded = jwt.encode({'uid':ext_config.mixin_client_id, 'sid':ext_config.mixin_pay_sessionid,'iat':iat,'exp': exp, 'jti':str(uuid.uuid1()),'sig':jwtSig}, ext_config.private_key, algorithm='RS512') - return encoded - - def genEncrypedPin_extConfig(self, ext_config): - privKeyObj = RSA.importKey(ext_config.private_key) - decoded_result = base64.b64decode(ext_config.mixin_pin_token) - decoded_result_inhexString = ":".join("{:02x}".format(ord(c)) for c in decoded_result) - cipher = PKCS1_OAEP.new(key = privKeyObj, hashAlgo = Crypto.Hash.SHA256, label = ext_config.mixin_pay_sessionid) - - decrypted_msg = cipher.decrypt(decoded_result) - decrypted_msg_inhexString = ":".join("{:02x}".format(ord(c)) for c in decrypted_msg) - - - keyForAES = decrypted_msg - - ts = int(time.time()) - tszero = ts%0x100 - tsone = (ts%0x10000) >> 8 - tstwo = (ts%0x1000000) >> 16 - tsthree = (ts%0x100000000) >> 24 - tsstring = chr(tszero) + chr(tsone) + chr(tstwo) + chr(tsthree) + '\0\0\0\0' - counter = '\1\0\0\0\0\0\0\0' - toEncryptContent = ext_config.asset_pin + tsstring + tsstring - lenOfToEncryptContent = len(toEncryptContent) - toPadCount = 16 - lenOfToEncryptContent % 16 - if toPadCount > 0: - paddedContent = toEncryptContent + chr(toPadCount) * toPadCount - else: - paddedContent = toEncryptContent - - iv = Random.new().read(AES.block_size) - cipher = AES.new(keyForAES, AES.MODE_CBC, iv) - encrypted_result = cipher.encrypt(paddedContent) - msg = iv + encrypted_result - encrypted_pin = base64.b64encode(msg) - - return encrypted_pin - def genEncrypedPin(self): - if self.keyForAES == "": - privKeyObj = RSA.importKey(self.private_key) - decoded_result = base64.b64decode(self.pin_token) - decoded_result_inhexString = ":".join("{:02x}".format(ord(c)) for c in decoded_result) -# print("pin_token is:" + self.pin_token) -# print("lenth of decoded pin_token is:" + str(len(decoded_result))) - cipher = PKCS1_OAEP.new(key = privKeyObj, hashAlgo = Crypto.Hash.SHA256, label = self.sessionid) - - decrypted_msg = cipher.decrypt(decoded_result) - decrypted_msg_inhexString = ":".join("{:02x}".format(ord(c)) for c in decrypted_msg) -# print("lenth of AES key:" + str(len(decrypted_msg))) -# print("content of AES key:") -# print(decrypted_msg_inhexString) - - self.keyForAES = decrypted_msg + privKeyObj = RSA.importKey(self.private_key) + cipher = PKCS1_OAEP.new(key = privKeyObj, hashAlgo = Crypto.Hash.SHA256, label = self.sessionid) + pinTokenObj = base64.b64decode(self.pin_token) + keyForAES = cipher.decrypt(pinTokenObj) ts = int(time.time()) -# print("ts"+ str(ts)) tszero = ts%0x100 tsone = (ts%0x10000) >> 8 tstwo = (ts%0x1000000) >> 16 @@ -201,23 +73,44 @@ def genEncrypedPin(self): tsstring = chr(tszero) + chr(tsone) + chr(tstwo) + chr(tsthree) + '\0\0\0\0' counter = '\1\0\0\0\0\0\0\0' toEncryptContent = self.asset_pin + tsstring + tsstring -# print("before padding:" + str(len(toEncryptContent))) lenOfToEncryptContent = len(toEncryptContent) toPadCount = 16 - lenOfToEncryptContent % 16 if toPadCount > 0: paddedContent = toEncryptContent + chr(toPadCount) * toPadCount else: paddedContent = toEncryptContent -# print("after padding:" + str(len(paddedContent))) iv = Random.new().read(AES.block_size) - cipher = AES.new(self.keyForAES, AES.MODE_CBC, iv) + cipher = AES.new(keyForAES, AES.MODE_CBC, iv) encrypted_result = cipher.encrypt(paddedContent) msg = iv + encrypted_result encrypted_pin = base64.b64encode(msg) -# print("to encrypted content in hex is :" + ":".join("{:02x}".format(ord(c)) for c in paddedContent)) -# print("iv in hex is " + ":".join("{:02x}".format(ord(c)) for c in iv)) -# print("iv + encrypted result in hex is :" + ":".join("{:02x}".format(ord(c)) for c in (iv + encrypted_result))) -# print("iv + encrypted_result in base64 :" + encrypted_pin) - return encrypted_pin + + def transferTo(self, to_user_id, to_asset_id, to_asset_amount, memo, trace_uuid=""): + encrypted_pin = self.genEncrypedPin() + body = {'asset_id': to_asset_id, 'counter_user_id':to_user_id, 'amount':str(to_asset_amount), 'pin':encrypted_pin, 'trace_id':trace_uuid, 'memo':memo} + if trace_uuid == "": + body['trace_id'] = str(uuid.uuid1()) + + body_in_json = json.dumps(body) + token = self.genPOSTJwtToken('/transfers', body_in_json, str(uuid.uuid4())) + r = requests.post('https://api.mixin.one/transfers', json = body, headers = {"Authorization":"Bearer " + token}) + result_obj = r.json() + print("transfer to:", to_user_id, result_obj) + return result_obj + + def listAssets(self): + token = self.genGETJwtToken('/assets', "", str(uuid.uuid4())) + r = requests.get('https://api.mixin.one/assets', headers = {"Authorization":"Bearer " + token}) + if r.status_code != 200: + print(r.status_code, r.text) + r.raise_for_status() + + result_obj = r.json() + assets_info = result_obj["data"] + asset_list = [] + for singleAsset in assets_info: + if singleAsset["balance"] != "0": + asset_list.append((singleAsset["symbol"], singleAsset["balance"])) + return asset_list \ No newline at end of file diff --git a/mixin_asset_list.py b/mixin_asset_list.py index 553510d..9d2838e 100644 --- a/mixin_asset_list.py +++ b/mixin_asset_list.py @@ -1,6 +1,7 @@ PRS_ASSET_ID = "3edb734c-6d6f-32ff-ab03-4eb43640c758" LY_ASSET_ID = "35f7a3a3-4335-3bf3-beca-685836602d72" -BTCCash_ASSET_ID = "fd11b6e3-0b87-41f1-a41f-f0e9b49e5bf0" +BTC_ASSET_ID = "fd11b6e3-0b87-41f1-a41f-f0e9b49e5bf0" CNB_ASSET_ID = "965e5c6e-434c-3fa9-b780-c50f43cd955c" EOS_ASSET_ID = "f8127159-e473-389d-8e0c-9ac5a4dc8cc6" CANDY_ASSET_ID = "43b645fc-a52c-38a3-8d3b-705e7aaefa15" +XIN_ASSET_ID = "c94ac88f-4671-3976-b60a-09064f1811e8" \ No newline at end of file diff --git a/mixin_config.py b/mixin_config.py index d718213..9cbc10b 100644 --- a/mixin_config.py +++ b/mixin_config.py @@ -1,35 +1,26 @@ -mixin_client_id = "3c5fd587-5ac3-4fb6-b294-423ba3473f7d" -mixin_client_secret = "9cb0c7245bda18ca34b6e23bf2f194826b474907f8d898a92013e2c0dee8f977" -mixin_pay_pin = '515532' -mixin_pay_sessionid = '25083eb4-adab-49f3-9600-81d244b7cbc4' +#!/usr/bin/env python +#coding: utf-8 + +mixin_client_id = "0aaac09a-c899-48e5-9cb1-fa68f083d277" +mixin_client_secret = "7dd59f0d362ee173b660d9d5a038cc1cd974fcfa8f88011087042e90c40f50b0" +mixin_pay_pin = '372282' +mixin_pay_sessionid = '86e8f083-391f-4953-a36b-7bf7d11cec73' private_key = """-----BEGIN RSA PRIVATE KEY----- -MIICXAIBAAKBgQDG+84eobu6hfDYYr+hsTOFi9w0ska988FB009yDgWBmSQA3TNI -jl6QKZVuJ0TwPijUfzkc1af6dfvJ60J4REPHLdhUghg0oVgWOjrYlYadb7XIqzw4 -a9R+NH66dHyXhVnoHxEM+2c7eUvam3vvj1UFQFx3iNPCxYganLtGarkffwIDAQAB -AoGAJmepU74xhoGdh5YfmGykHg1tdfpGrxjh3vuS5NeR9n6BNW18HW/lDnwILFeF -9bx5kvHvKwKNxkiJTWKL1LyQPAT9h78IkNlrW7ayLAwaasKg23UU8V+htf0WczAd -YWQ7woWU4ADbigximpmCtQCpuH7V6vvel72ny8QxYDGXOWECQQDt7e8fPBWjyHOp -uRivZi3prhDgf+pUIEYb4Sm5NEOa/wi+v76ZbZgg792rBGktq1Lt06d4vY2UpGr+ -771cns9RAkEA1hilnNE8J6IcPSAfgFD9vYhVX0J6kNTKfLUeINlt7hiYeRTxP9d0 -60Jdt/6btKW6AHpoCjngWFgXPTFO6OptzwJBAIj2dLZIQjS8CUjkUj911Gw2VWTG -fb/brEAUR45jdZ9dvE0B19g+bFpZegMeUOWHP//D3R32D/BHDYifvSP6D2ECQG2O -LzEP4LhnPAwLZBNFXpKeMRGN8yopuXQXOlOU76vm6h8LmGgS2MGKNGry3rqSE5wr -BxI0i5ipezrVAIwvagECQCHgwaDAobG5UpflHlzamTSu4OURVF1gomqSnpZp2AM9 -r9fVfWzUIFLuXFM/1eM+MbZrDs9J1WHyaRHK+F/3WKs= +MIICXAIBAAKBgQC/1bUVbpYlW+osDTuatR0viHVk8wTPS5gvNC7Pp2creynyfw+Z +00HBZD2HPnBiOg+FJBTXKyfAObYrixWgFYJXJ3ZnL6TRiWv7TQpiYSamvREy0AdS +dDPKizpzlKjCJeg3Mmn/jJW24QoO6E2z8dlurCULXpUKY1LQD0NCpOX4TwIDAQAB +AoGAdVYsOv23TQaZh3RYntplDavz0llq+biNT2Ilt9H3IvtkvvTFABvdvoKnt8+T +QiGtWIynSq0U1Vj3ek7KXW6Kl98497U1ljC87KBUtxhQ+cIEF27fRQiQwLBb6quN +vA1WCcvjDPr1A0hOGzxXqolp/ia8oEMHDiX/W/wv5cr/5wECQQD7stMn6tXoZF+/ +r6QCZu4A1eFqz3L2Z+sB9tGuygzUMy/k42IsVYxU9Re7rvpnczb7d1tQb8IyakjY +Azw6rv0PAkEAwxz65iouRSMPU8RtYriBMaaPSPK5HGg6An9MlKweZ5/OXQN19bpL +skAJluUBpcEy+PDGhjzGpS4MmjMf+tPQwQJAanyyx02caHCm7cNSoU2I3kOe1gCk +g8ldbPxOpCOJn/F0DuOAsn8TGxKCkv4ppMDi/yr1MCfIQmojHXjo727/UwJAcUiL +OEW3Vbb0eDttE0ty34QIX19mMOMnAzosGYoRoTK8225d980xlA3wQ2c1XKre0IDj +kx8IavFgqcsTP0vqQQJBAOMd3UlHYm3MV7INbYUYLkyCyE4ZVUCL6yeTK1vAHnYo +0awCPFv/QvwTwn0zF9aWS6eiXqW/iEQlXXDpQcTnhVw= -----END RSA PRIVATE KEY-----""" - -mixin_pin_token = """csEaHIh5RuVcXqcJ9aNp/AoubC/0L9ZtGWn037XREiR5JlbAvDW52obceJ9wWxVB12V9QxmabGmGR59wLoyfhfQeSVer56jOIUrOgL4ZXaMq32Rsddp2wpydEsCJbIjDftKwHJJvfz0XFAsNeBCTC+OfouaLW86Q50g3p7razbM=""" -admin_uuid = "28ee416a-0eaa-4133-bc79-9676909b7b4e" -class user_mixin_config: - def __init__(self): - self.mixin_client_id = "" - self.mixin_pay_sessionid= "" - self.mixin_pin_token= "" - self.mixin_pay_pin = "" - self.private_key = "" - self.deviceID = "" - self.keyForAES = "" - self.asset_pin = "" - +mixin_pin_token = "GgEq0y8l8Zw/UzV+kYhKFy3oxVTWk61t8+pF9F71eTioU9AAPObKauodurb+dGRUQAazfaWe13XfNJe0g9eIRmEUG6MsRvVKLXkOopcGIKM9w2JSsfp9pWq1TxEhTzvEQbF8Nvtzdq0pfJPwnxnFqtjfuhm3o24JL+lAyhEc/LI=" +admin_uuid = "a9c754ff-1e26-4f81-bd20-955de8982cd6" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8f10c1c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +cryptography==2.3.1 +ecdsa==0.13 +pycrypto==2.6.1 +PyJWT==1.6.4 +requests==2.19.1 +SQLAlchemy==1.2.12 +web.py==0.39 +websocket-client==0.53.0 \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..71162f5 --- /dev/null +++ b/run.sh @@ -0,0 +1,5 @@ + + +nohup python home_cnb.py 8888 >> log 2>&1 & +nohup python home_of_cnb_robot.py >> log 2>&1 & +