Exemplo n.º 1
0
    def load_wallet_file(self, filename):
        try:
            storage = WalletStorage(filename)
        except Exception as e:
            QMessageBox.information(None, _('Error'), str(e), _('OK'))
            return
        if not storage.file_exists:
            recent = self.config.get('recently_open', [])
            if filename in recent:
                recent.remove(filename)
                self.config.set_key('recently_open', recent)
            action = 'new'
        else:
            try:
                wallet = Wallet(storage)
            except BaseException as e:
                traceback.print_exc(file=sys.stdout)
                QMessageBox.warning(None, _('Warning'), str(e), _('OK'))
                return
            action = wallet.get_action()
        # run wizard
        if action is not None:
            wizard = InstallWizard(self.app, self.config, self.network, storage)
            wallet = wizard.run(action)
            # keep current wallet
            if not wallet:
                return
        else:
            wallet.start_threads(self.network)

        return wallet
Exemplo n.º 2
0
    def load_wallet_file(self, filename):
        try:
            storage = WalletStorage(filename)
        except Exception as e:
            QMessageBox.information(None, _('Error'), str(e), _('OK'))
            return
        if not storage.file_exists:
            recent = self.config.get('recently_open', [])
            if filename in recent:
                recent.remove(filename)
                self.config.set_key('recently_open', recent)
            action = 'new'
        else:
            try:
                wallet = Wallet(storage)
            except BaseException as e:
                traceback.print_exc(file=sys.stdout)
                QMessageBox.warning(None, _('Warning'), str(e), _('OK'))
                return
            action = wallet.get_action()
        # run wizard
        if action is not None:
            wizard = InstallWizard(self.config, self.network, storage)
            wallet = wizard.run(action)
            # keep current wallet
            if not wallet:
                return
        else:
            wallet.start_threads(self.network)

        return wallet
Exemplo n.º 3
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.º 4
0
    def main(self, url=None):

        storage = WalletStorage(self.config)
        if not storage.file_exists:
            action = self.restore_or_create()
            if not action:
                exit()
            self.wallet = wallet = Wallet(storage)
            gap = self.config.get('gap_limit', 5)
            if gap != 5:
                wallet.gap_limit = gap
                wallet.storage.put('gap_limit', gap, True)

            self.wallet.start_threads(self.network)

            if action == 'create':
                wallet.init_seed(None)
                wallet.save_seed()
                wallet.synchronize()  # generate first addresses offline
            elif action == 'restore':
                seed = self.seed_dialog()
                wallet.init_seed(seed)
                wallet.save_seed()
                self.restore_wallet(wallet)

            else:
                exit()
        else:
            self.wallet = Wallet(storage)
            self.wallet.start_threads(self.network)

        w = ElectrumWindow(self.wallet, self.config, self.network)
        if url: w.set_url(url)
        gtk.main()
Exemplo n.º 5
0
def create_wallet():
    """
    Create an electrum wallet if it does not exist
    :return: 
    """
    if not os.path.isfile(WALLET_FILE):
        print("Creating wallet")
        config = electrum.SimpleConfig()
        storage = WalletStorage(config.get_wallet_path())
        passphrase = config.get('passphrase', '')
        seed = Mnemonic('en').make_seed()
        k = keystore.from_seed(seed, passphrase)
        k.update_password(None, None)
        storage.put('keystore', k.dump())
        storage.put('wallet_type', 'standard')
        storage.put('use_encryption', False)
        storage.write()
        wallet = ElectrumWallet(storage)
        wallet.synchronize()
        print("Your wallet generation seed is:\n\"%s\"" % seed)
        print(
            "Please keep it in a safe place; if you lose it, you will not be able to restore your wallet."
        )
        wallet.storage.write()
        print("Wallet saved in '%s'" % wallet.storage.path)
    else:
        print("Wallet already present")
Exemplo n.º 6
0
    def load_wallet_by_name(self, wallet_path):
        if not wallet_path:
            return
        self.stop_wallet()

        config = self.electrum_config
        storage = WalletStorage(wallet_path)
        Logger.info('Electrum: Check for existing wallet')
        if storage.file_exists:
            wallet = Wallet(storage)
            action = wallet.get_action()
        else:
            action = 'new'
        if action is not None:
            # start installation wizard
            Logger.debug(
                'Electrum: Wallet not found. Launching install wizard')
            wizard = Factory.InstallWizard(config, self.network, storage)
            wizard.bind(on_wizard_complete=lambda instance, wallet: self.
                        load_wallet(wallet))
            wizard.run(action)
        else:
            wallet.start_threads(self.network)
            self.load_wallet(wallet)
        self.on_resume()
