Exemplo n.º 1
0
 def restore(self, t):
     if t == 'standard':
         text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
         if not text:
             return
         password = self.password_dialog() if Wallet.is_seed(text) or Wallet.is_xprv(text) or Wallet.is_private_key(text) else None
         wallet = Wallet.from_text(text, password, self.storage)
     elif re.match('(\d+)of(\d+)', t):
         n = int(re.match('(\d+)of(\d+)', t).group(2))
         key_list = self.multi_seed_dialog(n - 1)
         if not key_list:
             return
         password = self.password_dialog() if any(map(lambda x: Wallet.is_seed(x) or Wallet.is_xprv(x), key_list)) else None
         wallet = Wallet.from_multisig(key_list, password, self.storage, t)
     else:
         self.storage.put('wallet_type', t, False)
         # call the constructor to load the plugin (side effect)
         Wallet(self.storage)
         wallet = always_hook('installwizard_restore', self, self.storage)
         if not wallet:
             util.print_error("no wallet")
             return
     # create first keys offline
     self.waiting_dialog(wallet.synchronize)
     return wallet
Exemplo n.º 2
0
 def restore(self, t):
     if t == 'standard':
         text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
         if not text:
             return
         password = self.password_dialog(
         ) if Wallet.is_seed(text) or Wallet.is_xprv(
             text) or Wallet.is_private_key(text) else None
         wallet = Wallet.from_text(text, password, self.storage)
     elif re.match('(\d+)of(\d+)', t):
         n = int(re.match('(\d+)of(\d+)', t).group(2))
         key_list = self.multi_seed_dialog(n - 1)
         if not key_list:
             return
         password = self.password_dialog() if any(
             map(lambda x: Wallet.is_seed(x) or Wallet.is_xprv(x),
                 key_list)) else None
         wallet = Wallet.from_multisig(key_list, password, self.storage, t)
     else:
         self.storage.put('wallet_type', t, False)
         # call the constructor to load the plugin (side effect)
         Wallet(self.storage)
         wallet = always_hook('installwizard_restore', self, self.storage)
         if not wallet:
             util.print_error("no wallet")
             return
     # create first keys offline
     self.waiting_dialog(wallet.synchronize)
     return wallet
Exemplo n.º 3
0
    def on_verify_restore_ok(self, wallet, _dlg, btn, restore=False):
        if btn in (_dlg.ids.back, _dlg.ids.but_close) :
            _dlg.close()
            Factory.CreateRestoreDialog(
                on_release=self.on_creatrestore_complete).open()
            return

        seed = self.get_seed_text(_dlg.ids.text_input_seed)
        if not seed:
            return app.show_error(_("No seed!"), duration=.5)

        _dlg.close()

        if Wallet.is_seed(seed):
            return self.password_dialog(wallet=wallet, mode='restore',
                                        seed=seed)
        elif Wallet.is_xpub(seed):
            wallet = Wallet.from_xpub(seed, self.storage)
        elif Wallet.is_address(seed):
            wallet = Wallet.from_address(seed, self.storage)
        elif Wallet.is_private_key(seed):
            wallet = Wallet.from_private_key(seed, self.storage)
        else:
            return app.show_error(_('Not a valid seed. App will now exit'),
                                  exit=True, modal=True, duration=.5)
        return
Exemplo n.º 4
0
    def on_verify_restore_ok(self, wallet, _dlg, btn, restore=False):
        if btn in (_dlg.ids.back, _dlg.ids.but_close):
            _dlg.close()
            Factory.CreateRestoreDialog(
                on_release=self.on_creatrestore_complete).open()
            return

        seed = self.get_seed_text(_dlg.ids.text_input_seed)
        if not seed:
            return app.show_error(_("No seed!"), duration=.5)

        _dlg.close()

        if Wallet.is_seed(seed):
            return self.password_dialog(wallet=wallet,
                                        mode='restore',
                                        seed=seed)
        elif Wallet.is_mpk(seed):
            wallet = Wallet.from_mpk(seed, self.storage)
        elif Wallet.is_address(seed):
            wallet = Wallet.from_address(seed, self.storage)
        elif Wallet.is_private_key(seed):
            wallet = Wallet.from_private_key(seed, self.storage)
        else:
            return app.show_error(_('Not a valid seed. App will now exit'),
                                  exit=True,
                                  modal=True,
                                  duration=.5)
        return
Exemplo n.º 5
0
    def restore(self, t):

        if t == "standard":
            text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
            if not text:
                return
            if Wallet.is_xprv(text):
                password = self.password_dialog()
                wallet = Wallet.from_xprv(text, password, self.storage)
            elif Wallet.is_old_mpk(text):
                wallet = Wallet.from_old_mpk(text, self.storage)
            elif Wallet.is_xpub(text):
                wallet = Wallet.from_xpub(text, self.storage)
            elif Wallet.is_address(text):
                wallet = Wallet.from_address(text, self.storage)
            elif Wallet.is_private_key(text):
                password = self.password_dialog()
                wallet = Wallet.from_private_key(text, password, self.storage)
            elif Wallet.is_seed(text):
                password = self.password_dialog()
                wallet = Wallet.from_seed(text, password, self.storage)
            else:
                raise BaseException("unknown wallet type")

        elif re.match("(\d+)of(\d+)", t):
            n = int(re.match("(\d+)of(\d+)", t).group(2))
            key_list = self.multi_seed_dialog(n - 1)
            if not key_list:
                return
            password = (
                self.password_dialog() if any(map(lambda x: Wallet.is_seed(x) or Wallet.is_xprv(x), key_list)) else None
            )
            wallet = Wallet.from_multisig(key_list, password, self.storage, t)

        else:
            self.storage.put("wallet_type", t, False)
            # call the constructor to load the plugin (side effect)
            Wallet(self.storage)
            wallet = always_hook("installwizard_restore", self, self.storage)
            if not wallet:
                util.print_error("no wallet")
                return

        # create first keys offline
        self.waiting_dialog(wallet.synchronize)

        return wallet
