Exemple #1
0
    def test_query_poe_err(self):

        mock_do_request = mock.Mock(return_value=(0, response_fail))
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(cert_store)
            _, resp = wc.query_poe({}, fromdid)
            self.assertEqual(resp["ErrCode"], 107)
Exemple #2
0
    def test_query_txn_logs_with_endpoint_succ(self):

        mock_do_request = mock.Mock(return_value=(0, response_succ))
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(cert_store)
            _, resp = wc.query_txn_logs_with_endpoint({}, "in", "endpoint001")
            self.assertEqual(resp["ErrCode"], 0)
    def test_register_err(self):
        """ Test register with error code. """

        mock_do_post = mock.Mock(return_value=Response(400, server_cipher))
        mock_run_cmd = mock.Mock(
            side_effect=[client_cipher,
                         json.dumps(response_fail)])
        with mock.patch('cryption.crypto.run_cmd', mock_run_cmd):
            with mock.patch('requests.post', mock_do_post):
                wc = WalletClient(cert_store)
                body = {
                    "id": "did:axn:21tDAKCERh95uGgKbJNHYp",
                    "type": "Organization",
                    "access": "xxxxx",
                    "secret": "xxxx",
                    "public_key": {
                        "usage":
                        "SignVerify",
                        "key_type":
                        "EdDsaPublicKey",
                        "public_key_data":
                        "dGhpcyBpcyBhIHB1YmxpYyBrZXl0aGlzIGlzIGEgcHVibGljIGtleXRoaXMgaXMgYSBwdWJsaWMga2V5dGhpcyBpcyBhIHB1YmxpYyBrZXl0aGlzIGlzIGEgcHVibGljIGtleXRoaXMgaXMgYSBwdWJsaWMga2V5dGhpcyBpcyBhIHB1YmxpYyBrZXk="
                    }
                }
                _, resp = wc.register({}, body)
                self.assertEqual(resp["ErrCode"], 107)
Exemple #4
0
 def test_query_txn_logs_with_id_err(self):
     mock_do_request = mock.Mock(return_value=(0, response_fail))
     with mock.patch('rest.api.api.Client.do_request', mock_do_request):
         wc = WalletClient(
                 cert_store
                 )
         _, resp = wc.query_txn_logs_with_id({}, "in", "yourID")
         self.assertEqual(resp["ErrCode"], 107)
Exemple #5
0
    def test_query_stxo_succ(self):
        """ Test query wallet tx stxo successfully returned. """

        mock_do_request = mock.Mock(return_value=(0, response_succ))
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(cert_store)
            id_ = "did:axn:2ef06aa4-05bb-4728-8882-343d42faeb8f"
            _, resp = wc.get_tx_stxo({}, id_, 0, 0)
            self.assertEqual(resp["ErrCode"], 0)
Exemple #6
0
    def test_query_stxo_err(self):
        """ Test query stxo with error code. """

        mock_do_request = mock.Mock(return_value=(0, response_fail))
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(cert_store)
            id_ = "did:axn:2ef06aa4-05bb-4728-8882-343d42faeb8f"
            _, resp = wc.get_tx_stxo({}, id_, 0, 0)
            self.assertEqual(resp["ErrCode"], 107)