Exemplo n.º 7
0
def electrum_start(config, start_daemon=True):
	from electrum import NetworkProxy, Wallet, WalletStorage, SimpleConfig
	from electrum.daemon import get_daemon

	_config = SimpleConfig(config)
	daemon_socket = get_daemon(_config, start_daemon=start_daemon)
	network = NetworkProxy(daemon_socket, _config)
	network.start()

	# wait until connected
	while network.is_connecting():
		time.sleep(0.1)
	if not network.is_connected():
		sys.exit('electrum daemon is not connected')

	storage = WalletStorage(_config)
	if storage.file_exists:
		wallet = Wallet(storage)
	else: 
		sys.exit('wallet file is missing')

	#self.wallet.synchronize = lambda: None
	wallet.start_threads(network)

	# wait for wallet to update
	wallet.update()

	return (network, wallet)
Exemplo n.º 8
0
    def main(self, url):

        storage = WalletStorage(self.config)
        if not storage.file_exists:
            import installwizard

            wizard = installwizard.InstallWizard(self.config, self.network, storage)
            wallet = wizard.run()
            if not wallet:
                exit()
        else:
            wallet = Wallet(storage)
            wallet.start_threads(self.network)

        self.main_window = w = ElectrumWindow(self.config, self.network)

        # plugins that need to change the GUI do it here
        run_hook("init")

        w.load_wallet(wallet)

        s = Timer()
        s.start()

        self.windows.append(w)
        if url:
            w.set_url(url)
        w.app = self.app
        w.connect_slots(s)
        w.update_wallet()

        self.app.exec_()

        wallet.stop_threads()
Exemplo n.º 9
0
 def load_wallet_by_name(self, wallet_path):
     if not wallet_path:
         return
     config = self.electrum_config
     try:
         storage = WalletStorage(wallet_path)
     except IOError:
         self.show_error("Cannot read wallet file")
         return
     if storage.file_exists:
         wallet = Wallet(storage)
         action = wallet.get_action()
     else:
         action = 'new'
     if action is not None:
         # start installation wizard
         Logger.debug(
             'Electrum: Wallet not found. Launching install wizard')
         wizard = Factory.InstallWizard(config, self.network, storage)
         wizard.bind(on_wizard_complete=lambda instance, wallet: self.
                     load_wallet(wallet))
         wizard.run(action)
     else:
         self.load_wallet(wallet)
     self.on_resume()
Exemplo n.º 10
0
 def __init__(self, config, network, storage):
     super(InstallWizard, self).__init__()
     self.config = config
     self.network = network
     self.storage = storage
     self.wallet = Wallet(self.storage)
     self.is_restore = False
Exemplo n.º 11
0
class ElectrumGui():
    def __init__(self, config, network):
        self.network = network
        self.config = config
        storage = WalletStorage(config)
        if not storage.file_exists:
            print "Wallet not found. try 'electrum create'"
            exit()

        self.wallet = Wallet(storage)
        self.wallet.start_threads(network)

    def main(self, url=None):
        ew = ElectrumWindow(self.wallet, self.config)
        if url: ew.set_url(url)
        gtk.main()

    def restore_or_create(self):
        return restore_create_dialog(self.wallet)

    def seed_dialog(self):
        return run_recovery_dialog(self.wallet)

    def verify_seed(self):
        self.wallet.save_seed()
        return True

    def network_dialog(self):
        return run_network_dialog(self.wallet, parent=None)

    def show_seed(self):
        show_seed_dialog(self.wallet, None, None)

    def password_dialog(self):
        change_password_dialog(self.wallet, None, None)

    def restore_wallet(self):
        wallet = self.wallet

        dialog = gtk.MessageDialog(parent=None,
                                   flags=gtk.DIALOG_MODAL,
                                   buttons=gtk.BUTTONS_CANCEL,
                                   message_format="Please wait...")
        dialog.show()

        def recover_thread(wallet, dialog):
            while not wallet.is_up_to_date():
                time.sleep(0.1)
            gobject.idle_add(dialog.destroy)

        thread.start_new_thread(recover_thread, (wallet, dialog))
        r = dialog.run()
        dialog.destroy()
        if r == gtk.RESPONSE_CANCEL: return False
        if not wallet.is_found():
            show_message("No transactions found for this seed")

        wallet.save()
        return True
Exemplo n.º 12
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.º 13
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.º 14
0
    def __init__(self, config, daemon, plugins):

        self.config = config
        self.network = daemon.network
        self.preblockhash = self.network.get_pre_blockhash()
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists():
            print("Wallet not found. try 'electrum create'")
            exit()
        if storage.is_encrypted():
            password = getpass.getpass('Password:'******'')
        self.encoding = locale.getpreferredencoding()

        self.stdscr = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.start_color()
        curses.use_default_colors()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_CYAN)
        curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_WHITE)
        self.stdscr.keypad(1)
        self.stdscr.border(0)
        self.maxy, self.maxx = self.stdscr.getmaxyx()
        self.set_cursor(0)
        self.w = curses.newwin(10, 50, 5, 5)

        set_verbosity(False)
        self.tab = 0
        self.pos = 0
        self.popup_pos = 0

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""
        self.history = None

        if self.network:
            self.network.register_callback(self.update, ['updated'])

        self.tab_names = [
            _("History"),
            _("Send"),
            _("Receive"),
            _("Addresses"),
            _("Contacts"),
            _("Banner")
        ]
        self.num_tabs = len(self.tab_names)
