示例#1
0
 def create_account(self):
     """
     Creates an account from provided form.
     Verify we can unlock it.
     Disables widgets during the process, so the user doesn't try
     to create another account during the process.
     """
     # circular ref
     from pywallet.controller import Controller
     self.toggle_widgets(False)
     if not self.verify_fields():
         Dialog.show_invalid_form_dialog()
         self.toggle_widgets(True)
         return
     pywalib = self.controller.pywalib
     password = self.new_password1
     security_ratio = self.security_slider_value
     # dividing again by 10, because otherwise it's
     # too slow on smart devices
     security_ratio /= 10.0
     Dialog.snackbar_message("Creating account...")
     account = pywalib.new_account(password=password,
                                   security_ratio=security_ratio)
     Dialog.snackbar_message("Created!")
     self.toggle_widgets(True)
     Controller.set_account_alias(account, self.alias)
     self.on_account_created(account)
     CreateNewAccount.try_unlock(account, password)
     self.show_redirect_dialog()
     self.controller.load_landing_page()
     return account
示例#2
0
 def run_tests(self):
     """
     Loads the test suite and hook the callback for reporting progress.
     """
     # circular dep
     from pywallet.controller import Controller
     Controller.patch_keystore_path()
     test_suite = suite()
     self.stream_property = ""
     stream = StringIOCBWrite(callback_write=self.callback_write)
     verbosity = 2
     unittest.TextTestRunner(
             stream=stream, verbosity=verbosity).run(test_suite)
示例#3
0
 def load_changelog(self):
     # circular dep
     from pywallet.controller import Controller
     changelog_path = os.path.join(
         Controller.src_dir(),
         'CHANGELOG.md')
     with open(changelog_path, 'r') as f:
         self.changelog_text_property = f.read()
     f.close()
示例#4
0
 def on_address_property(self, instance, address):
     """
     Sets the address alias if it exists or defaults to the address itself.
     """
     # circular dep
     from pywallet.controller import Controller
     try:
         text = Controller.get_address_alias(address)
     except KeyError:
         text = address
     self.text = text
示例#5
0
 def __init__(self, account, **kwargs):
     """
     Setups the current alias for the given account.
     """
     # circular ref
     from pywallet.controller import Controller
     super(AliasForm, self).__init__(**kwargs)
     self.address = "0x" + account.address.hex()
     try:
         self.alias = Controller.get_address_alias(self.address)
     except KeyError:
         self.alias = ''
示例#6
0
 def create_item(self, account):
     """
     Creates an account list item from given account.
     """
     # circular ref
     from pywallet.controller import Controller
     address = "0x" + account.address.hex()
     # gets the alias if exists
     try:
         text = Controller.get_address_alias(address)
     except KeyError:
         text = address
     list_item = OneLineListItem(text=text)
     # makes sure the address doesn't overlap on small screen
     list_item.ids._lbl_primary.shorten = True
     list_item.account = account
     list_item.bind(on_release=lambda x: self.on_release(x))
     return list_item
示例#7
0
 def build(self):
     self.icon = "docs/images/icon.png"
     return Controller()