Exemplo n.º 6
0
 def task():
     if Wallet.is_seed(text):
         self.wallet.add_seed(text, password)
         self.wallet.create_master_keys(password)
     else:
         self.wallet = Wallet.from_text(text, None, self.storage)
     self.wallet.create_main_account()
     self.wallet.synchronize()
Exemplo n.º 7
0
 def is_any(self, seed_e):
     text = self.get_seed_text(seed_e)
     return (Wallet.is_seed(text) or
             Wallet.is_old_mpk(text) or
             Wallet.is_xpub(text) or
             Wallet.is_xprv(text) or
             Wallet.is_address(text) or
             Wallet.is_private_key(text))
Exemplo n.º 8
0
 def task():
     if Wallet.is_seed(text):
         self.wallet.add_seed(text, password)
         self.wallet.create_master_keys(password)
     else:
         self.wallet = Wallet.from_text(text, None, self.storage)
     self.wallet.create_main_account()
     self.wallet.synchronize()
    def __init__(self, _config, _network, plugins):
        global wallet, network, contacts, config
        network = _network
        config = _config
        network.register_callback('updated', update_callback)
        network.register_callback('connected', update_callback)
        network.register_callback('disconnected', update_callback)
        network.register_callback('disconnecting', update_callback)

        contacts = util.StoreDict(config, 'contacts')

        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists:
            action = self.restore_or_create()
            if not action:
                exit()

            password = droid.dialogGetPassword('Choose a password').result
            if password:
                password2 = droid.dialogGetPassword('Confirm password').result
                if password != password2:
                    modal_dialog('Error', 'passwords do not match')
                    exit()
            else:
                # set to None if it's an empty string
                password = None

            if action == 'create':
                wallet = Wallet(storage)
                seed = wallet.make_seed()
                modal_dialog('Your seed is:', seed)
                wallet.add_seed(seed, password)
                wallet.create_master_keys(password)
                wallet.create_main_account(password)
            elif action == 'restore':
                seed = self.seed_dialog()
                if not seed:
                    exit()
                if not Wallet.is_seed(seed):
                    exit()
                wallet = Wallet.from_seed(seed, password, storage)
            else:
                exit()

            msg = "Creating wallet" if action == 'create' else "Restoring wallet"
            droid.dialogCreateSpinnerProgress("Electrum", msg)
            droid.dialogShow()
            wallet.start_threads(network)
            if action == 'restore':
                wallet.wait_until_synchronized()
            else:
                wallet.synchronize()
            droid.dialogDismiss()
            droid.vibrate()

        else:
            wallet = Wallet(storage)
            wallet.start_threads(network)
Exemplo n.º 10
0
    def __init__(self, _config, _network, plugins):
        global wallet, network, contacts, config
        network = _network
        config = _config
        network.register_callback('updated', update_callback)
        network.register_callback('connected', update_callback)
        network.register_callback('disconnected', update_callback)
        network.register_callback('disconnecting', update_callback)

        contacts = util.StoreDict(config, 'contacts')

        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists:
            action = self.restore_or_create()
            if not action:
                exit()

            password = droid.dialogGetPassword('Choose a password').result
            if password:
                password2 = droid.dialogGetPassword('Confirm password').result
                if password != password2:
                    modal_dialog('Error', 'passwords do not match')
                    exit()
            else:
                # set to None if it's an empty string
                password = None

            if action == 'create':
                wallet = Wallet(storage)
                seed = wallet.make_seed()
                modal_dialog('Your seed is:', seed)
                wallet.add_seed(seed, password)
                wallet.create_master_keys(password)
                wallet.create_main_account(password)
            elif action == 'restore':
                seed = self.seed_dialog()
                if not seed:
                    exit()
                if not Wallet.is_seed(seed):
                    exit()
                wallet = Wallet.from_seed(seed, password, storage)
            else:
                exit()

            msg = "Creating wallet" if action == 'create' else "Restoring wallet"
            droid.dialogCreateSpinnerProgress("Electrum", msg)
            droid.dialogShow()
            wallet.start_threads(network)
            if action == 'restore':
                wallet.restore(lambda x: None)
            else:
                wallet.synchronize()
            droid.dialogDismiss()
            droid.vibrate()

        else:
            wallet = Wallet(storage)
            wallet.start_threads(network)
Exemplo n.º 11
0
 def is_any(self, text):
     return (
         Wallet.is_seed(text)
         or Wallet.is_old_mpk(text)
         or Wallet.is_xpub(text)
         or Wallet.is_xprv(text)
         or Wallet.is_address(text)
         or Wallet.is_private_key(text)
     )