Exemplo n.º 15
0
    def __init__(self, config, network):
        self.network = network
        self.config = config
        storage = WalletStorage(config)
        if not storage.file_exists:
            print "Wallet not found. try 'electrum create'"
            exit()

        self.wallet = Wallet(storage)
        self.wallet.start_threads(network)
Exemplo n.º 16
0
    def __init__(self, config, network, plugins):

        self.config = config
        self.network = network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists:
            print "Wallet not found. try 'electrum create'"
            exit()

        self.wallet = Wallet(storage)
        self.wallet.start_threads(self.network)
        self.contacts = StoreDict(self.config, 'contacts')

        locale.setlocale(locale.LC_ALL, '')
        self.encoding = locale.getpreferredencoding()

        self.stdscr = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.start_color()
        curses.use_default_colors()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_CYAN)
        self.stdscr.keypad(1)
        self.stdscr.border(0)
        self.maxy, self.maxx = self.stdscr.getmaxyx()
        self.set_cursor(0)
        self.w = curses.newwin(10, 50, 5, 5)

        set_verbosity(False)
        self.tab = 0
        self.pos = 0
        self.popup_pos = 0

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""
        self.history = None

        if self.network:
            self.network.register_callback('updated', self.update)
            self.network.register_callback('connected', self.refresh)
            self.network.register_callback('disconnected', self.refresh)
            self.network.register_callback('disconnecting', self.refresh)

        self.tab_names = [
            _("History"),
            _("Send"),
            _("Receive"),
            _("Addresses"),
            _("Contacts"),
            _("Banner")
        ]
        self.num_tabs = len(self.tab_names)
Exemplo n.º 17
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.º 18
0
    def main(self, url):

        storage = WalletStorage(self.config)
        if not storage.file_exists:
            import installwizard
            wizard = installwizard.InstallWizard(self.config, self.network, storage)
            wallet = wizard.run()
            if not wallet: 
                exit()
        else:
            wallet = Wallet(storage)

        wallet.start_threads(self.network)

            
        self.main_window = w = ElectrumWindow(self.config, self.network, self.minimize)

        # plugins that need to change the GUI do it here
        run_hook('init')

        w.load_wallet(wallet)

        s = Timer()
        s.start()

        self.windows.append(w)
        if url: w.set_url(url)
        w.app = self.app
        w.connect_slots(s)
        w.update_wallet()

        self.expert = w
        self.mini = self.init_lite(wallet, w, url)
        
        if self.config.get('lite_mode'):
            if not self.mini:
                QMessageBox.warning(None,"Could not start Lite GUI.", "Electrum was unable to load the 'Lite GUI' because it needs Qt version >= 4.7.\nChanging your config to use the 'Classic' GUI")
                self.config.set_key('lite_mode', False, True)
                sys.exit(0)
            else:
                self.minimize()
        else:
            w.show()
            if self.mini:
                self.mini.hide()

        self.app.exec_()

        wallet.stop_threads()
Exemplo n.º 19
0
    def on_start(self):
        """ This is the start point of the kivy ui
        """
        Logger.info("dpi: {} {}".format(metrics.dpi, metrics.dpi_rounded))
        win = Window
        win.bind(size=self.on_size, on_keyboard=self.on_keyboard)
        win.bind(on_key_down=self.on_key_down)

        # Register fonts without this you won't be able to use bold/italic...
        # inside markup.
        from kivy.core.text import Label

        Label.register(
            "Roboto",
            "data/fonts/Roboto.ttf",
            "data/fonts/Roboto.ttf",
            "data/fonts/Roboto-Bold.ttf",
            "data/fonts/Roboto-Bold.ttf",
        )

        if platform == "android":
            # bind to keyboard height so we can get the window contents to
            # behave the way we want when the keyboard appears.
            win.bind(keyboard_height=self.on_keyboard_height)

        self.on_size(win, win.size)
        config = self.electrum_config
        storage = WalletStorage(config.get_wallet_path())

        Logger.info("Electrum: Check for existing wallet")

        if storage.file_exists:
            wallet = Wallet(storage)
            action = wallet.get_action()
        else:
            action = "new"

        if action is not None:
            # start installation wizard
            Logger.debug("Electrum: Wallet not found. Launching install wizard")
            wizard = Factory.InstallWizard(config, self.network, storage)
            wizard.bind(on_wizard_complete=self.on_wizard_complete)
            wizard.run(action)
        else:
            wallet.start_threads(self.network)
            self.on_wizard_complete(None, wallet)

        self.on_resume()
