コード例 #1
0
ファイル: test_settings.py プロジェクト: vesellov/PyWallet
 def test_get_set_stored_gas_price(self):
     """
     Checks default stored gas price and set method.
     """
     # checks default
     assert Settings.get_stored_gas_price() == 4
     # checks set
     Settings.set_stored_gas_price(42)
     assert Settings.get_stored_gas_price() == 42
コード例 #2
0
 def load_settings(self):
     """
     Load json store settings to UI properties.
     """
     self.is_stored_mainnet = Settings.is_stored_mainnet()
     self.is_stored_testnet = Settings.is_stored_testnet()
     self.stored_gas_price = Settings.get_stored_gas_price()
     is_persistent_keystore = (Settings.is_persistent_keystore()
                               and check_write_permission())
     self.set_persist_keystore_switch_state(is_persistent_keystore)
コード例 #3
0
    def unlock_send_transaction(self):
        """
        Unlocks the account with password in order to sign and publish the
        transaction.
        """
        controller = App.get_running_app().controller
        pywalib = controller.pywalib
        address = to_checksum_address(self.send_to_address)
        amount_eth = float(self.ids.send_amount_id.text)
        amount_wei = int(amount_eth * pow(10, 18))
        gas_price_gwei = Settings.get_stored_gas_price()
        gas_price_wei = int(gas_price_gwei * (10**9))
        account = controller.current_account
        Dialog.snackbar_message("Unlocking account...")
        try:
            account.unlock(self.password)
        except ValueError:
            Dialog.snackbar_message("Could not unlock account")
            return

        Dialog.snackbar_message("Unlocked! Sending transaction...")
        sender = account.address
        try:
            pywalib.transact(address,
                             value=amount_wei,
                             data='',
                             sender=sender,
                             gasprice=gas_price_wei)
        except InsufficientFundsException:
            Dialog.snackbar_message("Insufficient funds")
            return
        except UnknownEtherscanException:
            Dialog.snackbar_message("Unknown error")
            Logger.error('UnknownEtherscanException', exc_info=True)
            return
        # TODO: handle ConnectionError
        Dialog.snackbar_message("Sent!")