コード例 #1
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
コード例 #2
0
 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)
コード例 #3
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
コード例 #4
0
 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)
コード例 #5
0
 def is_mpk(self, text):
     return Wallet.is_xpub(text) or Wallet.is_old_mpk(text)
コード例 #6
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)
コード例 #7
0
 def is_mpk(self, text):
     return Wallet.is_xpub(text) or Wallet.is_old_mpk(text)
コード例 #8
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)