Exemplo n.º 12
0
    def restore(self, t):

            if t == 'standard':
                text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
                if not text:
                    return
                if Wallet.is_xprv(text):
                    password = self.password_dialog()
                    wallet = Wallet.from_xprv(text, password, self.storage)
                elif Wallet.is_old_mpk(text):
                    wallet = Wallet.from_old_mpk(text, self.storage)
                elif Wallet.is_xpub(text):
                    wallet = Wallet.from_xpub(text, self.storage)
                elif Wallet.is_address(text):
                    wallet = Wallet.from_address(text, self.storage)
                elif Wallet.is_private_key(text):
                    password = self.password_dialog()
                    wallet = Wallet.from_private_key(text, password, self.storage)
                elif Wallet.is_seed(text):
                    password = self.password_dialog()
                    wallet = Wallet.from_seed(text, password, self.storage)
                else:
                    raise BaseException('unknown wallet type')

            elif t in ['2of2', '2of3']:
                key_list = self.multi_seed_dialog(1 if t == '2of2' else 2)
                if not key_list:
                    return
                password = self.password_dialog() if any(map(lambda x: Wallet.is_seed(x) or Wallet.is_xprv(x), key_list)) else None
                wallet = Wallet.from_multisig(key_list, password, self.storage)

            else:
                self.storage.put('wallet_type', t, False)
                # call the constructor to load the plugin (side effect)
                Wallet(self.storage)
                wallet = always_hook('installwizard_restore', self, self.storage)
                if not wallet:
                    util.print_error("no wallet")
                    return

            # create first keys offline
            self.waiting_dialog(wallet.synchronize)

            return wallet
Exemplo n.º 13
0
    def restore(self, t):

        if t == 'standard':
            text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
            if not text:
                return
            if Wallet.is_xprv(text):
                password = self.password_dialog()
                wallet = Wallet.from_xprv(text, password, self.storage)
            elif Wallet.is_old_mpk(text):
                wallet = Wallet.from_old_mpk(text, self.storage)
            elif Wallet.is_xpub(text):
                wallet = Wallet.from_xpub(text, self.storage)
            elif Wallet.is_address(text):
                wallet = Wallet.from_address(text, self.storage)
            elif Wallet.is_private_key(text):
                password = self.password_dialog()
                wallet = Wallet.from_private_key(text, password, self.storage)
            elif Wallet.is_seed(text):
                password = self.password_dialog()
                wallet = Wallet.from_seed(text, password, self.storage)
            else:
                raise BaseException('unknown wallet type')

        elif t in ['2of2', '2of3']:
            key_list = self.multi_seed_dialog(1 if t == '2of2' else 2)
            if not key_list:
                return
            password = self.password_dialog() if any(
                map(lambda x: Wallet.is_seed(x) or Wallet.is_xprv(x),
                    key_list)) else None
            wallet = Wallet.from_multisig(key_list, password, self.storage)

        else:
            self.storage.put('wallet_type', t)
            wallet = always_hook('installwizard_restore', self, self.storage)
            if not wallet:
                return

        # create first keys offline
        self.waiting_dialog(wallet.synchronize)

        return wallet
Exemplo n.º 14
0
    def __init__(self, _config, _network, daemon, plugins):
        global wallet, network, contacts, config
        network = _network
        config = _config
        network.register_callback(update_callback, ["updated"])

        contacts = util.StoreDict(config, "contacts")

        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists:
            action = self.restore_or_create()
            if not action:
                exit()

            password = droid.dialogGetPassword("Choose a password").result
            if password:
                password2 = droid.dialogGetPassword("Confirm password").result
                if password != password2:
                    modal_dialog("Error", "passwords do not match")
                    exit()
            else:
                # set to None if it's an empty string
                password = None

            if action == "create":
                wallet = Wallet(storage)
                seed = wallet.make_seed()
                modal_dialog("Your seed is:", seed)
                wallet.add_seed(seed, password)
                wallet.create_master_keys(password)
                wallet.create_main_account(password)
            elif action == "restore":
                seed = self.seed_dialog()
                if not seed:
                    exit()
                if not Wallet.is_seed(seed):
                    exit()
                wallet = Wallet.from_seed(seed, password, storage)
            else:
                exit()

            msg = "Creating wallet" if action == "create" else "Restoring wallet"
            droid.dialogCreateSpinnerProgress("Electrum", msg)
            droid.dialogShow()
            wallet.start_threads(network)
            if action == "restore":
                wallet.wait_until_synchronized()
            else:
                wallet.synchronize()
            droid.dialogDismiss()
            droid.vibrate()

        else:
            wallet = Wallet(storage)
            wallet.start_threads(network)
Exemplo n.º 15
0
 def confirm_seed(self, seed):
     assert Wallet.is_seed(seed)
     def on_seed(_dlg, btn):
         if btn is _dlg.ids.back:
             _dlg.close()
             self.run('create')
             return
         _dlg.close()
         self.run('enter_pin', (seed,))
     msg = _('Please retype your seed phrase, to confirm that you properly saved it')
     RestoreSeedDialog(test=lambda x: x==seed, message=msg, on_release=on_seed).open()
Exemplo n.º 16
0
    def seed_dialog(self, is_restore=True):

        vbox = QVBoxLayout()
        if is_restore:
            msg = _("Please enter your wallet seed.") + "\n"
        else:
            msg = _("Your seed is important!") \
                + "\n" + _("To make sure that you have properly saved your seed, please retype it here.")
        
        logo = QLabel()
        logo.setPixmap(QPixmap(":icons/seed.png").scaledToWidth(56))
        logo.setMaximumWidth(60)

        label = QLabel(msg)
        label.setWordWrap(True)

        seed_e = QTextEdit()
        seed_e.setMaximumHeight(100)

        vbox.addWidget(label)

        grid = QGridLayout()
        grid.addWidget(logo, 0, 0)
        grid.addWidget(seed_e, 0, 1)

        vbox.addLayout(grid)

        vbox.addStretch(1)
        vbox.addLayout(ok_cancel_buttons(self, _('Next')))

        self.set_layout(vbox)
        if not self.exec_():
            return

        seed = seed_e.toPlainText()
        seed = unicode(seed.toLower())

        if not seed:
            QMessageBox.warning(None, _('Error'), _('No seed'), _('OK'))
            return

        if not Wallet.is_seed(seed):
            QMessageBox.warning(None, _('Error'), _('Invalid seed'), _('OK'))
            return

        return seed
