本文整理汇总了Python中electrum_ltc.Wallet.start_threads方法的典型用法代码示例。如果您正苦于以下问题:Python Wallet.start_threads方法的具体用法?Python Wallet.start_threads怎么用?Python Wallet.start_threads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electrum_ltc.Wallet
的用法示例。
在下文中一共展示了Wallet.start_threads方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
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()
示例2: load_wallet_file
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
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
示例3: __init__
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
def __init__(self, _config, _network):
global wallet, network, contacts, config
network = _network
config = _config
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-LTC", 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)
示例4: main
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
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-LTC')
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()
示例5: main
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
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()
elif storage.get('wallet_type') in ['2of3'] and storage.get('seed') is None:
import installwizard
wizard = installwizard.InstallWizard(self.config, self.network, storage)
wallet = wizard.run(action= 'create2of3')
if not wallet:
exit()
else:
wallet = Wallet(storage)
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-LTC')
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: w.set_url(url)
w.app = self.app
w.connect_slots(s)
w.update_wallet()
self.app.exec_()
wallet.stop_threads()
示例6: on_start
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
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()
示例7: __init__
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
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)
示例8: __init__
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
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-ltc 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)
def main_command(self):
self.print_balance()
c = raw_input("enter command: ")
if c == "h" : self.print_commands()
elif c == "i" : self.print_history()
elif c == "o" : self.enter_order()
elif c == "p" : self.print_order()
elif c == "s" : self.send_order()
elif c == "r" : self.print_addresses()
elif c == "c" : self.print_contacts()
elif c == "b" : self.print_banner()
elif c == "n" : self.network_dialog()
elif c == "e" : self.settings_dialog()
elif c == "q" : self.done = 1
else: self.print_commands()
def peers(self):
print("got peers list:")
l = filter_protocol(self.wallet.network.get_servers(), 's')
for s in l:
print (s)
def connected(self):
print ("connected")
def disconnected(self):
print ("disconnected")
def disconnecting(self):
print ("disconnecting")
def updated(self):
s = self.get_balance()
if s != self.last_balance:
print(s)
self.last_balance = s
return True
def print_commands(self):
self.print_list(self.commands, "Available commands")
def print_history(self):
width = [20, 40, 14, 14]
delta = (80 - sum(width) - 4)/3
format_str = "%"+"%d"%width[0]+"s"+"%"+"%d"%(width[1]+delta)+"s"+"%" \
+ "%d"%(width[2]+delta)+"s"+"%"+"%d"%(width[3]+delta)+"s"
b = 0
messages = []
for item in self.wallet.get_tx_history():
tx_hash, confirmations, is_mine, value, fee, balance, timestamp = item
if confirmations:
try:
time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3]
except Exception:
time_str = "unknown"
else:
time_str = 'pending'
label, is_default_label = self.wallet.get_label(tx_hash)
#.........这里部分代码省略.........
示例9: run
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
def run(self, action, wallet_type):
if action in ['create', 'restore']:
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':
lang = self.config.get('language')
seed = wallet.make_seed(lang)
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':
wallet.create_main_account(password)
self.waiting_dialog(wallet.synchronize)
else:
f = always_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
示例10: InstallWizard
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
#.........这里部分代码省略.........
apply(f, *args)
else:
raise BaseException("unknown action", action)
def new(self):
def on_release(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:
self.run('create')
elif button == dialog.ids.restore:
self.run('restore')
else:
self.dispatch('on_wizard_complete', None)
CreateRestoreDialog(on_release=on_release).open()
def restore(self):
self.is_restore = True
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))
# fixme: sync
msg = _('You may also enter an extended public key, to create a watching-only wallet')
RestoreSeedDialog(test=Wallet.is_any, message=msg, on_release=on_seed).open()
def add_seed(self, text, password):
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()
msg= _("Electrum is generating your addresses, please wait.")
self.waiting_dialog(task, msg, self.terminate)
def create(self):
self.is_restore = False
seed = self.wallet.make_seed()
msg = _("If you forget your PIN or lose your device, your seed phrase will be the "
"only way to recover your funds.")
def on_ok(_dlg, _btn):
_dlg.close()
if _btn == _dlg.ids.confirm:
self.run('confirm_seed', (seed,))
else:
self.run('new')
ShowSeedDialog(message=msg, seed_text=seed, on_release=on_ok).open()
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()
def enter_pin(self, seed):
def callback(pin):
self.run('confirm_pin', (seed, pin))
popup = PasswordDialog('Choose a PIN code', callback)
popup.open()
def confirm_pin(self, seed, pin):
def callback(conf):
if conf == pin:
self.run('add_seed', (seed, pin))
else:
app.show_error(_('PIN mismatch'), duration=.5)
self.run('enter_pin', (seed,))
popup = PasswordDialog('Confirm your PIN code', callback)
popup.open()
def terminate(self):
self.wallet.start_threads(self.network)
#if self.is_restore:
# if self.wallet.is_found():
# app.show_info(_("Recovery successful"), duration=.5)
# else:
# app.show_info(_("No transactions found for this seed"), duration=.5)
self.dispatch('on_wizard_complete', self.wallet)
def on_wizard_complete(self, wallet):
"""overriden by main_window"""
pass
示例11: ElectrumGui
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
class ElectrumGui():
def __init__(self, config, network):
self.network = network
self.config = config
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':
wallet.init_seed(None)
show_seed_dialog(wallet, None, None)
r = change_password_dialog(False, None)
password = r[2] if r else None
wallet.save_seed(password)
wallet.synchronize() # generate first addresses offline
elif action == 'restore':
seed = self.seed_dialog()
wallet.init_seed(seed)
r = change_password_dialog(False, None)
password = r[2] if r else None
wallet.save_seed(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 restore_or_create(self):
return restore_create_dialog()
def seed_dialog(self):
return run_recovery_dialog()
def network_dialog(self):
return run_network_dialog( self.network, parent=None )
def restore_wallet(self, wallet):
dialog = Gtk.MessageDialog(
parent = None,
flags = Gtk.DialogFlags.MODAL,
buttons = Gtk.ButtonsType.CANCEL,
message_format = "Please wait..." )
dialog.show()
def recover_thread( wallet, dialog ):
wallet.restore(lambda x:x)
GObject.idle_add( dialog.destroy )
thread.start_new_thread( recover_thread, ( wallet, dialog ) )
r = dialog.run()
dialog.destroy()
if r==Gtk.ResponseType.CANCEL: return False
if not wallet.is_found():
show_message("No transactions found for this seed")
return True
示例12: run
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
def run(self, action):
if action == 'new':
action, wallet_type = self.restore_or_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)
elif action == 'add_cosigner':
xpub_hot = wallet.master_public_keys.get("m/")
r = self.multi_mpk_dialog(xpub_hot, 1)
if not r:
return
xpub_cold = r[0]
wallet.add_master_public_key("cold/", xpub_cold)
elif action == 'add_two_cosigners':
xpub_hot = wallet.master_public_keys.get("m/")
r = self.multi_mpk_dialog(xpub_hot, 2)
if not r:
return
xpub1, xpub2 = r
wallet.add_master_public_key("cold/", xpub1)
wallet.add_master_public_key("remote/", xpub2)
elif action == 'create_accounts':
wallet.create_accounts(password)
self.waiting_dialog(wallet.synchronize)
elif action == 'create_cold_seed':
self.create_cold_seed(wallet)
return
else:
r = run_hook('install_wizard_action', self, wallet, action)
if not r:
raise BaseException('unknown wizard action', action)
# 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:
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
示例13: run
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
def run(self):
action = self.restore_or_create()
if not action:
return
#gap = self.config.get('gap_limit', 5)
#if gap != 5:
# wallet.gap_limit = gap
# wallet.storage.put('gap_limit', gap, True)
if action == 'create':
wallet = Wallet(self.storage)
wallet.init_seed(None)
if not self.show_seed(wallet):
return
if not self.verify_seed(wallet):
return
ok, old_password, password = self.password_dialog(wallet)
def create():
wallet.save_seed(password)
wallet.synchronize() # generate first addresses offline
self.waiting_dialog(create)
elif action == 'restore':
seed = self.seed_dialog()
if not Wallet.is_seed(seed):
return
wallet = Wallet.from_seed(seed, self.storage)
ok, old_password, password = self.password_dialog(wallet)
wallet.save_seed(password)
elif action == 'watching':
mpk = self.mpk_dialog()
if not mpk:
return
wallet = Wallet.from_mpk(mpk, self.storage)
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
示例14: run_wallet_type
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
def run_wallet_type(self, action, wallet_type):
if action in ['create', 'restore']:
if wallet_type == 'multisig':
wallet_type = self.multisig_choice()
if not wallet_type:
return
elif wallet_type == 'hardware':
hardware_wallets = []
for item in electrum.wallet.wallet_types:
t, name, description, loader = item
if t == 'hardware':
try:
p = loader()
except:
util.print_error("cannot load plugin for:", name)
continue
if p:
hardware_wallets.append((name, description))
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
# load wallet in plugins
always_hook('installwizard_load_wallet', wallet, self)
while action is not None:
util.print_error("installwizard:", wallet, action)
if action == 'create_seed':
lang = self.config.get('language')
seed = wallet.make_seed(lang)
if not self.show_seed(seed, None):
return
self.app.clipboard().clear()
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_cosigners':
n = int(re.match('(\d+)of(\d+)', wallet.wallet_type).group(2))
xpub1 = wallet.master_public_keys.get("x1/")
r = self.multi_mpk_dialog(xpub1, n - 1)
if not r:
return
for i, xpub in enumerate(r):
wallet.add_master_public_key("x%d/"%(i+2), xpub)
elif action == 'create_accounts':
wallet.create_main_account(password)
self.waiting_dialog(wallet.synchronize)
else:
f = always_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:
# show network dialog if config does not exist
if self.config.get('server') is None:
self.network_dialog()
else:
QMessageBox.information(None, _('Warning'), _('You are offline'), _('OK'))
# start wallet threads
wallet.start_threads(self.network)
if action == 'restore':
self.waiting_dialog(lambda: wallet.wait_until_synchronized(self.waiting_label.setText))
if self.network:
msg = _("Recovery successful") if wallet.is_found() else _("No transactions found for this seed")
else:
#.........这里部分代码省略.........
示例15: main
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import start_threads [as 别名]
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.cmdline_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-LTC')
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()