Exemple #1
0
    def test_getcollectiondata(self):

        pro_id = 1
        # url = 'http://127.0.0.1:59009/queryaddresses'
        url = 'http://192.168.10.174/api/collection/getcollectiondata'

        # for token_name in ['HTDF', 'ETH']:
        post_data = {
            # 'address_count': address_count,
            # 'account_index': account_index,
            'pro_id': pro_id,
            'token_name': 'BTC',
            'start_time': 0,
            'end_time': 9999999999,
            'page_index': 1,
            'page_size': 20
        }

        # header = {
        #     'ContentType': 'application/json'
        # }

        jdata = json.dumps(post_data, separators=(',', ':'),
                           sort_keys=True)  # 按照key字母顺序排序

        # '1590040704197'
        timestamp = str(int(time.time() * 1000))
        # method  = 'POST'
        api_name = 'getcollectiondata'

        param = '|'.join([timestamp, api_name, jdata])
        # print(param)

        msg = param.encode('utf8')
        sign_key = '9fb4d80781b34eac1b54f5631cc931133c42fd0decb2cda4738118996b416744'
        # sk = SigningKey(sk_s=sign_key.encode('latin1'), prefix='', encoding='hex')
        # sig = sk.sign(msg=msg, prefix='', encoding='base64')
        sig = sign_msg(sign_key=sign_key, msg=msg)
        sig = sig.decode('utf8')
        print(f'sig:{sig}')
        # if verify_sig(verify_key=ASCCI_VERIFY_KEY, sig=sig, msg=msg):
        #     print('verify ok')
        # else:
        #     print('verify failed')
        header = {
            'ContentType': 'application/json',
            'PG_API_KEY':
            '4575b80909ed0f2a09da77965f77b99a79b4182c66c7b51d002e134486bc1e97',
            'PG_API_TIMESTAMP': timestamp,
            'PG_API_SIGNATURE': sig
        }

        rsp = requests.post(url=url, json=post_data, headers=header)

        self.assertEqual(rsp.status_code, 200)

        rsp_data = rsp.json()
        print(rsp_data)

        pass