Exemplo n.º 17
0
    def confirm_seed(self, seed):
        assert Wallet.is_seed(seed)

        def on_seed(_dlg, btn):
            if btn is _dlg.ids.back:
                _dlg.close()
                self.run('create')
                return
            _dlg.close()
            self.run('enter_pin', (seed, ))

        msg = _(
            'Please retype your seed phrase, to confirm that you properly saved it'
        )
        RestoreSeedDialog(test=lambda x: x == seed,
                          message=msg,
                          on_release=on_seed).open()
Exemplo n.º 18
0
def run_recovery_dialog():
    message = "Please enter your wallet seed or the corresponding mnemonic list of words, and the gap limit of your wallet."
    dialog = Gtk.MessageDialog(
        parent = None,
        flags = Gtk.DialogFlags.MODAL, 
        buttons = Gtk.ButtonsType.OK_CANCEL,
        message_format = message)

    vbox = dialog.vbox
    dialog.set_default_response(Gtk.ResponseType.OK)

    # ask seed, server and gap in the same dialog
    seed_box = Gtk.HBox()
    seed_label = Gtk.Label(label='Seed or mnemonic:')
    seed_label.set_size_request(150,-1)
    seed_box.pack_start(seed_label, False, False, 10)
    seed_label.show()
    seed_entry = Gtk.Entry()
    seed_entry.show()
    seed_entry.set_size_request(450,-1)
    seed_box.pack_start(seed_entry, False, False, 10)
    add_help_button(seed_box, '.')
    seed_box.show()
    vbox.pack_start(seed_box, False, False, 5)    

    dialog.show()
    r = dialog.run()
    seed = seed_entry.get_text()
    dialog.destroy()

    if r==Gtk.ResponseType.CANCEL:
        return False

    if Wallet.is_seed(seed):
        return seed

    show_message("no seed")
    return False
Exemplo n.º 19
0
    def __init__(self):
        global wallet
        self.qr_data = None
        storage = WalletStorage(
            {'wallet_path': '/sdcard/electrum/authenticator'})
        if not storage.file_exists:

            action = self.restore_or_create()
            if not action:
                exit()
            password = droid.dialogGetPassword('Choose a password').result
            if password:
                password2 = droid.dialogGetPassword('Confirm password').result
                if password != password2:
                    modal_dialog('Error', 'Passwords do not match')
                    exit()
            else:
                password = None
            if action == 'create':
                wallet = Wallet(storage)
                seed = wallet.make_seed()
                modal_dialog('Your seed is:', seed)
            elif action == 'import':
                seed = self.seed_dialog()
                if not seed:
                    exit()
                if not Wallet.is_seed(seed):
                    exit()
                wallet = Wallet.from_seed(seed, storage)
            else:
                exit()

            wallet.add_seed(seed, password)
            wallet.create_master_keys(password)
            wallet.create_main_account(password)
        else:
            wallet = Wallet(storage)
Exemplo n.º 20
0
    def __init__(self):
        global wallet
        self.qr_data = None
        storage = WalletStorage({'wallet_path':'/sdcard/electrum/authenticator'})
        if not storage.file_exists:

            action = self.restore_or_create()
            if not action:
                exit()
            password = droid.dialogGetPassword('Choose a password').result
            if password:
                password2 = droid.dialogGetPassword('Confirm password').result
                if password != password2:
                    modal_dialog('Error', 'Passwords do not match')
                    exit()
            else:
                password = None
            if action == 'create':
                wallet = Wallet(storage)
                seed = wallet.make_seed()
                modal_dialog('Your seed is:', seed)
            elif action == 'import':
                seed = self.seed_dialog()
                if not seed:
                    exit()
                if not Wallet.is_seed(seed):
                    exit()
                wallet = Wallet.from_seed(seed, storage)
            else:
                exit()

            wallet.add_seed(seed, password)
            wallet.create_master_keys(password)
            wallet.create_main_account(password)
        else:
            wallet = Wallet(storage)
Exemplo n.º 21
0
    def __init__(self):
        global wallet
        self.qr_data = None
        storage = WalletStorage("/sdcard/electrum/authenticator")
        if not storage.file_exists:

            action = self.restore_or_create()
            if not action:
                exit()
            password = droid.dialogGetPassword("Choose a password").result
            if password:
                password2 = droid.dialogGetPassword("Confirm password").result
                if password != password2:
                    modal_dialog("Error", "Passwords do not match")
                    exit()
            else:
                password = None
            if action == "create":
                wallet = Wallet(storage)
                seed = wallet.make_seed()
                modal_dialog("Your seed is:", seed)
            elif action == "import":
                seed = self.seed_dialog()
                if not seed:
                    exit()
                if not Wallet.is_seed(seed):
                    exit()
                wallet = Wallet.from_seed(seed, password, storage)
            else:
                exit()

            wallet.add_seed(seed, password)
            wallet.create_master_keys(password)
            wallet.create_main_account(password)
        else:
            wallet = Wallet(storage)