Exemplo n.º 20
0
    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)
Exemplo n.º 21
0
    def main(self, url=None):

        storage = WalletStorage(self.config)
        if not storage.file_exists:
            action = self.restore_or_create()
            if not action:
                exit()
            self.wallet = wallet = Wallet(storage)
            gap = self.config.get('gap_limit', 5)
            if gap != 5:
                wallet.gap_limit = gap
                wallet.storage.put('gap_limit', gap, True)

            self.wallet.start_threads(self.network)

            if action == 'create':
                wallet.init_seed(None)
                wallet.save_seed()
                wallet.synchronize()  # generate first addresses offline
            elif action == 'restore':
                seed = self.seed_dialog()
                wallet.init_seed(seed)
                wallet.save_seed()
                self.restore_wallet(wallet)
                
            else:
                exit()
        else:
            self.wallet = Wallet(storage)
            self.wallet.start_threads(self.network)

        w = ElectrumWindow(self.wallet, self.config, self.network)
        if url: w.set_url(url)
        gtk.main()
Exemplo n.º 22
0
 def __init__(self, config, network, storage):
     super(InstallWizard, self).__init__()
     self.config  = config
     self.network = network
     self.storage = storage
     self.wallet = Wallet(self.storage)
     self.is_restore = False
Exemplo n.º 23
0
 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)
Exemplo n.º 24
0
    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)
Exemplo n.º 25
0
    def unlock_wallet(self):
        """
        Attempt to unlock the BTC wallet with the password in the keychain.
        """
        if not self.created or self.unlocked:
            # Wallet has not been created or unlocked already, do nothing.
            return False

        if self.storage.is_encrypted():
            try:
                keychain_pw = self.get_wallet_password()
                self.wallet_password = keychain_pw if keychain_pw else None  # Convert empty passwords to None
                self.storage.decrypt(self.wallet_password)
                self.unlocked = True
            except InvalidPassword:
                self._logger.error("Invalid BTC wallet password, unable to unlock the wallet!")
            except InitError:
                self._logger.error("Cannot initialize the keychain, unable to unlock the wallet!")
        else:
            # No need to unlock the wallet
            self.unlocked = True

        if self.unlocked:
            config = SimpleConfig(options={'cwd': self.wallet_dir, 'wallet_path': self.wallet_file})
            if os.path.exists(config.get_wallet_path()):
                self.wallet = ElectrumWallet(self.storage)

            self.start_daemon()
            self.open_wallet()
            return True

        return False
Exemplo n.º 26
0
    def main(self, url):

        self.storage = storage = WalletStorage(self.config)
        if not storage.file_exists:
            import installwizard
            wizard = installwizard.InstallWizard(self.config, self.network, storage)
            wallet = wizard.run()
            if not wallet: 
                exit()
        else:
            self.wallet = wallet = Wallet(storage)
            wallet.start_threads(self.network)
            
        self.main_window = w = ElectrumWindow(self.config, self.network)

        # plugins that need to change the GUI do it here
        run_hook('init')

        w.load_wallet(wallet)

        self.timer= s = Timer()
        s.start()

        self.windows.append(w)
        if url: w.set_url(url)
        w.app = self.app
        w.connect_slots(s)
        w.update_wallet()

        self.app.exec_()

        wallet.stop_threads()
Exemplo n.º 27
0
    def main(self, url=None):

        storage = WalletStorage(self.config)
        if not storage.file_exists:
            action = self.restore_or_create()
            if not action:
                exit()
            self.wallet = wallet = Wallet(storage)
            gap = self.config.get('gap_limit', 5)
            if gap != 5:
                wallet.gap_limit = gap
                wallet.storage.put('gap_limit', gap, True)

            if action == 'create':
                seed = wallet.make_seed()
                show_seed_dialog(seed, None)
                r = change_password_dialog(False, None)
                password = r[2] if r else None
                wallet.add_seed(seed, password)
                wallet.create_master_keys(password)
                wallet.create_main_account(password)
                wallet.synchronize()  # generate first addresses offline

            elif action == 'restore':
                seed = self.seed_dialog()
                if not seed:
                    exit()
                r = change_password_dialog(False, None)
                password = r[2] if r else None
                wallet.add_seed(seed, password)
                wallet.create_master_keys(password)
                wallet.create_main_account(password)
                
            else:
                exit()
        else:
            self.wallet = Wallet(storage)
            action = None

        self.wallet.start_threads(self.network)

        if action == 'restore':
            self.restore_wallet(wallet)

        w = ElectrumWindow(self.wallet, self.config, self.network)
        if url: w.set_url(url)
        Gtk.main()