Exemple #7
0
    def test_upload_poe_err(self):

        mock_do_prepare = mock.Mock(return_value=(0, response_fail))
        with mock.patch('rest.api.api.Client.do_prepare', mock_do_prepare):
            file_ = "{}/requirements.txt".format(os.getcwd())
            poeid = "poe id"
            readonly = "True"
            wc = WalletClient(cert_store)
            _, resp = wc.upload_poe({}, file_, poeid, readonly)
            self.assertEqual(resp["ErrCode"], 107)
    def test_query_wallet_infos_succ(self):
        """ Test query wallet infos successfully returned. """

        mock_do_get = mock.Mock(return_value=Response(200, server_cipher))
        mock_run_cmd = mock.Mock(return_value=json.dumps(response_succ))

        with mock.patch('cryption.crypto.run_cmd', mock_run_cmd):
            with mock.patch('requests.get', mock_do_get):
                wc = WalletClient(cert_store)
                id_ = "did:axn:2ef06aa4-05bb-4728-8882-343d42faeb8f"
                _, resp = wc.query_wallet_infos({}, id_)
                self.assertEqual(resp["ErrCode"], 0)
    def test_query_wallet_balance_err(self):
        """ Test query wallet balance with error code. """

        mock_do_get = mock.Mock(return_value=Response(400, server_cipher))
        mock_run_cmd = mock.Mock(return_value=json.dumps(response_fail))

        with mock.patch('cryption.crypto.run_cmd', mock_run_cmd):
            with mock.patch('requests.get', mock_do_get):
                wc = WalletClient(cert_store)
                id_ = "did:axn:2ef06aa4-05bb-4728-8882-343d42faeb8f"
                _, resp = wc.query_wallet_balance({}, id_)
                self.assertEqual(resp["ErrCode"], 107)
    def test_set_index_succ(self):
        """Test set index successfully returned. """

        mock_do_request = mock.Mock(return_value=(0, response_succ))
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(
                    cert_store
                    )
            indexs = {
                "combined_index": ["first_index", "second_index", "third_index"],
                "individual_index": ["individual_index_1", "individual_index_2", "individual_index_3"],
            }
            _, resp = wc.set_index({}, "did:arx:string1", indexs)
            self.assertEqual(resp["ErrCode"], 0)
    def test_get_index_err(self):
        """Test get index with error code. """

        mock_do_request = mock.Mock(return_value=(0, response_fail))
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(
                    cert_store
                    )
            indexs = {
                "combined_index": ["first_index", "second_index", "third_index"],
                "individual_index": ["individual_index_1", "individual_index_2", "individual_index_3"],
            }
            _, resp = wc.get_index({}, indexs)
            self.assertEqual(resp["ErrCode"], 107)
Exemple #12
0
    def test_issue_asset_err(self):
        """Test issue asset with error code. """

        mock_do_request = mock.Mock(side_effect=[(0, proposal_ctoken_succ), (0, response_fail)])
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(cert_store)
            body = {
                "payload": json.dumps(payload),
                "creator": did,
                "created": create_time,	
                "nonce": nonce,
                "privateB64": secret_key_b64
            }   
            _, resp = wc.issue_asset({}, payload, body)
            self.assertEqual(resp["ErrCode"], 107)
Exemple #13
0
    def test_update_poe_fail(self):
        """Test update poe with ed25519 signed body failed returned. """

        mock_do_request = mock.Mock(return_value=(0, response_fail))
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(cert_store)
            params = {
                "creator": fromdid,
                "created": create_time,
                "privateB64": secret_key_b64,
                "payload": payload,
                "nonce": ""
            }

            _, resp = wc.update_poe({}, payload, params)
            self.assertEqual(resp["ErrCode"], 107)
Exemple #14
0
    def test_transfer_colored_tokens_succ(self):
        """Test transfer colored token successfully returned. """

        mock_do_request = mock.Mock(
            side_effect=[(0, proposal_ctoken_succ), (0, response_succ)])
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(cert_store)
            body = {
                "payload": json.dumps(payload),
                "creator": did,
                "created": create_time,
                "nonce": nonce,
                "privateB64": secret_key_b64
            }
            _, resp = wc.transfer_colored_tokens({}, payload, body)
            self.assertEqual(resp["ErrCode"], 0)
Exemple #15
0
    def __init__(self):
        self.api_key = "IoZYarPTp1532411905"
        self.cert_path = "C:/Python27/Lib/site-packages/py_common-2.0.1-py2.7.egg/cryption/ecc/certs"
        self.ent_sign_param = {
            "creator": "did:axn:124d00f2-ea55-4724-8e58-31680d443628",
            "created": "",
            "nonce": "",
            "privateB64": "2RPpCLAl0CNiiXMLjUNSC1acqtkvU8+U9MtU2yvo4Vz52m8mW4+UrvqmFosxi/pu/AzpFf+CCQtutYCtKOZFoQ=="
        }
        self.ip_address = "http://139.198.15.132:9143"

        self.client = Client(self.api_key, self.cert_path, self.ent_sign_param, self.ip_address)
        self.wallet = WalletClient(self.client)
        self.header = {
            "Bc-Invoke-Mode": "sync"
        }
        self.message_center = "did:axn:af7380cb-2137-4c2d-a98e-62aba671f6df"
        self.permission_center = "did:axn:a20b40ff-ccff-4f7a-a839-acbde84b6a6e"