Exemplo n.º 22
0
    def run(self, action):

        if action == 'new':
            action, t = self.restore_or_create()

        if action is None: 
            return
            
        if action == 'create':
            if t == 'standard':
                wallet = Wallet(self.storage)

            elif t == '2fa':
                wallet = Wallet_2of3(self.storage)
                run_hook('create_cold_seed', wallet, self)
                self.create_cold_seed(wallet)
                return

            elif t == '2of2':
                wallet = Wallet_2of2(self.storage)
                action = 'create_2of2_1'

            elif t == '2of3':
                wallet = Wallet_2of3(self.storage)
                action = 'create_2of3_1'


        if action in ['create_2fa_2', 'create_2of3_2']:
            wallet = Wallet_2of3(self.storage)

        if action in ['create', 'create_2of2_1', 'create_2fa_2', 'create_2of3_1']:
            seed = wallet.make_seed()
            sid = None if action == 'create' else 'hot'
            if not self.show_seed(seed, sid):
                return
            if not self.verify_seed(seed, sid):
                return
            password = self.password_dialog()
            wallet.add_seed(seed, password)
            if action == 'create':
                wallet.create_accounts(password)
                self.waiting_dialog(wallet.synchronize)
            elif action == 'create_2of2_1':
                action = 'create_2of2_2'
            elif action == 'create_2of3_1':
                action = 'create_2of3_2'
            elif action == 'create_2fa_2':
                action = 'create_2fa_3'

        if action == 'create_2of2_2':
            xpub_hot = wallet.master_public_keys.get("m/")
            xpub = self.multi_mpk_dialog(xpub_hot, 1)
            if not xpub:
                return
            wallet.add_master_public_key("cold/", xpub)
            wallet.create_account()
            self.waiting_dialog(wallet.synchronize)


        if action == 'create_2of3_2':
            xpub_hot = wallet.master_public_keys.get("m/")
            r = self.multi_mpk_dialog(xpub_hot, 2)
            if not r:
                return
            xpub1, xpub2 = r
            wallet.add_master_public_key("cold/", xpub1)
            wallet.add_master_public_key("remote/", xpub2)
            wallet.create_account()
            self.waiting_dialog(wallet.synchronize)


        if action == 'create_2fa_3':
            run_hook('create_remote_key', wallet, self)
            if not wallet.master_public_keys.get("remote/"):
                return
            wallet.create_account()
            self.waiting_dialog(wallet.synchronize)


        if action == 'restore':

            if t == 'standard':
                text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
                if not text:
                    return
                if Wallet.is_seed(text):
                    password = self.password_dialog()
                    wallet = Wallet.from_seed(text, self.storage)
                    wallet.add_seed(text, password)
                    wallet.create_accounts(password)
                elif Wallet.is_mpk(text):
                    wallet = Wallet.from_mpk(text, self.storage)
                elif Wallet.is_address(text):
                    wallet = Wallet.from_address(text, self.storage)
                elif Wallet.is_private_key(text):
                    wallet = Wallet.from_private_key(text, self.storage)
                else:
                    raise

            elif t in ['2fa', '2of2']:
                r = self.multi_seed_dialog(1)
                if not r: 
                    return
                text1, text2 = r
                password = self.password_dialog()
                if t == '2of2':
                    wallet = Wallet_2of2(self.storage)
                elif t == '2of3':
                    wallet = Wallet_2of3(self.storage)
                elif t == '2fa':
                    wallet = Wallet_2of3(self.storage)

                if Wallet.is_seed(text1):
                    wallet.add_seed(text1, password)
                    if Wallet.is_seed(text2):
                        wallet.add_cold_seed(text2, password)
                    else:
                        wallet.add_master_public_key("cold/", text2)

                elif Wallet.is_mpk(text1):
                    if Wallet.is_seed(text2):
                        wallet.add_seed(text2, password)
                        wallet.add_master_public_key("cold/", text1)
                    else:
                        wallet.add_master_public_key("m/", text1)
                        wallet.add_master_public_key("cold/", text2)

                if t == '2fa':
                    run_hook('restore_third_key', wallet, self)

                wallet.create_account()

            elif t in ['2of3']:
                r = self.multi_seed_dialog(2)
                if not r: 
                    return
                text1, text2, text3 = r
                password = self.password_dialog()
                wallet = Wallet_2of3(self.storage)

                if Wallet.is_seed(text1):
                    wallet.add_seed(text1, password)
                    if Wallet.is_seed(text2):
                        wallet.add_cold_seed(text2, password)
                    else:
                        wallet.add_master_public_key("cold/", text2)

                elif Wallet.is_mpk(text1):
                    if Wallet.is_seed(text2):
                        wallet.add_seed(text2, password)
                        wallet.add_master_public_key("cold/", text1)
                    else:
                        wallet.add_master_public_key("m/", text1)
                        wallet.add_master_public_key("cold/", text2)

                wallet.create_account()

            else:
                raise


                
        #if not self.config.get('server'):
        if self.network:
            if self.network.interfaces:
                self.network_dialog()
            else:
                QMessageBox.information(None, _('Warning'), _('You are offline'), _('OK'))
                self.network.stop()
                self.network = None

        # start wallet threads
        wallet.start_threads(self.network)

        if action == 'restore':

            self.waiting_dialog(lambda: wallet.restore(self.waiting_label.setText))

            if self.network:
                if wallet.is_found():
                    QMessageBox.information(None, _('Information'), _("Recovery successful"), _('OK'))
                else:
                    QMessageBox.information(None, _('Information'), _("No transactions found for this seed"), _('OK'))
            else:
                QMessageBox.information(None, _('Information'), _("This wallet was restored offline. It may contain more addresses than displayed."), _('OK'))

        return wallet