Exemplo n.º 28
0
    def on_start(self):
        ''' This is the start point of the kivy ui
        '''
        Logger.info("dpi: {} {}".format(metrics.dpi, metrics.dpi_rounded))
        win = Window
        win.bind(size=self.on_size,
                    on_keyboard=self.on_keyboard)
        win.bind(on_key_down=self.on_key_down)

        # Register fonts without this you won't be able to use bold/italic...
        # inside markup.
        from kivy.core.text import Label
        Label.register('Roboto',
                   'data/fonts/Roboto.ttf',
                   'data/fonts/Roboto.ttf',
                   'data/fonts/Roboto-Bold.ttf',
                   'data/fonts/Roboto-Bold.ttf')

        if platform == 'android':
            # bind to keyboard height so we can get the window contents to
            # behave the way we want when the keyboard appears.
            win.bind(keyboard_height=self.on_keyboard_height)

        self.on_size(win, win.size)
        config = self.electrum_config
        storage = WalletStorage(config.get_wallet_path())

        Logger.info('Electrum: Check for existing wallet')

        if storage.file_exists:
            wallet = Wallet(storage)
            action = wallet.get_action()
        else:
            action = 'new'

        if action is not None:
            # start installation wizard
            Logger.debug('Electrum: Wallet not found. Launching install wizard')
            wizard = Factory.InstallWizard(config, self.network, storage)
            wizard.bind(on_wizard_complete=self.on_wizard_complete)
            wizard.run(action)
        else:
            wallet.start_threads(self.network)
            self.on_wizard_complete(None, wallet)

        self.on_resume()
Exemplo n.º 29
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.º 30
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.º 31
0
 def on_seed(_dlg, btn):
     _dlg.close()
     if btn is _dlg.ids.back:
         self.run('new')
         return
     text = _dlg.get_seed_text()
     if Wallet.should_encrypt(text):
         self.run('enter_pin', (text,))
     else:
         self.run('add_seed', (text, None))
Exemplo n.º 32
0
    def main(self, url):

        storage = WalletStorage(self.config)
        if storage.file_exists:
            wallet = Wallet(storage)
            action = wallet.get_action()
        else:
            action = 'new'

        if action is not None:
            import installwizard
            wizard = installwizard.InstallWizard(self.config, self.network, storage)
            wallet = wizard.run(action)
            if not wallet: 
                exit()
        else:
            wallet.start_threads(self.network)

        # init tray
        self.dark_icon = self.config.get("dark_icon", False)
        icon = QIcon(":icons/electrum_dark_icon.png") if self.dark_icon else QIcon(':icons/electrum_light_icon.png')
        self.tray = QSystemTrayIcon(icon, None)
        self.tray.setToolTip('Electrum')
        self.tray.activated.connect(self.tray_activated)
        self.build_tray_menu()
        self.tray.show()

        # main window
        self.main_window = w = ElectrumWindow(self.config, self.network, self)
        self.current_window = self.main_window

        #lite window
        self.init_lite()

        # plugins that need to change the GUI do it here
        run_hook('init')

        w.load_wallet(wallet)

        s = Timer()
        s.start()

        self.windows.append(w)
        if url: 
            self.set_url(url)

        w.app = self.app
        w.connect_slots(s)
        w.update_wallet()

        self.app.exec_()

        # clipboard persistence
        # see http://www.mail-archive.com/[email protected]/msg17328.html
        event = QtCore.QEvent(QtCore.QEvent.Clipboard)
        self.app.sendEvent(self.app.clipboard(), event)

        wallet.stop_threads()
Exemplo n.º 33
0
    def __init__(self, config, network):
        self.network = network
        self.config = config
        storage = WalletStorage(config)
        if not storage.file_exists:
            print "Wallet not found. try 'electrum create'"
            exit()

        self.wallet = Wallet(storage)
        self.wallet.start_threads(network)
Exemplo n.º 34
0
 def on_seed(_dlg, btn):
     _dlg.close()
     if btn is _dlg.ids.back:
         self.run('new')
         return
     text = _dlg.get_seed_text()
     if Wallet.should_encrypt(text):
         self.run('enter_pin', (text, ))
     else:
         self.run('add_seed', (text, None))
Exemplo n.º 35
0
 def load_wallet_by_name(self, wallet_path):
     if not wallet_path:
         return
     config = self.electrum_config
     storage = WalletStorage(wallet_path)
     Logger.info('Electrum: Check for existing wallet')
     if storage.file_exists:
         wallet = Wallet(storage)
         action = wallet.get_action()
     else:
         action = 'new'
     if action is not None:
         # start installation wizard
         Logger.debug('Electrum: Wallet not found. Launching install wizard')
         wizard = Factory.InstallWizard(config, self.network, storage)
         wizard.bind(on_wizard_complete=lambda instance, wallet: self.load_wallet(wallet))
         wizard.run(action)
     else:
         self.load_wallet(wallet)
     self.on_resume()