Exemple #16
0
    def test_register_succ(self):
        """ Test register successfully returned. """

        mock_do_request = mock.Mock(return_value=(0, response_succ))
        with mock.patch('rest.api.api.Client.do_request', mock_do_request):
            wc = WalletClient(cert_store)
            body={
                "id": "did:axn:21tDAKCERh95uGgKbJNHYp",
                "type": "Organization",
                "access": "xxxxx",
                "secret": "xxxx",
                "public_key":  {
                    "usage": "SignVerify",
                    "key_type": "EdDsaPublicKey",
                    "public_key_data": "dGhpcyBpcyBhIHB1YmxpYyBrZXl0aGlzIGlzIGEgcHVibGljIGtleXRoaXMgaXMgYSBwdWJsaWMga2V5dGhpcyBpcyBhIHB1YmxpYyBrZXl0aGlzIGlzIGEgcHVibGljIGtleXRoaXMgaXMgYSBwdWJsaWMga2V5dGhpcyBpcyBhIHB1YmxpYyBrZXk="
                }
            }
            _, resp = wc.register({}, body)
            self.assertEqual(resp["ErrCode"], 0)
Exemple #17
0
 def __init__(self, ):
     #self.apikey = apikey
     #self.cert_path = cert_path
     #self.ip_addr = ip_addr
     with open('api_data.csv', 'rb', encoding='utf-8') as f:
         reader = csv.DictReader(f)
         js = dict(reader)
     self.apikey = js['apikey']
     self.cert_path = js['cert_path']
     self.ip_addr = js['ip_addr']
     self.__creator = js['creator']
     self.__created = js['created']
     self.__nonce = js['nonce']
     self.__privateB64 = js['privateB64']
     self.ent_sign_param = {
         "creator": self.__creator,
         "created": self.__created,
         "nonce": self.__nonce,
         "privateB64": self.__privateB64
     }
     self.client = Client(self.apikey, self.cert_path, self.ent_sign_param,
                          self.ip_addr)
     self.walletclient = WalletClient(self.client)
     self.header = {"Bc-Invoke-Mode": "sync"}
from rest.api.api import Client
from api.wallet import WalletClient
apikey = "JTZdtpNTp1540767548"
cert_path = "/usr/local/lib/python2.7/site-packages/py_common-2.0.1-py2.7.egg/cryption/ecc/certs"
ip_addr = "http://139.198.15.132:9143"
ent_sign_param = {
    "creator":
    "did:axn:bcaad1cb-e1f2-415b-b110-1fb4da5a08a2",
    "nonce":
    "ubiright",
    "privateB64":
    "SELx1xc9ad83Ixa10lXU96pFq7mn4OAFMuuU5uGXtQx8e3+TF6ulYl0xsbVnGQOShKaPqY7We4tjTZ4wOkn6dw=="
}
client = Client(apikey, cert_path, ent_sign_param, ip_addr)
walletClient = WalletClient(client)
Exemple #19
0
ent_sign_param = {
    "creator":
    "did:axn:17e8db57-a0fa-4028-b17f-802d01602194",
    "nonce":
    "0",
    "privateB64":
    "lgdYjMbh7BKCeGxmJrempaP+/cDGMy5StdjM4ZexB0/Ku8V1uI81OlhKdnsCJVqTrXe2vGWKtXR+ciuozCgqjQ=="
}

client = Client(
    "qYIwhZPTp1532489219",  # eg: "z_pGym-Tp15288809805" # 企业用户申请的API-KEY
    "/usr/local/lib/python2.7/dist-packages/py_common-2.0.1-py2.7.egg/cryption/ecc/certs",  # eg: /usr/local/lib/python2.7/site-packages/py_common-1.5.0-py2.7.egg/cryption/ecc/certs
    ent_sign_param,
    "http://139.198.15.132:9143")

walletclient = WalletClient(client)