Exemplo n.º 23
0
    def restore_seed_dialog(self, wallet):
        #TODO t currently hardcoded
        t = 'standard'
        if t == 'standard':
            from electrum_gui.kivy.uix.dialogs.create_restore import\
                RestoreSeedDialog
            RestoreSeedDialog(
                on_release=partial(self.on_verify_restore_ok, wallet),
                                    wizard=weakref.proxy(self)).open()

        elif t in ['2fa', '2of2']:
            r = self.multi_seed_dialog(1)
            if not r:
                return
            text1, text2 = r
            password = self.password_dialog(wallet=wallet)
            if t == '2of2':
                wallet = Wallet_2of2(self.storage)
            elif t == '2of3':
                wallet = Wallet_2of3(self.storage)
            elif t == '2fa':
                wallet = Wallet_2of3(self.storage)

            if Wallet.is_seed(text1):
                wallet.add_seed(text1, password)
                if Wallet.is_seed(text2):
                    wallet.add_cold_seed(text2, password)
                else:
                    wallet.add_master_public_key("cold/", text2)

            elif Wallet.is_mpk(text1):
                if Wallet.is_seed(text2):
                    wallet.add_seed(text2, password)
                    wallet.add_master_public_key("cold/", text1)
                else:
                    wallet.add_master_public_key("m/", text1)
                    wallet.add_master_public_key("cold/", text2)

            if t == '2fa':
                run_hook('restore_third_key', wallet, self)

            wallet.create_account()

        elif t in ['2of3']:
            r = self.multi_seed_dialog(2)
            if not r:
                return
            text1, text2, text3 = r
            password = self.password_dialog()
            wallet = Wallet_2of3(self.storage)

            if Wallet.is_seed(text1):
                wallet.add_seed(text1, password)
                if Wallet.is_seed(text2):
                    wallet.add_cold_seed(text2, password)
                else:
                    wallet.add_master_public_key("cold/", text2)
            
            elif Wallet.is_mpk(text1):
                if Wallet.is_seed(text2):
                    wallet.add_seed(text2, password)
                    wallet.add_master_public_key("cold/", text1)
                else:
                    wallet.add_master_public_key("m/", text1)
                    wallet.add_master_public_key("cold/", text2)
            
            wallet.create_account()
Exemplo n.º 24
0
 def task():
     if not Wallet.is_seed(text):
         raise BaseException("invalid seed")
     self.wallet = Wallet.from_seed(text, password, self.storage)
     self.wallet.create_main_account()
     self.wallet.synchronize()
Exemplo n.º 25
0
    def restore(self, t):

            if t == 'standard':
                text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
                if not text:
                    return
                if Wallet.is_xprv(text):
                    password = self.password_dialog()
                    wallet = Wallet.from_xprv(text, password, self.storage)
                elif Wallet.is_xpub(text):
                    wallet = Wallet.from_xpub(text, self.storage)
                elif Wallet.is_address(text):
                    wallet = Wallet.from_address(text, self.storage)
                elif Wallet.is_private_key(text):
                    wallet = Wallet.from_private_key(text, self.storage)
                elif Wallet.is_seed(text):
                    password = self.password_dialog()
                    wallet = Wallet.from_seed(text, self.storage)
                    wallet.add_seed(text, password)
                    wallet.create_master_keys(password)
                    wallet.create_main_account(password)
                else:
                    raise BaseException('unknown wallet type')

            elif t in ['2of2']:
                r = self.multi_seed_dialog(1)
                if not r:
                    return
                text1, text2 = r
                wallet = Wallet_2of2(self.storage)
                if Wallet.is_seed(text1) or Wallet.is_seed(text2):
                    password = self.password_dialog()
                else:
                    password = None

                if Wallet.is_seed(text2) and Wallet.is_xpub(text1):
                    c = text1
                    text1 = text2
                    text2 = c

                if Wallet.is_seed(text1):
                    wallet.add_seed(text1, password)
                    wallet.create_master_keys(password)
                else:
                    wallet.add_master_public_key("x1/", text1)

                if Wallet.is_seed(text2):
                    wallet.add_cosigner_seed(text2, "x2/", password)
                elif Wallet.is_xpub(text2):
                    wallet.add_master_public_key("x2/", text2)

                wallet.create_main_account(password)


            elif t in ['2of3']:
                r = self.multi_seed_dialog(2)
                if not r:
                    return
                text1, text2, text3 = r
                wallet = Wallet_2of3(self.storage)
                if Wallet.is_seed(text1) or Wallet.is_seed(text2) or Wallet.is_seed(text3):
                    password = self.password_dialog()
                else:
                    password = None

                if Wallet.is_xpub(text1) and Wallet.is_seed(text2):
                    temp = text1
                    text1 = text2
                    text2 = temp

                if Wallet.is_xpub(text1) and Wallet.is_seed(text3):
                    temp = text1
                    text1 = text3
                    text3 = temp

                if Wallet.is_seed(text1):
                    wallet.add_seed(text1, password)
                    wallet.create_master_keys(password)
                else:
                    wallet.add_master_public_key("x1/", text1)

                if Wallet.is_seed(text2):
                    wallet.add_cosigner_seed(text2, "x2/", password)
                elif Wallet.is_xpub(text2):
                    wallet.add_master_public_key("x2/", text2)

                if Wallet.is_seed(text3):
                    wallet.add_cosigner_seed(text3, "x3/", password)
                elif Wallet.is_xpub(text3):
                    wallet.add_master_public_key("x3/", text3)

                wallet.create_main_account(password)

            else:
                self.storage.put('wallet_type', t)
                wallet = run_hook('installwizard_restore', self, self.storage)
                if not wallet:
                    return

            # create first keys offline
            self.waiting_dialog(wallet.synchronize)

            return wallet