Exemple #2
0
    def test_generateaddress(self):

        # url = 'http://127.0.0.1:59009/addaddresses'


        address_count = 10
        pro_id = 52

        # for token_name in ['BTC', 'HTDF', 'ETH']:
        for token_name in ['ETH']:
            post_data = {
                'address_count': address_count,
                # 'account_index': account_index,
                'pro_id': pro_id,
                'token_name': token_name,
            }



            jdata = json.dumps(post_data, separators=(',', ':'), sort_keys=True)  # 按照key字母顺序排序

            # '1590040704197'
            timestamp =  str(int(time.time() * 1000))
            # method  = 'POST'
            api_name = 'addaddresses'

            param = '|'.join([timestamp, api_name, jdata])
            # print(param)

            msg = param.encode('utf8')
            sign_key = '2ed28bf53120a4d07ce82e614be060a15322563bada59f16d2ac1f7c323acdb0'
            # sk = SigningKey(sk_s=sign_key.encode('latin1'), prefix='', encoding='hex')
            # sig = sk.sign(msg=msg, prefix='', encoding='base64')
            sig = sign_msg(sign_key=sign_key, msg=msg)
            sig = sig.decode('utf8')
            print(f'sig:{sig}')
            # if verify_sig(verify_key=ASCCI_VERIFY_KEY, sig=sig, msg=msg):
            #     print('verify ok')
            # else:
            #     print('verify failed')
            header = {
                'ContentType': 'application/json',
                'PG_API_KEY':'1f0e774c81e2b3545493a76873d019b42d2273a617535b3848dcca17e7334efe',
                'PG_API_TIMESTAMP':timestamp,
                'PG_API_SIGNATURE':sig
            }



            rsp = requests.post(url='http://192.168.10.174/api/wallet/addaddresses', json=post_data, headers=header)
            # rsp = requests.post(url='http://192.168.10.155:59000/addaddresses', json=post_data, headers=header)

            self.assertEqual(rsp.status_code, 200)

            rsp_data = rsp.json()
            print(rsp_data)


        pass
    def test_withdraw_order_post_v2(self):

        # while True:
        if True:

            token_name = 'HTDF'
            to_address = 'htdf1rpuzcwy96y4rtksl6whmku0w8pwgjlykx2yu6e'

            orderid = self.get_random_number_str(20)
            data = {
                "order_id": orderid,
                "from_address": 'htdf1vhq6c38demm58cnevc4sntc77z8ppvl85mj0a6',
                "to_address": to_address,
                "amount": '0.1',
                "token_name": token_name,
                "pro_id": 1,
                "callback_url": "http://192.168.10.29:8001/notify/withdraw",
                "memo": "测"
            }

            jdata = json.dumps(data, separators=(',', ':'),
                               sort_keys=True)  # 按照key字母顺序排序

            # '1590040704197'
            timestamp = str(int(time.time() * 1000))
            # method  = 'POST'
            api_name = 'withdraw'

            param = '|'.join([timestamp, api_name, jdata])
            # print(param)

            msg = param.encode('utf8')
            sign_key = 'bea7b5228628eaeffe3e595d389628ae9e2cdade0bfc093b606cf2e7b5db029c'
            sig = sign_msg(sign_key=sign_key, msg=msg)
            sig = sig.decode('utf8')
            print(f'sig:{sig}')

            header = {
                # 'ContentType': 'application/json',
                'PG_API_KEY':
                'dafe466bad363682060c178a409ee9a7d35be178b2a51c98c3d12eb8c43e2a51',
                'PG_API_TIMESTAMP': timestamp,
                'PG_API_SIGNATURE': sig
            }

            # url = "http://192.168.10.174/api/withdraw/withdraw"
            url = "http://192.168.10.231/api/withdraw/withdraw"
            # url = "http://192.168.10.29:8001/notify/withdraw"
            # url = "http://192.168.10.107:7778/api/withdraw/notifywithdraw"
            # url = "http://127.0.0.1:59002/withdraw"

            rest = requests.post(url=url, json=data, headers=header)
            print(rest.text)
Exemple #4
0
    def test_query_deposit_data(self):

        data = {
            'pro_id': 1,
            # 'token_name': 'HTDF',
            'token_name': 'BTC',
            'start_height': 0,
            'end_height': 999999999,
            'page_index': 1,
            'page_size': 2,
        }

        jdata = json.dumps(data, separators=(',', ':'),
                           sort_keys=True)  # 按照key字母顺序排序

        # '1590040704197'
        timestamp = str(int(time.time() * 1000))
        # method  = 'POST'
        api_name = 'getdepositdata'

        param = '|'.join([timestamp, api_name, jdata])
        # print(param)

        msg = param.encode('utf8')
        sign_key = '9fb4d80781b34eac1b54f5631cc931133c42fd0decb2cda4738118996b416744'
        sig = sign_msg(sign_key=sign_key, msg=msg)
        sig = sig.decode('utf8')
        print(f'sig:{sig}')

        header = {
            'ContentType': 'application/json',
            'PG_API_KEY':
            '4575b80909ed0f2a09da77965f77b99a79b4182c66c7b51d002e134486bc1e97',
            'PG_API_TIMESTAMP': timestamp,
            'PG_API_SIGNATURE': sig
        }

        url = "http://192.168.10.174/api/deposit/getdepositdata"
        # url = "http://127.0.0.1:59000/getdepositdata"
        rest = requests.post(url=url, json=data, headers=header)

        print(json.dumps(json.loads(rest.text), indent=4))

        pass