# header {"Bc-Invoke-Mode": "sync"} for sync invoke mode. {} or header {"Bc-Invoke-Mode": "async"} for async invoke mode.
# read wallet-sdk-py README "Using callback URL to receive blockchain transaction event" for more details
header = {"Bc-Invoke-Mode": "sync"}
payload = {
    "issuer": "did:axn:17e8db57-a0fa-4028-b17f-802d01602194",  # 数字凭证的发行方钱包DID
    "owner":
    "did:axn:17e8db57-a0fa-4028-b17f-802d01602194",  # 数字资产的持有人钱包ID,如企业用户钱包DID(did:axn:***2fc68-f51e-4aff-b6e4-427cce3ed1af)
    "asset_id":
    "did:axn:9b906590-1c93-4734-8cf6-473995fbdfca",  # 创建数字资产存证接口返回的poe_id,如:did:axn:***a94a9-eff4-4f15-88bf-f2054701e87c
    "amount": 2000,  # 发行金额
    "fee": {
        "amount": 10
    }  # 发行手续费、可不填
}
Exemple #20
0
ent_sign_param = {
    "creator":
    "did:axn:17e8db57-a0fa-4028-b17f-802d01602194",
    "nonce":
    "0",
    "privateB64":
    "lgdYjMbh7BKCeGxmJrempaP+/cDGMy5StdjM4ZexB0/Ku8V1uI81OlhKdnsCJVqTrXe2vGWKtXR+ciuozCgqjQ=="
}

client = Client(
    "qYIwhZPTp1532489219",  # eg: "z_pGym-Tp15288809805" # 企业用户申请的API-KEY
    "/usr/local/lib/python2.7/dist-packages/py_common-2.0.1-py2.7.egg/cryption/ecc/certs",  # eg: /usr/local/lib/python2.7/site-packages/py_common-1.5.0-py2.7.egg/cryption/ecc/certs
    ent_sign_param,
    "http://139.198.15.132:9143")

walletclient = WalletClient(client)

# header {"Bc-Invoke-Mode": "sync"} for sync invoke mode. {} or header {"Bc-Invoke-Mode": "async"} for async invoke mode.
# read wallet-sdk-py README "Using callback URL to receive blockchain transaction event" for more details
header = {"Bc-Invoke-Mode": "sync"}