Exemplo n.º 26
0
    def restore_seed_dialog(self, wallet):
        #TODO t currently hardcoded
        t = 'standard'
        if t == 'standard':
            from electrum_gui.kivy.uix.dialogs.create_restore import\
                RestoreSeedDialog
            RestoreSeedDialog(on_release=partial(self.on_verify_restore_ok,
                                                 wallet),
                              wizard=weakref.proxy(self)).open()

        elif t in ['2fa', '2of2']:
            r = self.multi_seed_dialog(1)
            if not r:
                return
            text1, text2 = r
            password = self.password_dialog(wallet=wallet)
            if t == '2of2':
                wallet = Wallet_2of2(self.storage)
            elif t == '2of3':
                wallet = Wallet_2of3(self.storage)
            elif t == '2fa':
                wallet = Wallet_2of3(self.storage)

            if Wallet.is_seed(text1):
                wallet.add_seed(text1, password)
                if Wallet.is_seed(text2):
                    wallet.add_cold_seed(text2, password)
                else:
                    wallet.add_master_public_key("cold/", text2)

            elif Wallet.is_mpk(text1):
                if Wallet.is_seed(text2):
                    wallet.add_seed(text2, password)
                    wallet.add_master_public_key("cold/", text1)
                else:
                    wallet.add_master_public_key("m/", text1)
                    wallet.add_master_public_key("cold/", text2)

            if t == '2fa':
                run_hook('restore_third_key', wallet, self)

            wallet.create_account()

        elif t in ['2of3']:
            r = self.multi_seed_dialog(2)
            if not r:
                return
            text1, text2, text3 = r
            password = self.password_dialog()
            wallet = Wallet_2of3(self.storage)

            if Wallet.is_seed(text1):
                wallet.add_seed(text1, password)
                if Wallet.is_seed(text2):
                    wallet.add_cold_seed(text2, password)
                else:
                    wallet.add_master_public_key("cold/", text2)

            elif Wallet.is_mpk(text1):
                if Wallet.is_seed(text2):
                    wallet.add_seed(text2, password)
                    wallet.add_master_public_key("cold/", text1)
                else:
                    wallet.add_master_public_key("m/", text1)
                    wallet.add_master_public_key("cold/", text2)

            wallet.create_account()
Exemplo n.º 27
0
 def is_any(self, seed_e):
     text = self.get_seed_text(seed_e)
     return Wallet.is_seed(text) or Wallet.is_old_mpk(text) or Wallet.is_xpub(text) or Wallet.is_xprv(text) or Wallet.is_address(text) or Wallet.is_private_key(text)
Exemplo n.º 28
0
 def is_any(self, seed_e):
     text = self.get_seed_text(seed_e)
     return (Wallet.is_seed(text) or Wallet.is_mpk(text)
             or Wallet.is_address(text) or Wallet.is_private_key(text))
Exemplo n.º 29
0
    def restore(self, t):

            if t == 'standard':
                text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
                if not text:
                    return
                if Wallet.is_seed(text):
                    password = self.password_dialog()
                    wallet = Wallet.from_seed(text, self.storage)
                    wallet.add_seed(text, password)
                    wallet.create_accounts(password)
                elif Wallet.is_xprv(text):
                    password = self.password_dialog()
                    wallet = Wallet.from_xprv(text, password, self.storage)
                elif Wallet.is_old_mpk(text):
                    wallet = Wallet.from_old_mpk(text, self.storage)
                elif Wallet.is_xpub(text):
                    wallet = Wallet.from_xpub(text, self.storage)
                elif Wallet.is_address(text):
                    wallet = Wallet.from_address(text, self.storage)
                elif Wallet.is_private_key(text):
                    wallet = Wallet.from_private_key(text, self.storage)
                else:
                    raise

            elif t in ['2of2']:
                r = self.multi_seed_dialog(1)
                if not r: 
                    return
                text1, text2 = r
                wallet = Wallet_2of2(self.storage)
                if Wallet.is_seed(text1) or Wallet.is_seed(text2):
                    password = self.password_dialog()
                else:
                    password = None

                if Wallet.is_seed(text1):
                    wallet.add_seed(text1, password)
                    if Wallet.is_seed(text2):
                        wallet.add_cold_seed(text2, password)
                    else:
                        wallet.add_master_public_key("cold/", text2)
                else:
                    assert Wallet.is_xpub(text1)
                    if Wallet.is_seed(text2):
                        wallet.add_seed(text2, password)
                        wallet.add_master_public_key("cold/", text1)
                    else:
                        wallet.add_master_public_key("m/", text1)
                        wallet.add_master_public_key("cold/", text2)

                wallet.create_accounts(password)


            elif t in ['2of3']:
                r = self.multi_seed_dialog(2)
                if not r: 
                    return
                text1, text2, text3 = r
                wallet = Wallet_2of3(self.storage)
                if Wallet.is_seed(text1) or Wallet.is_seed(text2) or Wallet.is_seed(text3):
                    password = self.password_dialog()
                else:
                    password = None

                if Wallet.is_seed(text1):
                    wallet.add_seed(text1, password)
                    if Wallet.is_seed(text2):
                        wallet.add_cold_seed(text2, password)
                    else:
                        wallet.add_master_public_key("cold/", text2)

                elif Wallet.is_xpub(text1):
                    if Wallet.is_seed(text2):
                        wallet.add_seed(text2, password)
                        wallet.add_master_public_key("cold/", text1)
                    else:
                        wallet.add_master_public_key("m/", text1)
                        wallet.add_master_public_key("cold/", text2)

                wallet.create_accounts(password)

            else:
                wallet = run_hook('installwizard_restore', self, self.storage)
                if not wallet:
                    return

            # create first keys offline
            self.waiting_dialog(wallet.synchronize)
                
            return wallet
