本文整理汇总了Python中electrum_ltc.Wallet.get_action方法的典型用法代码示例。如果您正苦于以下问题:Python Wallet.get_action方法的具体用法?Python Wallet.get_action怎么用?Python Wallet.get_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electrum_ltc.Wallet
的用法示例。
在下文中一共展示了Wallet.get_action方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_wallet_file
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import get_action [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
示例2: main
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import get_action [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()
示例3: on_start
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import get_action [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()
示例4: load_wallet_by_name
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import get_action [as 别名]
def load_wallet_by_name(self, wallet_path):
if not wallet_path:
return
config = self.electrum_config
storage = WalletStorage(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=lambda instance, wallet: self.load_wallet(wallet))
wizard.run(action)
else:
self.load_wallet(wallet)
self.on_resume()
示例5: load_wallet_by_name
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import get_action [as 别名]
def load_wallet_by_name(self, wallet_path):
if not wallet_path:
return
config = self.electrum_config
try:
storage = WalletStorage(wallet_path)
except IOError:
self.show_error("Cannot read wallet file")
return
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=lambda instance, wallet: self.load_wallet(wallet))
wizard.run(action)
else:
self.load_wallet(wallet)
self.on_resume()
示例6: run_wallet_type
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import get_action [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:
#.........这里部分代码省略.........
示例7: run
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import get_action [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
示例8: main
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import get_action [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()
示例9: run
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import get_action [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