コード例 #1
0
 def proxy_claim_relay(self):
     proxy_trans = ProxyTrans(default_web3, config.chain.core_contract)
     private_key_file_path = join_with_root(config.wallet.private_key_file)
     password_path = join_with_root(config.wallet.private_key_password_file)
     with open(password_path) as f:
         password = f.read()
     priv_key, pub_key = ECCipher.geth_load_key_pair_from_private_key(
         private_key_file_path, password)
     priv_key_bytes = Encoder.str_to_base64_byte(priv_key)
     digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
     digest.update(
         ECCipher.generate_signature(priv_key_bytes,
                                     to_bytes(self.trade.order_id),
                                     password))
     deliver_hash = digest.finalize()
     tx_hash = proxy_trans.claim_relay(self.trade.order_id, deliver_hash)
     return tx_hash
コード例 #2
0
        message.type = Message.SELLER_DATA
        seller_data.order_id = 1
        seller_data.seller_addr = seller_public_key
        seller_data.buyer_addr = buyer_public_key
        seller_data.market_hash = b'MARKET_HASH'
        seller_data.AES_key = b'AES_key'
        storage = seller_data.storage
        storage.type = Message.Storage.IPFS
        ipfs = storage.ipfs
        ipfs.file_hash = b'QmT4kFS5gxzQZJwiDJQ66JLVGPpyTCF912bywYkpgyaPsD'
        ipfs.gateway = "192.168.0.132:5001"

        sign_message = SignMessage()
        sign_message.public_key = seller_public_key
        sign_message.data = message.SerializeToString()
        sign_message.signature = ECCipher.generate_signature(
            seller_private_key, sign_message.data)

        d = start_client(sign_message)

        d.addBoth(handle_proxy_response)
        d.addBoth(lambda _: reactor.stop())

    elif test_type == 'buyer_data':
        message = Message()
        buyer_data = message.buyer_data
        message.type = Message.BUYER_DATA
        buyer_data.order_id = 1
        buyer_data.seller_addr = seller_public_key
        buyer_data.buyer_addr = buyer_public_key
        buyer_data.market_hash = b'MARKET_HASH'