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()
def __init__(self, config, network): self.config = config self.network = network storage = WalletStorage(config) if not storage.file_exists: print "Wallet not found. try 'electrum-ixc create'" exit() self.wallet = Wallet(storage) self.wallet.start_threads(self.network) 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)
def __init__(self, config, _network): global wallet, network network = _network network.register_callback('updated', update_callback) network.register_callback('connected', update_callback) network.register_callback('disconnected', update_callback) network.register_callback('disconnecting', update_callback) storage = WalletStorage(config) if not storage.file_exists: action = self.restore_or_create() if not action: exit() wallet = Wallet(storage) if action == 'create': wallet.init_seed(None) self.show_seed() wallet.save_seed(None) wallet.synchronize() # generate first addresses offline elif action == 'restore': seed = self.seed_dialog() if not seed: exit() wallet.init_seed(str(seed)) wallet.save_seed(None) else: exit() wallet.start_threads(network) if action == 'restore': if not self.restore_wallet(): exit() self.password_dialog() else: wallet = Wallet(storage) wallet.start_threads(network)
def main(self, url): storage = WalletStorage(self.config) if storage.file_exists: try: wallet = Wallet(storage) except BaseException as e: QMessageBox.warning(None, _('Warning'), str(e), _('OK')) return 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: return 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-IXC') 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() # initial configuration if self.config.get('hide_gui') is True and self.tray.isVisible(): self.main_window.hide() self.lite_window.hide() else: if self.config.get('lite_mode') is True: self.go_lite() else: self.go_full() # plugins that need to change the GUI do it here run_hook('init_qt', self) 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() signal.signal(signal.SIGINT, lambda *args: self.app.quit()) self.app.exec_() if self.tray: self.tray.hide() # 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) w.close_wallet()
def run(self, action): if action == 'new': action, wallet_type = self.restore_or_create() if wallet_type == 'multisig': wallet_type = self.choice(_("Multi Signature Wallet"), 'Select wallet type', [('2of2', _("2 of 2")), ('2of3', _("2 of 3"))]) if not wallet_type: return elif wallet_type == 'hardware': hardware_wallets = map( lambda x: (x[1], x[2]), filter(lambda x: x[0] == 'hardware', electrum.wallet.wallet_types)) wallet_type = self.choice(_("Hardware Wallet"), 'Select your hardware wallet', hardware_wallets) if not wallet_type: return elif wallet_type == 'twofactor': wallet_type = '2fa' if action == 'create': self.storage.put('wallet_type', wallet_type, False) if action is None: return if action == 'restore': wallet = self.restore(wallet_type) if not wallet: return action = None else: wallet = Wallet(self.storage) action = wallet.get_action() # fixme: password is only needed for multiple accounts password = None while action is not None: util.print_error("installwizard:", wallet, action) if action == 'create_seed': seed = wallet.make_seed() if not self.show_seed(seed, None): return if not self.verify_seed(seed, None): return password = self.password_dialog() wallet.add_seed(seed, password) wallet.create_master_keys(password) elif action == 'add_cosigner': xpub1 = wallet.master_public_keys.get("x1/") r = self.multi_mpk_dialog(xpub1, 1) if not r: return xpub2 = r[0] wallet.add_master_public_key("x2/", xpub2) elif action == 'add_two_cosigners': xpub1 = wallet.master_public_keys.get("x1/") r = self.multi_mpk_dialog(xpub1, 2) if not r: return xpub2, xpub3 = r wallet.add_master_public_key("x2/", xpub2) wallet.add_master_public_key("x3/", xpub3) elif action == 'create_accounts': try: wallet.create_main_account(password) except BaseException as e: import traceback traceback.print_exc(file=sys.stdout) QMessageBox.information(None, _('Error'), str(e), _('OK')) return self.waiting_dialog(wallet.synchronize) else: f = run_hook('get_wizard_action', self, wallet, action) if not f: raise BaseException('unknown wizard action', action) r = f(wallet, self) if not r: return # next action action = wallet.get_action() 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: msg = _("Recovery successful") if wallet.is_found() else _( "No transactions found for this seed") else: msg = _( "This wallet was restored offline. It may contain more addresses than displayed." ) QMessageBox.information(None, _('Information'), msg, _('OK')) return wallet