Exemplo n.º 36
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.º 37
0
    def create_or_load_wallet(self):
        wallet = Wallet(self.storage)
        if not self.storage.file_exists:
            try:
                seed = wallet.make_seed()
                wallet.init_seed(seed)
                wallet.save_seed(self.__password__())
                wallet.synchronize()
                config_entry = Configuration.objects.get()
                config_entry.wallet_seed = str(seed)
                config_entry.save()
            except Exception:
                exc_info = sys.exc_info()
                message = str(exc_info[0]) + ' - ' + str(exc_info[1])
                utils.log_error('btc processor create or load wallet', message)

        return wallet
Exemplo n.º 38
0
    def __init__(self, *, config, daemon, plugins):
        BaseElectrumGui.__init__(self,
                                 config=config,
                                 daemon=daemon,
                                 plugins=plugins)
        self.network = daemon.network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists():
            print("Wallet not found. try 'electrum create'")
            exit()
        if storage.is_encrypted():
            password = getpass.getpass('Password:', stream=None)
            storage.decrypt(password)

        db = WalletDB(storage.read(), manual_upgrades=False)

        self.done = 0
        self.last_balance = ""

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""

        self.wallet = Wallet(db, storage,
                             config=config)  # type: Optional[Abstract_Wallet]
        self.wallet.start_network(self.network)
        self.contacts = self.wallet.contacts

        self.register_callbacks()
        self.commands = [_("[h] - displays this help text"), \
                         _("[i] - display transaction history"), \
                         _("[o] - enter payment order"), \
                         _("[p] - print stored payment order"), \
                         _("[s] - send stored payment order"), \
                         _("[r] - show own receipt addresses"), \
                         _("[c] - display contacts"), \
                         _("[b] - print server banner"), \
                         _("[q] - quit")]
        self.num_commands = len(self.commands)
Exemplo n.º 39
0
    def __init__(self, config, daemon, plugins):
        self.config = config
        self.network = daemon.network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists:
            print("Wallet not found. try 'electrum-bitg create'")
            exit()
        if storage.is_encrypted():
            password = getpass.getpass('Password:'******'wallet_updated', 'network_updated', 'banner'])
        self.commands = [_("[h] - displays this help text"), \
                         _("[i] - display transaction history"), \
                         _("[o] - enter payment order"), \
                         _("[p] - print stored payment order"), \
                         _("[s] - send stored payment order"), \
                         _("[r] - show own receipt addresses"), \
                         _("[c] - display contacts"), \
                         _("[b] - print server banner"), \
                         _("[q] - quit") ]
        self.num_commands = len(self.commands)
Exemplo n.º 40
0
    def __init__(self, config, network):
        self.network = network
        self.config = config
        storage = WalletStorage(config)
        if not storage.file_exists:
            print "Wallet not found. try 'electrum create'"
            exit()

        self.done = 0
        self.last_balance = ""

        set_verbosity(False)

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""

        self.wallet = Wallet(storage)
        self.wallet.start_threads(network)

        self.wallet.network.register_callback('updated', self.updated)
        self.wallet.network.register_callback('connected', self.connected)
        self.wallet.network.register_callback('disconnected',
                                              self.disconnected)
        self.wallet.network.register_callback('disconnecting',
                                              self.disconnecting)
        self.wallet.network.register_callback('peers', self.peers)
        self.wallet.network.register_callback('banner', self.print_banner)
        self.commands = [_("[h] - displays this help text"), \
                         _("[i] - display transaction history"), \
                         _("[o] - enter payment order"), \
                         _("[p] - print stored payment order"), \
                         _("[s] - send stored payment order"), \
                         _("[r] - show own receipt addresses"), \
                         _("[c] - display contacts"), \
                         _("[b] - print server banner"), \
                         _("[q] - quit") ]
        self.num_commands = len(self.commands)
Exemplo n.º 41
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.º 42
0
 def load_wallet_by_name(self, wallet_path):
     if not wallet_path:
         return
     config = self.electrum_config
     try:
         storage = WalletStorage(wallet_path)
     except IOError:
         self.show_error("Cannot read wallet file")
         return
     if storage.file_exists:
         wallet = Wallet(storage)
         action = wallet.get_action()
     else:
         action = 'new'
     if action is not None:
         # start installation wizard
         Logger.debug('Electrum: Wallet not found. Launching install wizard')
         wizard = Factory.InstallWizard(config, self.network, storage)
         wizard.bind(on_wizard_complete=lambda instance, wallet: self.load_wallet(wallet))
         wizard.run(action)
     else:
         self.load_wallet(wallet)
     self.on_resume()
