Register loaded wallets in daemon, to prevent a wallet from being opened twice.
Simplify the wizard logic.
This commit is contained in:
@@ -904,7 +904,7 @@ config = None
|
||||
|
||||
class ElectrumGui:
|
||||
|
||||
def __init__(self, _config, _network, plugins):
|
||||
def __init__(self, _config, _network, daemon, plugins):
|
||||
global wallet, network, contacts, config
|
||||
network = _network
|
||||
config = _config
|
||||
|
||||
@@ -1189,7 +1189,7 @@ class ElectrumWindow:
|
||||
tooltip = tx_hash + "\n%d confirmations"%conf if tx_hash else ''
|
||||
details = self.get_tx_details(tx_hash)
|
||||
|
||||
self.history_list.prepend( [tx_hash, conf_icon, time_str, label, is_default_label,
|
||||
self.history_list.prepend( [tx_hash, conf_icon, time_str, label, False,
|
||||
format_satoshis(value,True,self.num_zeros, whitespaces=True),
|
||||
format_satoshis(balance,False,self.num_zeros, whitespaces=True), tooltip, details] )
|
||||
if cursor: self.history_treeview.set_cursor( cursor )
|
||||
@@ -1284,7 +1284,7 @@ class ElectrumWindow:
|
||||
|
||||
class ElectrumGui():
|
||||
|
||||
def __init__(self, config, network, plugins):
|
||||
def __init__(self, config, network, daemon, plugins):
|
||||
self.network = network
|
||||
self.config = config
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ from main_window import ElectrumWindow
|
||||
|
||||
class ElectrumGui:
|
||||
|
||||
def __init__(self, config, network, plugins, app=None):
|
||||
def __init__(self, config, network, daemon, plugins):
|
||||
Logger.debug('ElectrumGUI: initialising')
|
||||
self.network = network
|
||||
self.config = config
|
||||
|
||||
@@ -66,7 +66,7 @@ class OpenFileEventFilter(QObject):
|
||||
|
||||
class ElectrumGui(MessageBoxMixin):
|
||||
|
||||
def __init__(self, config, network, plugins):
|
||||
def __init__(self, config, network, daemon, plugins):
|
||||
set_language(config.get('language'))
|
||||
# Uncomment this call to verify objects are being properly
|
||||
# GC-ed when windows are closed
|
||||
@@ -74,6 +74,7 @@ class ElectrumGui(MessageBoxMixin):
|
||||
# ElectrumWindow], interval=5)])
|
||||
self.network = network
|
||||
self.config = config
|
||||
self.daemon = daemon
|
||||
self.plugins = plugins
|
||||
self.windows = []
|
||||
self.efilter = OpenFileEventFilter(self.windows)
|
||||
@@ -134,12 +135,10 @@ class ElectrumGui(MessageBoxMixin):
|
||||
# Use a signal as can be called from daemon thread
|
||||
self.app.emit(SIGNAL('new_window'), path, uri)
|
||||
|
||||
def create_window_for_wallet(self, wallet, task):
|
||||
def create_window_for_wallet(self, wallet):
|
||||
w = ElectrumWindow(self, wallet)
|
||||
self.windows.append(w)
|
||||
self.build_tray_menu()
|
||||
if task:
|
||||
WaitingDialog(w, task[0], task[1])
|
||||
# FIXME: Remove in favour of the load_wallet hook
|
||||
run_hook('on_new_window', w)
|
||||
return w
|
||||
@@ -153,10 +152,10 @@ class ElectrumGui(MessageBoxMixin):
|
||||
break
|
||||
else:
|
||||
wizard = InstallWizard(self.config, self.app, self.plugins)
|
||||
result = wizard.open_wallet(self.network, path)
|
||||
if not result:
|
||||
wallet = self.daemon.load_wallet(path, wizard)
|
||||
if not wallet:
|
||||
return
|
||||
w = self.create_window_for_wallet(*result)
|
||||
w = self.create_window_for_wallet(wallet)
|
||||
|
||||
if uri:
|
||||
w.pay_to_URI(uri)
|
||||
|
||||
@@ -17,7 +17,8 @@ from electrum.mnemonic import prepare_seed
|
||||
from electrum.wizard import (WizardBase, UserCancelled,
|
||||
MSG_ENTER_PASSWORD, MSG_RESTORE_PASSPHRASE,
|
||||
MSG_COSIGNER, MSG_ENTER_SEED_OR_MPK,
|
||||
MSG_SHOW_MPK, MSG_VERIFY_SEED)
|
||||
MSG_SHOW_MPK, MSG_VERIFY_SEED,
|
||||
MSG_GENERATING_WAIT)
|
||||
|
||||
class CosignWidget(QWidget):
|
||||
size = 120
|
||||
@@ -134,6 +135,20 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||
if self.config.get('server') is None:
|
||||
self.network_dialog(network)
|
||||
|
||||
def show_restore(self, wallet, network, action):
|
||||
def on_finished(b):
|
||||
if action == 'restore':
|
||||
if network:
|
||||
if wallet.is_found():
|
||||
msg = _("Recovery successful")
|
||||
else:
|
||||
msg = _("No transactions found for this seed")
|
||||
else:
|
||||
msg = _("This wallet was restored offline. It may "
|
||||
"contain more addresses than displayed.")
|
||||
self.show_message(msg)
|
||||
WaitingDialog(self, MSG_GENERATING_WAIT, wallet.wait_until_synchronized, on_finished)
|
||||
|
||||
def set_layout(self, layout):
|
||||
w = QWidget()
|
||||
w.setLayout(layout)
|
||||
|
||||
@@ -12,7 +12,7 @@ import sys, getpass, datetime
|
||||
|
||||
class ElectrumGui:
|
||||
|
||||
def __init__(self, config, network, plugins):
|
||||
def __init__(self, config, network, daemon, plugins):
|
||||
self.network = network
|
||||
self.config = config
|
||||
storage = WalletStorage(config.get_wallet_path())
|
||||
|
||||
@@ -12,7 +12,7 @@ import tty, sys
|
||||
|
||||
class ElectrumGui:
|
||||
|
||||
def __init__(self, config, network, plugins):
|
||||
def __init__(self, config, network, daemon, plugins):
|
||||
|
||||
self.config = config
|
||||
self.network = network
|
||||
|
||||
Reference in New Issue
Block a user