Exemplo n.º 30
0
    def restore(self, t):

        if t == 'standard':
            text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
            if not text:
                return
            if Wallet.is_xprv(text):
                password = self.password_dialog()
                wallet = Wallet.from_xprv(text, password, self.storage)
            elif Wallet.is_old_mpk(text):
                wallet = Wallet.from_old_mpk(text, self.storage)
            elif Wallet.is_xpub(text):
                wallet = Wallet.from_xpub(text, self.storage)
            elif Wallet.is_address(text):
                wallet = Wallet.from_address(text, self.storage)
            elif Wallet.is_private_key(text):
                password = self.password_dialog()
                wallet = Wallet.from_private_key(text, password, self.storage)
            elif Wallet.is_seed(text):
                password = self.password_dialog()
                wallet = Wallet.from_seed(text, self.storage)
                wallet.add_seed(text, password)
                wallet.create_master_keys(password)
                wallet.create_main_account(password)
            else:
                raise BaseException('unknown wallet type')

        elif t in ['2of2']:
            r = self.multi_seed_dialog(1)
            if not r:
                return
            text1, text2 = r
            wallet = Wallet_2of2(self.storage)
            if Wallet.is_seed(text1) or Wallet.is_seed(text2):
                password = self.password_dialog()
            else:
                password = None

            if Wallet.is_seed(text2) and Wallet.is_xpub(text1):
                c = text1
                text1 = text2
                text2 = c

            if Wallet.is_seed(text1):
                wallet.add_seed(text1, password)
                wallet.create_master_keys(password)
            else:
                wallet.add_master_public_key("x1/", text1)

            if Wallet.is_seed(text2):
                wallet.add_cosigner_seed(text2, "x2/", password)
            elif Wallet.is_xpub(text2):
                wallet.add_master_public_key("x2/", text2)

            wallet.create_main_account(password)

        elif t in ['2of3']:
            r = self.multi_seed_dialog(2)
            if not r:
                return
            text1, text2, text3 = r
            wallet = Wallet_2of3(self.storage)
            if Wallet.is_seed(text1) or Wallet.is_seed(
                    text2) or Wallet.is_seed(text3):
                password = self.password_dialog()
            else:
                password = None

            if Wallet.is_xpub(text1) and Wallet.is_seed(text2):
                temp = text1
                text1 = text2
                text2 = temp

            if Wallet.is_xpub(text1) and Wallet.is_seed(text3):
                temp = text1
                text1 = text3
                text3 = temp

            if Wallet.is_seed(text1):
                wallet.add_seed(text1, password)
                wallet.create_master_keys(password)
            else:
                wallet.add_master_public_key("x1/", text1)

            if Wallet.is_seed(text2):
                wallet.add_cosigner_seed(text2, "x2/", password)
            elif Wallet.is_xpub(text2):
                wallet.add_master_public_key("x2/", text2)

            if Wallet.is_seed(text3):
                wallet.add_cosigner_seed(text3, "x3/", password)
            elif Wallet.is_xpub(text3):
                wallet.add_master_public_key("x3/", text3)

            wallet.create_main_account(password)

        else:
            self.storage.put('wallet_type', t)
            wallet = run_hook('installwizard_restore', self, self.storage)
            if not wallet:
                return

        # create first keys offline
        self.waiting_dialog(wallet.synchronize)

        return wallet
Exemplo n.º 31
0
 def is_any(self, seed_e):
     text = self.get_seed_text(seed_e)
     return Wallet.is_seed(text) or Wallet.is_mpk(text) or Wallet.is_address(text) or Wallet.is_private_key(text)
Exemplo n.º 32
0
 def is_any(self, text):
     return Wallet.is_seed(text) or Wallet.is_old_mpk(
         text) or Wallet.is_xpub(text) or Wallet.is_xprv(
             text) or Wallet.is_address(text) or Wallet.is_private_key(text)
Exemplo n.º 33
0
    def run(self, action = None):

        if action is None:
            action = self.restore_or_create()

        if action is None: 
            return

        if action == 'create':            
            t = self.choose_wallet_type()
            if t == '2of3':
                run_hook('create_cold_seed', self.storage, self)
                return


        if action in ['create', 'create2of3']:

            wallet = Wallet(self.storage)

            wallet.init_seed(None)
            seed = wallet.get_mnemonic(None)
            if not self.show_seed(seed, 'hot' if action == 'create2of3' else None):
                return
            if not self.verify_seed(seed):
                return
            ok, old_password, password = self.password_dialog(wallet)
            wallet.save_seed(password)

            if action == 'create2of3':
                run_hook('create_hot_seed', wallet, self)

            wallet.create_accounts(password)
            def create():
                wallet.synchronize()  # generate first addresses offline
            self.waiting_dialog(create)

        elif action == 'restore':
            seed = self.seed_dialog()
            if not Wallet.is_seed(seed):
                return
            wallet = Wallet.from_seed(seed, self.storage)
            ok, old_password, password = self.password_dialog(wallet)
            wallet.save_seed(password)
            wallet.create_accounts(password)

        elif action == 'watching':
            mpk = self.mpk_dialog()
            if not mpk:
                return
            wallet = Wallet.from_mpk(mpk, self.storage)

        else: raise
                
        #if not self.config.get('server'):
        if self.network:
            if self.network.interfaces:
                self.network_dialog()
            else:
                QMessageBox.information(None, _('Warning'), _('You are offline'), _('OK'))
                self.network.stop()
                self.network = None

        # start wallet threads
        wallet.start_threads(self.network)

        if action == 'restore':

            self.waiting_dialog(lambda: wallet.restore(self.waiting_label.setText))

            if self.network:
                if wallet.is_found():
                    QMessageBox.information(None, _('Information'), _("Recovery successful"), _('OK'))
                else:
                    QMessageBox.information(None, _('Information'), _("No transactions found for this seed"), _('OK'))
            else:
                QMessageBox.information(None, _('Information'), _("This wallet was restored offline. It may contain more addresses than displayed."), _('OK'))

        return wallet