Exemple #1
0
    def buyer_place_order(self, product, proxy):
        buyer_rsa_pubkey = self.rsa_public_key

        desc_hash = Encoder.str_to_base64_byte(product['msg_hash'])

        public_key = ECCipher.create_public_key(
            Encoder.hex_to_bytes(product['owner_address']))
        seller_addr = w3.toChecksumAddress(
            ECCipher.get_address_from_public_key(public_key))
        proxy = w3.toChecksumAddress(proxy)

        product = OrderInfo(desc_hash=desc_hash,
                            buyer_rsa_pubkey=buyer_rsa_pubkey,
                            seller=seller_addr,
                            proxy=proxy,
                            secondary_proxy=proxy,
                            proxy_value=100,
                            value=product['price'],
                            time_allowed=3600 * 24)

        w3.personal.unlockAccount(self.account.address, _passphrase)

        order_id = self.buyer_agent.place_order(product)
        # w3.personal.lockAccount(self.account.address)

        # return -1 if failure
        return order_id
Exemple #2
0
def get_public_key(public_key_string):
    pub_key_bytes = Encoder.hex_to_bytes(public_key_string)
    return ECCipher.create_public_key(pub_key_bytes)