Exemple #5
0
    def test_queryaddress(self):

        pro_id = 1
        url = 'http://127.0.0.1:59000/queryaddresses'
        # url = 'http://192.168.10.174/api/wallet/queryaddresses'

        for token_name in ['HTDF', 'ETH']:
            post_data = {
                'pro_id': pro_id,
                'token_name': token_name,
                'page_index':1,
                'page_size':1,
                'order_id':'202006081010508973077'
            }

            jdata = json.dumps(post_data, separators=(',', ':'), sort_keys=True)  # 按照key字母顺序排序

            timestamp = str(int(time.time() * 1000))
            api_name = 'queryaddresses'

            param = '|'.join([timestamp, api_name, jdata])

            msg = param.encode('utf8')
            sign_key = '3e4b948ae2a54554d13138d64c5fb6b9764489099803f2f7360306d8e9db98f8'
            sig = sign_msg(sign_key=sign_key, msg=msg)
            sig = sig.decode('utf8')
            print(f'sig:{sig}')
            header = {
                'ContentType': 'application/json',
                'PG_API_KEY': 'd5a08d84603f5714914bf39915d198b501e8f389e31fe12ec6f18d7b906f5c0c',
                'PG_API_TIMESTAMP': timestamp,
                'PG_API_SIGNATURE': sig
            }

            rsp = requests.post(url=url, json=post_data, headers=header)

            self.assertEqual(rsp.status_code, 200)

            rsp_data = rsp.json()
            print(rsp_data)

            break
        pass
Exemple #6
0
    def test_query_all_withdraw_order(self):
        pro_id = 1
        post_data = {
            # 'address_count': address_count,
            # 'account_index': account_index,
            'pro_id': pro_id,
            'token_name': 'HTDF',
            'start_time': 0,
            'end_time': 9999999999,
            'page_index': 1,
            'page_size': 20
        }

        jdata = json.dumps(post_data, separators=(',', ':'), sort_keys=True)  # 按照key字母顺序排序

        # '1590040704197'
        timestamp = str(int(time.time() * 1000))
        # method  = 'POST'
        api_name = 'queryallwithdrawdata'

        param = '|'.join([timestamp, api_name, jdata])
        # print(param)

        msg = param.encode('utf8')
        sign_key = '3e4b948ae2a54554d13138d64c5fb6b9764489099803f2f7360306d8e9db98f8'
        sig = sign_msg(sign_key=sign_key, msg=msg)
        sig = sig.decode('utf8')
        print(f'sig:{sig}')

        header = {
            'ContentType': 'application/json',
            'PG_API_KEY': 'd5a08d84603f5714914bf39915d198b501e8f389e31fe12ec6f18d7b906f5c0c',
            'PG_API_TIMESTAMP': timestamp,
            'PG_API_SIGNATURE': sig
        }

        url = "http://192.168.10.174/api/withdraw/queryallwithdrawdata"
        # url = "http://127.0.0.1:59001/querywithdraworder"
        rest = requests.post(url=url, json=post_data, headers=header)
        print(rest.text)

        pass
