def __init__(self, address, creation_transaction):
     Address.__init__(self, address, creation_transaction)
     assert not self.transaction.to
     assert utils.add_0x_prefix(
         eth.utils.mk_contract_address(
             self.transaction.sender,
             self.transaction.nonce).hex()) == address.lower()
Beispiel #2
0
    def handle(self):
        commit = Commit()

        commit.opcode = "requested_loan_manager"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        oracle = self._args.get("_oracle")
        try:
            if oracle != "0x0000000000000000000000000000000000000000":
                oracle_contract = OracleInterface(oracle)
                currency = oracle_contract.currency()
            else:
                currency = loan_manager_interface.get_currency(
                    self._args.get('_id'))
                if currency:
                    currency = utils.add_0x_prefix(currency)
        except BadFunctionCallOutput:
            currency = "0x"

        print("currency: {}".format(currency))

        data = {
            "id": self._args.get("_id"),
            "open": True,
            "approved":
            self._args.get("_creator") == self._args.get("_borrower"),
            "position": "0",
            "expiration": str(self._args.get("_expiration")),
            "amount": str(self._args.get("_amount")),
            "cosigner": "0x0000000000000000000000000000000000000000",
            "model": self._args.get("_model"),
            "creator": self._args.get("_creator"),
            "oracle": self._args.get("_oracle"),
            "borrower": self._args.get("_borrower"),
            "callback": self._args.get("_callback"),
            "salt": str(self._args.get("_salt")),
            "loanData": self._args.get("_loanData"),
            "created": str(self._block_timestamp()),
            "currency": currency,
            "status": "0"
        }

        descriptor = loan_manager_interface.get_descriptor(data)

        data["descriptor"] = descriptor

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
Beispiel #3
0
 def _normalize(self):
     self._args["_id"] = utils.add_0x_prefix(self._args["_id"].hex())
 def __init__(self, address, out_transaction):
     Address.__init__(self, address, out_transaction)
     assert bool(self.transaction.to)
     assert utils.add_0x_prefix(self.transaction.sender.hex()) \
             == address.lower()
     assert self.owner_address == address.lower()
 def owner_address(self):
     return utils.add_0x_prefix(
         eth.utils.sha3(self.owner_public_key)[12:].hex())
Beispiel #6
0
                transaction = utils.web3tx_to_ethtx(transaction)
                address = ContractAddress(address_hex, 
                                            creation_transaction=transaction)
                print("Address: contract.")
            except FileNotFoundError:
                print("Error: Local Web3 node not found. Did you forget to start it?")
                exit(2)
            except AssertionError:
                print("Error: Transaction {} is not a creation "
                      "transaction.".format(options.sent_transaction))
        else:
            print("Error: Please specify either sent trasaction (-p) or creation transaction (-c) flag.")
            exit(1)

        encrypted_message = address.encrypt(message)
        print("Encrypted message: {}".format(utils.add_0x_prefix(utils.encode_hex(encrypted_message))))
        owner = utils.decode_hex(utils.remove_0x_prefix(address.owner_address))
        assert len(owner) == 20
        message_data = owner + encrypted_message + info_bytes()
        print("Message to send: {}".format(utils.add_0x_prefix(utils.encode_hex(message_data))))
        
        if options.send:
            print("Sending transaction to: {}".format(address_hex))
            sender_account = options.send_from
            if not utils.is_hex_address(sender_account):
                try:
                    sender_account = web3.personal.listAccounts[int(sender_account)]
                except ValueError:
                    print("Error: Invalid sender account. Should be your local Ethereum account "
                          "or its index number. See --list flag.")
                    exit(1)