本文整理汇总了Python中electrum_ltc.Wallet类的典型用法代码示例。如果您正苦于以下问题:Python Wallet类的具体用法?Python Wallet怎么用?Python Wallet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Wallet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
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: restore
def restore(self, t):
if t == 'standard':
text = self.enter_seed_dialog(MSG_ENTER_ANYTHING, None)
if not text:
return
password = self.password_dialog() if Wallet.is_seed(text) or Wallet.is_xprv(text) or Wallet.is_private_key(text) else None
wallet = Wallet.from_text(text, password, self.storage)
elif re.match('(\d+)of(\d+)', t):
n = int(re.match('(\d+)of(\d+)', t).group(2))
key_list = self.multi_seed_dialog(n - 1)
if not key_list:
return
password = self.password_dialog() if any(map(lambda x: Wallet.is_seed(x) or Wallet.is_xprv(x), key_list)) else None
wallet = Wallet.from_multisig(key_list, password, self.storage, t)
else:
self.storage.put('wallet_type', t, False)
# call the constructor to load the plugin (side effect)
Wallet(self.storage)
wallet = always_hook('installwizard_restore', self, self.storage)
if not wallet:
util.print_error("no wallet")
return
# create first keys offline
self.waiting_dialog(wallet.synchronize)
return wallet
示例3: load_wallet_file
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
示例4: task
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()
示例5: main
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: multi_mpk_dialog
def multi_mpk_dialog(self, xpub_hot, n):
vbox = QVBoxLayout()
scroll = QScrollArea()
scroll.setEnabled(True)
scroll.setWidgetResizable(True)
vbox.addWidget(scroll)
w = QWidget()
scroll.setWidget(w)
innerVbox = QVBoxLayout()
w.setLayout(innerVbox)
vbox0 = seed_dialog.show_seed_box(MSG_SHOW_MPK, xpub_hot, 'hot')
innerVbox.addLayout(vbox0)
entries = []
for i in range(n):
msg = _("Please enter the master public key of cosigner") + ' %d'%(i+1)
vbox2, seed_e2 = seed_dialog.enter_seed_box(msg, self, 'cold')
innerVbox.addLayout(vbox2)
entries.append(seed_e2)
vbox.addStretch(1)
button = OkButton(self, _('Next'))
vbox.addLayout(Buttons(CancelButton(self), button))
button.setEnabled(False)
f = lambda: button.setEnabled( map(lambda e: Wallet.is_xpub(self.get_seed_text(e)), entries) == [True]*len(entries))
for e in entries:
e.textChanged.connect(f)
self.set_layout(vbox)
if not self.exec_():
return
return map(lambda e: self.get_seed_text(e), entries)
示例7: __init__
def __init__(self, config, network, storage):
super(InstallWizard, self).__init__()
self.config = config
self.network = network
self.storage = storage
self.wallet = Wallet(self.storage)
self.is_restore = False
示例8: on_start
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()
示例9: on_verify_restore_ok
def on_verify_restore_ok(self, wallet, _dlg, btn, restore=False):
if btn in (_dlg.ids.back, _dlg.ids.but_close) :
_dlg.close()
Factory.CreateRestoreDialog(
on_release=self.on_creatrestore_complete).open()
return
seed = self.get_seed_text(_dlg.ids.text_input_seed)
if not seed:
return app.show_error(_("No seed!"), duration=.5)
_dlg.close()
if Wallet.is_seed(seed):
return self.password_dialog(wallet=wallet, mode='restore',
seed=seed)
elif Wallet.is_mpk(seed):
wallet = Wallet.from_mpk(seed, self.storage)
elif Wallet.is_address(seed):
wallet = Wallet.from_address(seed, self.storage)
elif Wallet.is_private_key(seed):
wallet = Wallet.from_private_key(seed, self.storage)
else:
return app.show_error(_('Not a valid seed. App will now exit'),
exit=True, modal=True, duration=.5)
return
示例10: on_seed
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))
示例11: load_wallet_by_name
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()
示例12: confirm_seed
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()
示例13: main
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()
示例14: load_wallet_by_name
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()
示例15: __init__
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-ltc 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)