Exemple #7
0
    def test_query_withdraw_order(self):

        data = {
            'pro_id':1,
            'serial_id' : '202005211652543548069'
        }

        jdata = json.dumps(data, separators=(',', ':'), sort_keys=True)  # 按照key字母顺序排序

        # '1590040704197'
        timestamp = str(int(time.time() * 1000))
        # method  = 'POST'
        api_name = 'querywithdraworder'

        param = '|'.join([timestamp, api_name, jdata])
        # print(param)

        msg = param.encode('utf8')
        sign_key = '3e4b948ae2a54554d13138d64c5fb6b9764489099803f2f7360306d8e9db98f8'
        sig = sign_msg(sign_key=sign_key, msg=msg)
        sig = sig.decode('utf8')
        print(f'sig:{sig}')

        header = {
            'ContentType': 'application/json',
            'PG_API_KEY': 'd5a08d84603f5714914bf39915d198b501e8f389e31fe12ec6f18d7b906f5c0c',
            'PG_API_TIMESTAMP': timestamp,
            'PG_API_SIGNATURE': sig
        }

        # url = "http://192.168.10.174/api/withdraw/withdraw"
        url = "http://127.0.0.1:59001/querywithdraworder"
        rest = requests.post(url=url, json=data, headers=header)
        print(rest.text)

        pass
    def test_withdraw_order_post(self):

        REDIS_DEPOSIT_ADDRESS_POOL_NAME = 'deposit_address_sit'
        REDIS_HOST = '192.168.10.29'
        REDIS_PORT = 6379
        REDIS_DB_NAME = 1

        rds = redis.Redis(host=REDIS_HOST,
                          port=REDIS_PORT,
                          db=REDIS_DB_NAME,
                          decode_responses=True)

        req_count = 60 * 12
        n = 0
        # for i in range(req_count ):
        i = 0
        # token_list = ['HTDF', 'ETH', 'USDT']
        token_list = ['ETH', 'USDT']
        while True:

            # token = token_list[ i % 2]
            token = 'BTC'

            items = rds.srandmember(REDIS_DEPOSIT_ADDRESS_POOL_NAME, 1)
            to_address = ''
            if len(items) > 0:
                to_address = items[0]

            if str(to_address).startswith('htdf1') and token == 'HTDF':
                token_name = 'HTDF'
            elif str(to_address).startswith('0x'):
                if n % 5 == 0:
                    token = 'ETH'
                else:
                    token = 'USDT'
                token_name = token
                n += 1
            else:
                # print(f'invalid addresss:{to_address}')
                continue

            orderid = self.get_random_number_str(20)
            if (token_name) == "ETH":
                from_address = "0x13fd432b1e443f923065a3e48fc15a0ed270efcd"
                to_address = to_address
                amount = '0.10000001'  #str(random.uniform(0.01, 0.009))[:8]
            elif (token_name == "USDT"):
                from_address = "0x13fd432b1e443f923065a3e48fc15a0ed270efcd"
                to_address = to_address
                amount = '0.100002'  #str(random.uniform(0.1, 0.5))[:8]
            else:  #(token_name == "HTDF"):
                from_address = "htdf1vhq6c38demm58cnevc4sntc77z8ppvl85mj0a6"
                to_address = to_address
                amount = '0.10000001'  #str(random.uniform(0.1, 0.3))[:8]

            logging.info(
                f"from:{from_address}  ---> to:{to_address} amount:{amount}")
            logging.info(
                "orderid:%s, from_address:%s, to_address:%s==================== "
                % (orderid, from_address, to_address))
            data = {
                "order_id": orderid,
                "from_address": from_address,
                "to_address": to_address,
                "amount": amount,
                "token_name": token_name,
                "pro_id": 1,
                "callback_url": "http://192.168.10.29:8001/notify/withdraw"
            }

            jdata = json.dumps(data, separators=(',', ':'),
                               sort_keys=True)  # 按照key字母顺序排序

            # '1590040704197'
            timestamp = str(int(time.time() * 1000))
            # method  = 'POST'
            api_name = 'withdraw'

            param = '|'.join([timestamp, api_name, jdata])
            # print(param)

            msg = param.encode('utf8')
            sign_key = '9fb4d80781b34eac1b54f5631cc931133c42fd0decb2cda4738118996b416744'
            sig = sign_msg(sign_key=sign_key, msg=msg)
            sig = sig.decode('utf8')
            print(f'sig:{sig}')

            header = {
                # 'ContentType': 'application/json',
                'PG_API_KEY':
                '4575b80909ed0f2a09da77965f77b99a79b4182c66c7b51d002e134486bc1e97',
                'PG_API_TIMESTAMP': timestamp,
                'PG_API_SIGNATURE': sig
            }

            url = "http://192.168.10.174/api/withdraw/withdraw"
            # url = "http://192.168.10.29:8001/notify/withdraw"
            # url = "http://192.168.10.107:7778/api/withdraw/notifywithdraw"
            # url = "http://127.0.0.1:59002/withdraw"

            # import urllib3
            # import json

            # data = {'abc': '123'}
            # resp1 = urllib3.PoolManager(num_pools=5, headers=header)

            # resp1 = http.request('POST', url, fields=data)
            # resp1 = http.request('GET', 'http://www.httpbin.org/post', fields=data)

            # print(resp1.data.decode())

            rest = requests.post(url=url, json=data, headers=header)
            print(rest.text)

            # break
            #
            # ret_data = rest.json()
            # self.assertIsInstance(ret_data, dict)
            # self.assertIn('err_code', ret_data)
            # self.assertEqual(ret_data['err_code'], 0)
            #
            time.sleep(100)
            i += 1