Exemplo n.º 43
0
    def load_wallet(self, wallet_dir, wallet_file):
        self.wallet_dir = wallet_dir
        self.wallet_file = wallet_file

        config = SimpleConfig(options={'cwd': self.wallet_dir, 'wallet_path': self.wallet_file})
        self.storage = WalletStorage(config.get_wallet_path())
        if self.storage.is_encrypted():
            self.storage.decrypt(self.wallet_password)

        if os.path.exists(config.get_wallet_path()):
            self.wallet = ElectrumWallet(self.storage)
            self.created = True
            self.start_daemon()
            self.open_wallet()
Exemplo n.º 44
0
Arquivo: stdio.py Projeto: homdx/pkpay
    def __init__(self, config, daemon, plugins):
        self.config = config
        self.network = daemon.network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists:
            print("Wallet not found. try 'pkpay create'")
            exit()
        if storage.is_encrypted():
            password = getpass.getpass('Password:'******'wallet_updated', 'network_updated', 'banner'])
        self.commands = [_("[h] - displays this help text"),
                         _("[i] - display transaction history"),
                         _("[o] - enter payment order"),
                         _("[p] - print stored payment order"),
                         _("[s] - send stored payment order"),
                         _("[r] - show own receipt addresses"),
                         _("[c] - display contacts"),
                         _("[b] - print server banner"),
                         _("[q] - quit")]
        self.num_commands = len(self.commands)
Exemplo n.º 45
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.º 46
0
    def create_or_load_wallet(self):
        wallet = Wallet(self.storage)
        if not self.storage.file_exists:
            try:
                seed = wallet.make_seed()
                wallet.init_seed(seed)
                wallet.save_seed(self.__password__())
                wallet.synchronize()
                config_entry = Configuration.objects.get()
                config_entry.wallet_seed = str(seed)
                config_entry.save()
            except Exception:
                exc_info = sys.exc_info()
                message = str(exc_info[0]) + ' - ' + str(exc_info[1])
                utils.log_error('btc processor create or load wallet', message)

        return wallet
Exemplo n.º 47
0
    def main(self, url=None):

        storage = WalletStorage(self.config)
        if not storage.file_exists:
            action = self.restore_or_create()
            if not action:
                exit()
            self.wallet = wallet = Wallet(storage)
            gap = self.config.get("gap_limit", 5)
            if gap != 5:
                wallet.gap_limit = gap
                wallet.storage.put("gap_limit", gap, True)

            if action == "create":
                seed = wallet.make_seed()
                show_seed_dialog(seed, None)
                r = change_password_dialog(False, None)
                password = r[2] if r else None
                wallet.add_seed(seed, password)
                wallet.create_master_keys(password)
                wallet.create_main_account(password)
                wallet.synchronize()  # generate first addresses offline

            elif action == "restore":
                seed = self.seed_dialog()
                if not seed:
                    exit()
                r = change_password_dialog(False, None)
                password = r[2] if r else None
                wallet.add_seed(seed, password)
                wallet.create_master_keys(password)
                wallet.create_main_account(password)

            else:
                exit()
        else:
            self.wallet = Wallet(storage)
            action = None

        self.wallet.start_threads(self.network)

        if action == "restore":
            self.restore_wallet(wallet)

        w = ElectrumWindow(self.wallet, self.config, self.network)
        if url:
            w.set_url(url)
        Gtk.main()
Exemplo n.º 48
0
    def __init__(self, config, network):

        self.config = config
        self.network = network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists:
            print "Wallet not found. try 'electrum create'"
            exit()

        self.wallet = Wallet(storage)
        self.wallet.start_threads(self.network)
        self.contacts = StoreDict(self.config, "contacts")

        locale.setlocale(locale.LC_ALL, "")
        self.encoding = locale.getpreferredencoding()

        self.stdscr = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.start_color()
        curses.use_default_colors()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_CYAN)
        self.stdscr.keypad(1)
        self.stdscr.border(0)
        self.maxy, self.maxx = self.stdscr.getmaxyx()
        self.set_cursor(0)
        self.w = curses.newwin(10, 50, 5, 5)

        set_verbosity(False)
        self.tab = 0
        self.pos = 0
        self.popup_pos = 0

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""
        self.history = None

        if self.network:
            self.network.register_callback("updated", self.update)
            self.network.register_callback("connected", self.refresh)
            self.network.register_callback("disconnected", self.refresh)
            self.network.register_callback("disconnecting", self.refresh)

        self.tab_names = [_("History"), _("Send"), _("Receive"), _("Contacts"), _("Wall")]
        self.num_tabs = len(self.tab_names)
