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
def multi_mpk_dialog(self, xpub_hot, n): vbox = QVBoxLayout() scroll = QScrollArea() scroll.setEnabled(True) scroll.setWidgetResizable(True) vbox.addWidget(scroll) w = QWidget() scroll.setWidget(w) innerVbox = QVBoxLayout() w.setLayout(innerVbox) vbox0 = seed_dialog.show_seed_box(MSG_SHOW_MPK, xpub_hot, 'hot') innerVbox.addLayout(vbox0) entries = [] for i in range(n): msg = _("Please enter the master public key of cosigner" ) + ' %d' % (i + 1) vbox2, seed_e2 = seed_dialog.enter_seed_box(msg, self, 'cold') innerVbox.addLayout(vbox2) entries.append(seed_e2) vbox.addStretch(1) button = OkButton(self, _('Next')) vbox.addLayout(Buttons(CancelButton(self), button)) button.setEnabled(False) f = lambda: button.setEnabled( map(lambda e: Wallet.is_xpub(self.get_seed_text(e)), entries) == [True] * len(entries)) for e in entries: e.textChanged.connect(f) self.set_layout(vbox) if not self.exec_(): return return map(lambda e: self.get_seed_text(e), entries)
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
def multi_mpk_dialog(self, xpub_hot, n): vbox = QVBoxLayout() scroll = QScrollArea() scroll.setEnabled(True) scroll.setWidgetResizable(True) vbox.addWidget(scroll) w = QWidget() scroll.setWidget(w) innerVbox = QVBoxLayout() w.setLayout(innerVbox) vbox0 = seed_dialog.show_seed_box(MSG_SHOW_MPK, xpub_hot, 'hot') innerVbox.addLayout(vbox0) entries = [] for i in range(n): msg = _("Please enter the master public key of cosigner") + ' %d'%(i+1) vbox2, seed_e2 = seed_dialog.enter_seed_box(msg, self, 'cold') innerVbox.addLayout(vbox2) entries.append(seed_e2) vbox.addStretch(1) button = OkButton(self, _('Next')) vbox.addLayout(Buttons(CancelButton(self), button)) button.setEnabled(False) f = lambda: button.setEnabled( map(lambda e: Wallet.is_xpub(self.get_seed_text(e)), entries) == [True]*len(entries)) for e in entries: e.textChanged.connect(f) self.set_layout(vbox) if not self.exec_(): return return map(lambda e: self.get_seed_text(e), entries)
def multi_mpk_dialog(self, xpub_hot, n): vbox = QVBoxLayout() vbox0, seed_e0 = seed_dialog.enter_seed_box(MSG_SHOW_MPK, self, 'hot') vbox.addLayout(vbox0) seed_e0.setText(xpub_hot) seed_e0.setReadOnly(True) entries = [] for i in range(n): vbox2, seed_e2 = seed_dialog.enter_seed_box( MSG_ENTER_COLD_MPK, self, 'cold') vbox.addLayout(vbox2) entries.append(seed_e2) vbox.addStretch(1) hbox, button = ok_cancel_buttons2(self, _('Next')) vbox.addLayout(hbox) button.setEnabled(False) f = lambda: button.setEnabled( map(lambda e: Wallet.is_xpub(self.get_seed_text(e)), entries) == [True] * len(entries)) for e in entries: e.textChanged.connect(f) self.set_layout(vbox) if not self.exec_(): return return map(lambda e: self.get_seed_text(e), entries)
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))
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) )
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
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
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
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
def multi_mpk_dialog(self, xpub_hot, n): vbox = QVBoxLayout() vbox0 = seed_dialog.show_seed_box(MSG_SHOW_MPK, xpub_hot, 'hot') vbox.addLayout(vbox0) entries = [] for i in range(n): vbox2, seed_e2 = seed_dialog.enter_seed_box(MSG_ENTER_COLD_MPK, self, 'cold') vbox.addLayout(vbox2) entries.append(seed_e2) vbox.addStretch(1) button = OkButton(self, _('Next')) vbox.addLayout(Buttons(CancelButton(self), button)) button.setEnabled(False) f = lambda: button.setEnabled( map(lambda e: Wallet.is_xpub(self.get_seed_text(e)), entries) == [True]*len(entries)) for e in entries: e.textChanged.connect(f) self.set_layout(vbox) if not self.exec_(): return return map(lambda e: self.get_seed_text(e), entries)
def multi_mpk_dialog(self, xpub_hot, n): vbox = QVBoxLayout() vbox0, seed_e0 = seed_dialog.enter_seed_box(MSG_SHOW_MPK, "hot") vbox.addLayout(vbox0) seed_e0.setText(xpub_hot) seed_e0.setReadOnly(True) entries = [] for i in range(n): vbox2, seed_e2 = seed_dialog.enter_seed_box(MSG_ENTER_COLD_MPK, "cold") vbox.addLayout(vbox2) entries.append(seed_e2) vbox.addStretch(1) hbox, button = ok_cancel_buttons2(self, _("Next")) vbox.addLayout(hbox) button.setEnabled(False) f = lambda: button.setEnabled( map(lambda e: Wallet.is_xpub(self.get_seed_text(e)), entries) == [True] * len(entries) ) for e in entries: e.textChanged.connect(f) self.set_layout(vbox) if not self.exec_(): return return map(lambda e: self.get_seed_text(e), entries)
def is_mpk(self, text): return Wallet.is_xpub(text) or Wallet.is_old_mpk(text)
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
def is_xpub(self, seed_e): text = self.get_seed_text(seed_e) return Wallet.is_xpub(text)
def is_mpk(self, seed_e): text = self.get_seed_text(seed_e) return Wallet.is_xpub(text) or Wallet.is_old_mpk(text)
def is_mpk(self, text): return Wallet.is_xpub(text) or Wallet.is_old_mpk(text)
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
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)
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))
def is_mpk(self, seed_e): text = self.get_seed_text(seed_e) return Wallet.is_xpub(text) or Wallet.is_old_mpk(text)
def is_xpub(self, seed_e): text = self.get_seed_text(seed_e) return Wallet.is_xpub(text)
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