payload = {
    "from":
    "did:axn:17e8db57-a0fa-4028-b17f-802d01602194",  # 转出方did
    "to":
    "did:axn:cac77e46-96ca-4021-a591-7e2605b7b505",  # 转入方did
    "asset_id":
    "",
    "tokens": [{
        "token_id":
        "ab8bef8523bdd7c6e95c30818d985f3b4d7ab4bf1ffbfaa90d5415eb7782fb6b",  # 企业用户发行企业积分发行数字凭证时,返回的token_id
Exemple #21
0
class WalletInit():
    def __init__(self, ):
        #self.apikey = apikey
        #self.cert_path = cert_path
        #self.ip_addr = ip_addr
        with open('api_data.csv', 'rb', encoding='utf-8') as f:
            reader = csv.DictReader(f)
            js = dict(reader)
        self.apikey = js['apikey']
        self.cert_path = js['cert_path']
        self.ip_addr = js['ip_addr']
        self.__creator = js['creator']
        self.__created = js['created']
        self.__nonce = js['nonce']
        self.__privateB64 = js['privateB64']
        self.ent_sign_param = {
            "creator": self.__creator,
            "created": self.__created,
            "nonce": self.__nonce,
            "privateB64": self.__privateB64
        }
        self.client = Client(self.apikey, self.cert_path, self.ent_sign_param,
                             self.ip_addr)
        self.walletclient = WalletClient(self.client)
        self.header = {"Bc-Invoke-Mode": "sync"}

    def Err(self, p):
        self.__p = p
        print "失败,原因是", self.__p["ErrMessage"], "错误码:", self.__p["ErrCode"]

    #注册钱包
    def register(self, id_number, access, secret, usertype, save=0):
        self.__access = access
        self.__id = id_number  #填身份证号码
        self.__password = secret
        self.__type = usertype  #"Organization" / "Person" / "Dependent" / "Independent"
        self.__save = save
        self.__body = {
            "id": "",
            "access": self.__access,  #钱包用户名称
            "password":
            self.__password,  #钱包登录口令 (由8-16位英文大小写字母和数字组成,必须同时包含大小写字母和数字)
            "type": self.__type,  #建议用复选框传字符串进来,选项在下方注释  
            "public_key": {  #如果没有提供,则由服务自动生成
                "usage": "",  #公钥的使用用途
                "key_type": "",  #公钥的类型
                "public_key_data": ""  #钱包公钥(ED25519,Base64编码)
            }
        }

        _, r = self.walletclient.register(self.header, self.__body)
        print "您的信息为\n", r
        if (self.__save == 1):
            with open('wallet_did.txt', "wb") as f:
                json.dump(r, f)  #注册完成后用户名密码和did会被存放在工作目录下一个叫wallet_did.txt的文件中
        #print "请妥善保管您的用户名、密码、id和did\n"

    def login(self, access=None, secret=None, did=None):
        self.__access = access
        self.__secret = secret
        self.__did = did
        body = {"credential": {"value": {"access": access, "secret": secret}}}
        r = requests.post(ip_addr + "/fred/v1/auth/token", json=body)
        p = json.loads(r.text)
        if p["ErrCode"] == 0:
            # print "登录成功,信息为:",p
            with open('login.json', 'wb') as f:
                f.write(r.text)
            with open('cache/login_temp.json', 'wb') as f:
                json.dump(
                    json.dumps({
                        "access": self.__access,
                        "secret": self.__secret,
                        "did": self.__did
                    }), f)
            return p["token"]["value"]
        else:
            #失败,重新登陆
            pass

    #查询区块详情
    #XAuthToken,DID = login()
    #XAuthToken = json.load(login)["token"]["value"]
    def query_block_detials(self, XAuthToken, BlockCode):
        self.__XAuthToken = XAuthToken
        self.__BlockCode = BlockCode  #传入区块编号
        #n=raw_input("输入区块编号:")
        self.__headers = {'X-Auth-Token': self.__XAuthToken}
        r = requests.get(ip_addr +
                         "/chain-monitor/v1/chain/block_detail?height=" +
                         self.__BlockCode,
                         headers=self.__headers)
        return r

    #"查询交易详情"
    def query_transaction_details(self, transaction_id):
        print
        self.__transaction_id = transaction_id  #交易ID
        _, resp = self.walletclient.query_txn_logs_with_id(
            {"Bc-Invoke-Mode": "sync"},
            type_="",
            id_=transaction_id,
        )  # 交易ID
        print resp.text

    '''
Exemple #22
0
class ClientPart:
    def __init__(self):
        self.api_key = "IoZYarPTp1532411905"
        self.cert_path = "C:/Python27/Lib/site-packages/py_common-2.0.1-py2.7.egg/cryption/ecc/certs"
        self.ent_sign_param = {
            "creator": "did:axn:124d00f2-ea55-4724-8e58-31680d443628",
            "created": "",
            "nonce": "",
            "privateB64": "2RPpCLAl0CNiiXMLjUNSC1acqtkvU8+U9MtU2yvo4Vz52m8mW4+UrvqmFosxi/pu/AzpFf+CCQtutYCtKOZFoQ=="
        }
        self.ip_address = "http://139.198.15.132:9143"

        self.client = Client(self.api_key, self.cert_path, self.ent_sign_param, self.ip_address)
        self.wallet = WalletClient(self.client)
        self.header = {
            "Bc-Invoke-Mode": "sync"
        }
        self.message_center = "did:axn:af7380cb-2137-4c2d-a98e-62aba671f6df"
        self.permission_center = "did:axn:a20b40ff-ccff-4f7a-a839-acbde84b6a6e"

    def sign_up(self, access, secret, entity_type, name, country):
        body = {
            "id": "did:axn:kwsxz" + access,
            "type": entity_type,
            "access": access,
            "secret": secret
        }
        _, response = self.wallet.register(self.header, body)
        if response["ErrCode"] == 0:
            key_pair = json.loads(response["Payload"])["key_pair"]
            private_key = key_pair["private_key"]

            message = {
                "name": name,
                "country": country
            }

            response_poe = self.__create_poe(access, private_key, message)
            poe_did = json.loads(response_poe["Payload"])["id"]

            response_message = self.__query_poe_to_json(self.message_center)
            response_message[access] = {
                "POEdid": poe_did,
                "key_pair": key_pair
            }
            self.__update_poe_metadata(response_message, self.message_center, "MessageBox",
                                       self.ent_sign_param["creator"],
                                       self.ent_sign_param["privateB64"])
            return response
        else:
            return None

    def log_in(self, access, secret):
        response = requests.post(url="http://139.198.15.132:9143/fred/v1/auth/token", json={
            "credential": {
                "value": {
                    "access": access,
                    "secret": secret
                }
            }
        })
        return response.json()

    def query_personal_message(self, access):
        try:
            personal_poe_did = self.__query_poe_to_json(self.message_center)[access]["POEdid"]
        except Exception:
            return None
        else:
            return self.__query_poe_to_json(personal_poe_did)

    def update_personal_message(self, access, message):
        try:
            personal_value = self.__query_poe_to_json(self.message_center)[access]
        except Exception:
            return None
        else:
            return self.__update_poe_metadata(message, personal_value["POEdid"], "PersonalMessage",
                                              "did:axn:kwsxz" + access,
                                              personal_value["key_pair"]["private_key"])

    def ask_other_message(self, self_access, other_access):

        response = self.__query_poe_to_json(self.permission_center)
        if other_access in response:
            for x in response[other_access]:
                if x["userAccess"] == self_access:
                    return x["permitList"]
            response[other_access].append({
                "userAccess": self_access,
                "permitList": []
            })
        else:
            response[other_access] = []
        self.__update_poe_metadata(response, self.permission_center, "PermissionBox", self.ent_sign_param["creator"],
                                   self.ent_sign_param["privateB64"])

    def update_permission_list(self, access, permit_list, other_access):

        response = self.__query_poe_to_json(self.permission_center)
        if access in response:
            found = False
            for x in response[access]:  # jsonArray
                if x["userAccess"] == other_access:
                    x["permitList"] = permit_list
                    found = True
            if not found:
                response[access].append({
                    "userAccess": other_access,
                    "permitList": permit_list
                })
        else:
            response[access] = [{
                "userAccess":other_access,
                "permitList":permit_list
            }]
        self.__update_poe_metadata(response, self.permission_center, "PermissionBox", self.ent_sign_param["creator"],
                                   self.ent_sign_param["privateB64"])

    def query_personal_permission(self, access):
        json_object = self.__query_poe_to_json(self.permission_center)
        ls = []
        if access in json_object:
            for x in json_object[access]:
                ls.append(x["userAccess"])
            return ls
        else:
            return None

    def __create_poe(self, access, private_key, message):
        pay_load = {
            "name": "PersonalMessage",
            "owner": "did:axn:kwsxz" + access,
            "metadata": base64.b64encode(json.dumps(message))
        }
        parameter = {
            "creator": self.ent_sign_param["creator"],
            "created": "",
            "nonce": "",
            "privateB64": private_key,
            "payload": pay_load,
        }
        _, response = self.wallet.create_poe(self.header, pay_load, parameter)
        return response

    def __query_poe_to_json(self, poe_did):
        _, response = self.wallet.query_poe(self.header, poe_did)
        return json.loads(base64.b64decode(json.loads(response["Payload"])["metadata"]))

    def __update_poe_metadata(self, message, poe_did, name, did, private_key):
        payload = {
            "id": poe_did,
            "name": name,
            "owner": did,
            "metadata": base64.b64encode(json.dumps(message))
        }
        parameter = {
            "creator": self.ent_sign_param["creator"],
            "created": "",
            "nonce": "",
            "privateB64": private_key,
            "payload": payload,
        }
        _, response = self.wallet.update_poe(self.header, payload, parameter)
        return response
Exemple #23
0
# coding=utf-8
import time
from api.wallet import WalletClient
import json
from rest.api.api import Client
ent_sign_param = {
    "creator": "did:axn:17e8db57-a0fa-4028-b17f-802d01602194",
    "nonce": "0",
    "privateB64": "lgdYjMbh7BKCeGxmJrempaP+/cDGMy5StdjM4ZexB0/Ku8V1uI81OlhKdnsCJVqTrXe2vGWKtXR+ciuozCgqjQ=="
}

client = Client(
    "qYIwhZPTp1532489219", # eg: "z_pGym-Tp15288809805" # 企业用户申请的API-KEY
    "/usr/local/lib/python2.7/dist-packages/py_common-2.0.1-py2.7.egg/cryption/ecc/certs", # eg: /usr/local/lib/python2.7/site-packages/py_common-1.5.0-py2.7.egg/cryption/ecc/certs
    ent_sign_param,
    "http://139.198.15.132:9143")

walletclient = WalletClient(client)

# header {"Bc-Invoke-Mode": "sync"} for sync invoke mode. {} or header {"Bc-Invoke-Mode": "async"} for async invoke mode.
# read wallet-sdk-py README "Using callback URL to receive blockchain transaction event" for more details
header = {"Bc-Invoke-Mode": "sync"}
_, resp = walletclient.query_wallet_balance({"Bc-Invoke-Mode":"sync"}, "did:axn:17e8db57-a0fa-4028-b17f-802d01602194")
print resp
Exemple #24
0
# coding=utf-8
from api.wallet import WalletClient
import json
from rest.api.api import Client
ent_sign_param = {
    "creator": "did:axn:17e8db57-a0fa-4028-b17f-802d01602194",
    "nonce": "0",
    "privateB64": "lgdYjMbh7BKCeGxmJrempaP+/cDGMy5StdjM4ZexB0/Ku8V1uI81OlhKdnsCJVqTrXe2vGWKtXR+ciuozCgqjQ=="
}

client = Client(
    "qYIwhZPTp1532489219", # eg: "z_pGym-Tp15288809805" # 企业用户申请的API-KEY
    "/usr/local/lib/python2.7/dist-packages/py_common-2.0.1-py2.7.egg/cryption/ecc/certs", # eg: /usr/local/lib/python2.7/site-packages/py_common-1.5.0-py2.7.egg/cryption/ecc/certs
    ent_sign_param,
    "http://139.198.15.132:9143")

walletclient = WalletClient(client)

# header {"Bc-Invoke-Mode": "sync"} for sync invoke mode. {} or header {"Bc-Invoke-Mode": "async"} for async invoke mode.
# read wallet-sdk-py README "Using callback URL to receive blockchain transaction event" for more details
header = {"Bc-Invoke-Mode": "sync"}
body = {
    "access": "test06", # 普通用户用户名, 长度为4-36位
    "secret": "Integrate1230", # 普通用户密码, 由8-16位英文大小写字母和数字组成,必须同时包含大小写字母和数字
    "type": "Person", # 类型
    "id": ""} # id可以为空,由系统自动生成
_,response = walletclient.register(header,body)
print response
Exemple #25
0
import json
import time
from rest.api.api import Client
ent_sign_param = {
    "creator": "did:axn:17e8db57-a0fa-4028-b17f-802d01602194",
    "nonce": "0",
    "privateB64": "lgdYjMbh7BKCeGxmJrempaP+/cDGMy5StdjM4ZexB0/Ku8V1uI81OlhKdnsCJVqTrXe2vGWKtXR+ciuozCgqjQ=="
}

client = Client(
    "qYIwhZPTp1532489219", # eg: "z_pGym-Tp15288809805" # 企业用户申请的API-KEY
    "/usr/local/lib/python2.7/dist-packages/py_common-2.0.1-py2.7.egg/cryption/ecc/certs", # eg: /usr/local/lib/python2.7/site-packages/py_common-1.5.0-py2.7.egg/cryption/ecc/certs
    ent_sign_param,
    "http://139.198.15.132:9143")

walletclient = WalletClient(client)

# header {"Bc-Invoke-Mode": "sync"} for sync invoke mode. {} or header {"Bc-Invoke-Mode": "async"} for async invoke mode.
# read wallet-sdk-py README "Using callback URL to receive blockchain transaction event" for more details
header = {"Bc-Invoke-Mode": "sync"}
payload = {
    "id": "", # 若传的数字存证id是空,则系统会自动生成
    "name": "POE_ID_01", # poe name
    "hash": "",
    "parent_id": "",
    "owner": "did:axn:17e8db57-a0fa-4028-b17f-802d01602194", # 企业用户钱包DID,如:did:axn:***2fc68-f51e-4aff-b6e4-427cce3ed1af
    "metadata": "GhaHjjdmN2VkNGU5M2NhMzk1MmM4NDgzZGNlN2Y4YTExZmRmOTEyNmU2ZTU2NWMzNzk3MTA1NjkzMWRiMjBkZjEy" # metadata的数据格式是byte数组,需要将json格式的数据进行处理, 如 [ord(x) for x in json.dumps(json格式的metadata数据)]
}

params = {
    "creator": "did:axn:17e8db57-a0fa-4028-b17f-802d01602194", # 企业用户钱包DID,如:did:axn:***2fc68-f51e-4aff-b6e4-427cce3ed1af