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-vior 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 __init__(self, config, network): self.network = network self.config = config storage = WalletStorage(config) if not storage.file_exists: print "Wallet not found. try 'electrum-vior 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)
params = sys.argv[2:] + [my_password] ret = send_command(cmd, params) sys.exit(ret) conn = sqlite3.connect(database) # create table if needed check_create_table(conn) # init network config = SimpleConfig({'wallet_path': wallet_path}) network = Network(config) network.start(wait=True) # create watching_only wallet storage = WalletStorage(config) wallet = Wallet(storage) if not storage.file_exists: wallet.seed = '' wallet.create_watching_only_wallet(master_public_key, master_chain) wallet.synchronize = lambda: None # prevent address creation by the wallet wallet.start_threads(network) network.register_callback('updated', on_wallet_update) out_queue = Queue.Queue() thread.start_new_thread(server_thread, (conn, )) while not stopping: cur = conn.cursor() # read pending requests from table
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-VIOR') 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()
def run(self, action): if action == 'new': action, t = self.restore_or_create() if action is None: return if action == 'create': if t == 'standard': wallet = Wallet(self.storage) 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 == 'create_2fa_2': wallet = Wallet_2of3(self.storage) if action in ['create', 'create_2of2_1', 'create_2fa_2', 'create_2of3_1']: seed = wallet.make_seed() sid = None if action == 'create' else 'hot' if not self.show_seed(seed, sid): return if not self.verify_seed(seed, sid): return password = self.password_dialog() wallet.add_seed(seed, password) if action == 'create': wallet.create_accounts(password) self.waiting_dialog(wallet.synchronize) elif action == 'create_2of2_1': action = 'create_2of2_2' elif action == 'create_2of3_1': action = 'create_2of3_2' elif action == 'create_2fa_2': action = 'create_2fa_3' if action == 'create_2of2_2': xpub_hot = wallet.master_public_keys.get("m/") xpub = self.cold_mpk_dialog(xpub_hot) wallet.add_master_public_key("cold/", xpub) wallet.create_account() self.waiting_dialog(wallet.synchronize) if action == 'create_2of3_2': xpub_hot = wallet.master_public_keys.get("m/") xpub1, xpub2 = self.cold_mpk2_dialog(xpub_hot) wallet.add_master_public_key("cold/", xpub1) wallet.add_master_public_key("remote/", xpub2) wallet.create_account() self.waiting_dialog(wallet.synchronize) if action == 'create_2fa_3': run_hook('create_remote_key', wallet, self) if not wallet.master_public_keys.get("remote/"): return wallet.create_account() self.waiting_dialog(wallet.synchronize) if action == 'restore': 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_mpk(text): wallet = Wallet.from_mpk(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 ['2fa', '2of2','2of3']: r = self.double_seed_dialog() if not r: return text1, text2 = r password = self.password_dialog() if t == '2of2': wallet = Wallet_2of2(self.storage) elif t == '2of3': wallet = Wallet_2of3(self.storage) elif t == '2fa': wallet = Wallet_2of3(self.storage) 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_mpk(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) if t == '2of3': run_hook('restore_third_key', wallet, self) wallet.create_account() else: raise #if not self.config.get('server'): 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: if wallet.is_found(): QMessageBox.information(None, _('Information'), _("Recovery successful"), _('OK')) else: QMessageBox.information(None, _('Information'), _("No transactions found for this seed"), _('OK')) else: QMessageBox.information(None, _('Information'), _("This wallet was restored offline. It may contain more addresses than displayed."), _('OK')) return wallet