Exemplo n.º 49
0
    def __init__(self, config, daemon, plugins):

        self.config = config
        self.network = daemon.network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists():
            print("Wallet not found. try 'electrum create'")
            exit()
        if storage.is_encrypted():
            password = getpass.getpass('Password:'******'')
        self.encoding = locale.getpreferredencoding()

        self.stdscr = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.start_color()
        curses.use_default_colors()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_CYAN)
        curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_WHITE)
        self.stdscr.keypad(1)
        self.stdscr.border(0)
        self.maxy, self.maxx = self.stdscr.getmaxyx()
        self.set_cursor(0)
        self.w = curses.newwin(10, 50, 5, 5)

        set_verbosity(False)
        self.tab = 0
        self.pos = 0
        self.popup_pos = 0

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""
        self.history = None

        if self.network:
            self.network.register_callback(self.update, ['updated'])

        self.tab_names = [_("History"), _("Send"), _("Receive"), _("Addresses"), _("Contacts"), _("Banner")]
        self.num_tabs = len(self.tab_names)
Exemplo n.º 50
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.º 51
0
    def on_creatrestore_complete(self, dialog, button):
        if not button:
            # soft back or escape button pressed
            return self.dispatch('on_wizard_complete', None)
        dialog.close()

        action = dialog.action
        if button == dialog.ids.create:
            # create
            # TODO take from UI instead of hardcoding
            #t = dialog.wallet_type
            t = 'standard'

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

            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'
        ]:
            self.password_dialog(wallet=wallet, mode=action)

        elif button == dialog.ids.restore:
            # restore
            wallet = None
            self.restore_seed_dialog(wallet)

        else:
            self.dispatch('on_wizard_complete', None)
Exemplo n.º 52
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.º 53
0
    def on_creatrestore_complete(self, dialog, button):
        if not button:
            # soft back or escape button pressed
            return self.dispatch('on_wizard_complete', None)
        dialog.close()

        action = dialog.action
        if button == dialog.ids.create:
            wallet = Wallet(self.storage)
            self.password_dialog(wallet=wallet, mode='create')

        elif button == dialog.ids.restore:
            wallet = None
            self.restore_seed_dialog(wallet)

        else:
            self.dispatch('on_wizard_complete', None)
Exemplo n.º 54
0
 def restore_wallet_from_seed(self, seed):
     try:
         self.wallet = Wallet.from_seed(str(seed), self.storage)
         if not self.wallet:
             raise Exception('invalid seed')
         self.wallet.save_seed(self.__password__())
         self.wallet.create_accounts(self.__password__())
         self.wallet.start_threads(self.network)
         self.wallet.restore(lambda x: x)
         self.wallet.synchronize()
         #self.wallet.update()
         config_entry = Configuration.objects.get()
         config_entry.wallet_seed = str(seed)
         config_entry.save()
     except:
         exc_info = sys.exc_info()
         message = str(exc_info[0]) + ' - ' + str(exc_info[1])
         log_error('btc processor restore from seed', message)
Exemplo n.º 55
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)
Exemplo n.º 56
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.º 57
0
    def __init__(self, config, network):
        self.network = network
        self.config = config
        storage = WalletStorage(config)
        if not storage.file_exists:
            print "Wallet not found. try 'electrum create'"
            exit()

	self.done = 0
        self.last_balance = ""

        set_verbosity(False)

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""

        self.wallet = Wallet(storage)
        self.wallet.start_threads(network)
        
        self.wallet.network.register_callback('updated', self.updated)
        self.wallet.network.register_callback('connected', self.connected)
        self.wallet.network.register_callback('disconnected', self.disconnected)
        self.wallet.network.register_callback('disconnecting', self.disconnecting)
        self.wallet.network.register_callback('peers', self.peers)
        self.wallet.network.register_callback('banner', self.print_banner)
        self.commands = [_("[h] - displays this help text"), \
                         _("[i] - display transaction history"), \
                         _("[o] - enter payment order"), \
                         _("[p] - print stored payment order"), \
                         _("[s] - send stored payment order"), \
                         _("[r] - show own receipt addresses"), \
                         _("[c] - display contacts"), \
                         _("[b] - print server banner"), \
                         _("[q] - quit") ]
        self.num_commands = len(self.commands)
Exemplo n.º 58
0
    def __init__(self, config, daemon, plugins):
        self.config = config
        self.network = daemon.network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists:
            print("Wallet not found. try 'electrum create'")
            exit()
        if storage.is_encrypted():
            password = getpass.getpass('Password:'******'updated', 'banner'])
        self.commands = [_("[h] - displays this help text"), \
                         _("[i] - display transaction history"), \
                         _("[o] - enter payment order"), \
                         _("[p] - print stored payment order"), \
                         _("[s] - send stored payment order"), \
                         _("[r] - show own receipt addresses"), \
                         _("[c] - display contacts"), \
                         _("[b] - print server banner"), \
                         _("[q] - quit") ]
        self.num_commands = len(self.commands)
Exemplo n.º 59
0
 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)