本文整理汇总了Python中electrum_ltc.Wallet.synchronize方法的典型用法代码示例。如果您正苦于以下问题:Python Wallet.synchronize方法的具体用法?Python Wallet.synchronize怎么用?Python Wallet.synchronize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electrum_ltc.Wallet
的用法示例。
在下文中一共展示了Wallet.synchronize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import synchronize [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)
示例2: __init__
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import synchronize [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)
示例3: check_create_table
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import synchronize [as 别名]
# 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
cur.execute("SELECT address, amount, confirmations FROM electrum_payments WHERE paid IS NULL;")
data = cur.fetchall()
# add pending requests to the wallet
for item in data:
示例4: InstallWizard
# 需要导入模块: from electrum_ltc import Wallet [as 别名]
# 或者: from electrum_ltc.Wallet import synchronize [as 别名]
class InstallWizard(Widget):
'''Installation Wizard. Responsible for instantiating the
creation/restoration of wallets.
events::
`on_wizard_complete` Fired when the wizard is done creating/ restoring
wallet/s.
'''
__events__ = ('on_wizard_complete', )
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
def waiting_dialog(self, task, msg, on_complete=None):
'''Perform a blocking task in the background by running the passed
method in a thread.
'''
def target():
# run your threaded function
try:
task()
except Exception as err:
Clock.schedule_once(lambda dt: app.show_error(str(err)))
# on completion hide message
Clock.schedule_once(lambda dt: app.info_bubble.hide(now=True), -1)
if on_complete:
on_complete()
app.show_info_bubble(
text=msg, icon='atlas://gui/kivy/theming/light/important',
pos=Window.center, width='200sp', arrow_pos=None, modal=True)
t = threading.Thread(target = target)
t.start()
def run(self, action, *args):
'''Entry point of our Installation wizard'''
if not action:
return
if hasattr(self, action):
f = getattr(self, action)
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()
#.........这里部分代码省略.........