def __init__(self, config, _network): global wallet, network, contacts 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) contacts = util.StoreDict(config, 'contacts') storage = WalletStorage(config.get_wallet_path()) if not storage.file_exists: action = self.restore_or_create() if not action: exit() password = droid.dialogGetPassword('Choose a password').result if password: password2 = droid.dialogGetPassword('Confirm password').result if password != password2: modal_dialog('Error', 'passwords do not match') exit() else: # set to None if it's an empty string password = None if action == 'create': wallet = Wallet(storage) seed = wallet.make_seed() modal_dialog('Your seed is:', seed) wallet.add_seed(seed, password) wallet.create_master_keys(password) wallet.create_main_account(password) elif action == 'restore': seed = self.seed_dialog() if not seed: exit() if not Wallet.is_seed(seed): exit() wallet = Wallet.from_seed(seed, password, storage) else: exit() msg = "Creating wallet" if action == 'create' else "Restoring wallet" droid.dialogCreateSpinnerProgress("Electrum-XVG", msg) droid.dialogShow() wallet.start_threads(network) if action == 'restore': wallet.restore(lambda x: None) else: wallet.synchronize() droid.dialogDismiss() droid.vibrate() else: wallet = Wallet(storage) wallet.start_threads(network)
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-xvg 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)
def __init__(self): global wallet self.qr_data = None storage = WalletStorage('/sdcard/electrum-xvg/authenticator') if not storage.file_exists: action = self.restore_or_create() if not action: exit() password = droid.dialogGetPassword('Choose a password').result if password: password2 = droid.dialogGetPassword('Confirm password').result if password != password2: modal_dialog('Error', 'Passwords do not match') exit() else: password = None if action == 'create': wallet = Wallet(storage) seed = wallet.make_seed() modal_dialog('Your seed is:', seed) elif action == 'import': seed = self.seed_dialog() if not seed: exit() if not Wallet.is_seed(seed): exit() wallet = Wallet.from_seed(seed, password, storage) else: exit() wallet.add_seed(seed, password) wallet.create_master_keys(password) wallet.create_main_account(password) else: wallet = Wallet(storage)
def main(self, url): last_wallet = self.config.get('gui_last_wallet') if last_wallet is not None and self.config.get('wallet_path') is None: if os.path.exists(last_wallet): self.config.read_only_options[ 'default_wallet_path'] = last_wallet try: storage = WalletStorage(self.config.get_wallet_path()) except BaseException as e: QMessageBox.warning(None, _('Warning'), str(e), _('OK')) self.config.set_key('gui_last_wallet', None) return 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: wallet = self.run_wizard(storage, 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-XVG') 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 interact with main window run_hook('init_qt', self) w.load_wallet(wallet) # 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() s = Timer() s.start() self.windows.append(w) if url: self.set_url(url) w.connect_slots(s) 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()