本文整理汇总了Python中electrum.wallet.Multisig_Wallet类的典型用法代码示例。如果您正苦于以下问题:Python Multisig_Wallet类的具体用法?Python Multisig_Wallet怎么用?Python Multisig_Wallet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Multisig_Wallet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sign_transaction
def sign_transaction(self, tx, password):
Multisig_Wallet.sign_transaction(self, tx, password)
if tx.is_complete():
return
if not self.auth_code:
self.print_error("sign_transaction: no auth code")
return
long_user_id, short_id = self.get_user_id()
tx_dict = tx.as_dict()
raw_tx = tx_dict["hex"]
r = server.sign(short_id, raw_tx, self.auth_code)
if r:
raw_tx = r.get('transaction')
tx.update(raw_tx)
self.print_error("twofactor: is complete", tx.is_complete())
示例2: create_wallet
def create_wallet(self, text, password):
if self.wallet_type == 'standard':
self.wallet = Wallet.from_text(text, password, self.storage)
self.run('create_addresses')
elif self.wallet_type == 'multisig':
self.storage.put('wallet_type', self.multisig_type)
self.wallet = Multisig_Wallet(self.storage)
self.wallet.add_cosigner('x1/', text, password)
self.run('show_xpub_and_add_cosigners', (Wallet.is_xpub(text), password,))
示例3: create_wallet
def create_wallet(self, text, password):
if self.wallet_type == 'standard':
self.wallet = Wallet.from_text(text, password, self.storage)
self.run('create_addresses')
elif self.wallet_type == 'multisig':
self.storage.put('wallet_type', self.multisig_type)
self.wallet = Multisig_Wallet(self.storage)
self.wallet.add_seed(text, password)
self.wallet.create_master_keys(password)
self.run_wallet()
示例4: make_unsigned_transaction
def make_unsigned_transaction(self, coins, outputs, config, fixed_fee=None,
change_addr=None, is_sweep=False):
mk_tx = lambda o: Multisig_Wallet.make_unsigned_transaction(
self, coins, o, config, fixed_fee, change_addr)
fee = self.extra_fee(config) if not is_sweep else 0
if fee:
address = self.billing_info['billing_address']
fee_output = TxOutput(TYPE_ADDRESS, address, fee)
try:
tx = mk_tx(outputs + [fee_output])
except NotEnoughFunds:
# TrustedCoin won't charge if the total inputs is
# lower than their fee
tx = mk_tx(outputs)
if tx.input_value() >= fee:
raise
self.print_error("not charging for this tx")
else:
tx = mk_tx(outputs)
return tx
示例5: get_tx_fee
def get_tx_fee(self, tx):
fee = Multisig_Wallet.get_tx_fee(self, tx)
fee += self.extra_fee(tx)
return fee
示例6: estimated_fee
def estimated_fee(self, tx, fee_per_kb):
fee = Multisig_Wallet.estimated_fee(self, tx, fee_per_kb)
fee += self.extra_fee(tx)
return fee
示例7: BaseWizard
#.........这里部分代码省略.........
def restore_2fa(self):
self.storage.put('wallet_type', '2fa')
self.wallet = Wallet(self.storage)
self.wallet.plugin.on_restore_wallet(self.wallet, self)
def choose_hw(self):
hw_wallet_types, choices = self.plugins.hardware_wallets('create')
choices = zip(hw_wallet_types, choices)
title = _('Hardware wallet')
if choices:
msg = _('Select the type of hardware wallet: ')
else:
msg = ' '.join([
_('No hardware wallet support found on your system.'),
_('Please install the relevant libraries (eg python-trezor for Trezor).'),
])
self.choice_dialog(title=title, message=msg, choices=choices, run_next=self.on_hardware)
def on_hardware(self, hw_type):
self.hw_type = hw_type
if self.wallet_type == 'multisig':
self.create_hardware_multisig()
else:
title = _('Hardware wallet') + ' [%s]' % hw_type
message = _('Do you have a device, or do you want to restore a wallet using an existing seed?')
choices = [
('create_hardware_wallet', _('I have a device')),
('restore_hardware_wallet', _('Use hardware wallet seed')),
]
self.choice_dialog(title=title, message=message, choices=choices, run_next=self.run)
def create_hardware_multisig(self):
self.storage.put('wallet_type', self.multisig_type)
self.wallet = Multisig_Wallet(self.storage)
# todo: get the xpub from the plugin
self.run('create_wallet', xpub, None)
def create_hardware_wallet(self):
self.storage.put('wallet_type', self.hw_type)
self.wallet = Wallet(self.storage)
self.wallet.plugin.on_create_wallet(self.wallet, self)
self.terminate()
def restore_hardware_wallet(self):
self.storage.put('wallet_type', self.wallet_type)
self.wallet = Wallet(self.storage)
self.wallet.plugin.on_restore_wallet(self.wallet, self)
self.terminate()
def create_wallet(self, text, password):
if self.wallet_type == 'standard':
self.wallet = Wallet.from_text(text, password, self.storage)
self.run('create_addresses')
elif self.wallet_type == 'multisig':
self.storage.put('wallet_type', self.multisig_type)
self.wallet = Multisig_Wallet(self.storage)
self.wallet.add_cosigner('x1/', text, password)
self.stack = []
self.run('show_xpub_and_add_cosigners', (password,))
def show_xpub_and_add_cosigners(self, password):
xpub = self.wallet.master_public_keys.get('x1/')
self.show_xpub_dialog(xpub=xpub, run_next=lambda x: self.run('add_cosigners', password))
def add_cosigners(self, password):
i = self.wallet.get_missing_cosigner()
示例8: BaseWizard
#.........这里部分代码省略.........
def restore_2fa(self):
self.storage.put('wallet_type', '2fa')
self.wallet = Wallet(self.storage)
self.wallet.plugin.on_restore_wallet(self.wallet, self)
def choose_hw(self):
hw_wallet_types, choices = self.plugins.hardware_wallets('create')
choices = zip(hw_wallet_types, choices)
title = _('Hardware wallet')
if choices:
msg = _('Select the type of hardware wallet: ')
else:
msg = ' '.join([
_('No hardware wallet support found on your system.'),
_('Please install the relevant libraries (eg python-trezor for Trezor).'),
])
self.choice_dialog(title=title, message=msg, choices=choices, run_next=self.on_hardware)
def on_hardware(self, hw_type):
self.hw_type = hw_type
if self.wallet_type == 'multisig':
self.create_hardware_multisig()
else:
title = _('Hardware wallet') + ' [%s]' % hw_type
message = _('Do you have a device, or do you want to restore a wallet using an existing seed?')
choices = [
('create_hardware_wallet', _('I have a device')),
('restore_hardware_wallet', _('Use hardware wallet seed')),
]
self.choice_dialog(title=title, message=message, choices=choices, run_next=self.run)
def create_hardware_multisig(self):
self.storage.put('wallet_type', self.multisig_type)
self.wallet = Multisig_Wallet(self.storage)
# todo: get the xpub from the plugin
self.run('create_wallet', xpub, None)
def create_hardware_wallet(self):
self.storage.put('wallet_type', self.hw_type)
self.wallet = Wallet(self.storage)
self.wallet.plugin.on_create_wallet(self.wallet, self)
self.terminate()
def restore_hardware_wallet(self):
self.storage.put('wallet_type', self.wallet_type)
self.wallet = Wallet(self.storage)
self.wallet.plugin.on_restore_wallet(self.wallet, self)
self.terminate()
def create_wallet(self, text, password):
if self.wallet_type == 'standard':
self.wallet = Wallet.from_text(text, password, self.storage)
self.run('create_addresses')
elif self.wallet_type == 'multisig':
self.storage.put('wallet_type', self.multisig_type)
self.wallet = Multisig_Wallet(self.storage)
self.wallet.add_seed(text, password)
self.wallet.create_master_keys(password)
self.run_wallet()
def add_cosigners(self):
xpub = self.wallet.master_public_keys.get('x1/')
self.show_xpub_dialog(run_next=lambda x: self.add_cosigner(), xpub=xpub)
def add_cosigner(self):
def on_xpub(xpub):
self.wallet.add_cosigner(xpub)
i = self.wallet.get_missing_cosigner()
action = 'add_cosigner' if i else 'create_addresses'
self.run(action)
i = self.wallet.get_missing_cosigner()
title = _("Add Cosigner") + " %d"%(i-1)
message = _('Please paste your cosigners master public key, or scan it using the camera button.')
self.add_xpub_dialog(run_next=on_xpub, title=title, message=message, is_valid=Wallet.is_any)
def create_addresses(self):
def task():
self.wallet.create_main_account()
self.wallet.synchronize()
self.terminate()
msg= _("Electrum is generating your addresses, please wait.")
self.waiting_dialog(task, msg)
def create_seed(self):
from electrum.wallet import BIP32_Wallet
seed = BIP32_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.")
self.show_seed_dialog(run_next=self.confirm_seed, message=msg, seed_text=seed)
def confirm_seed(self, seed):
assert Wallet.is_seed(seed)
title = _('Confirm Seed')
msg = _('Please retype your seed phrase, to confirm that you properly saved it')
self.enter_seed_dialog(run_next=self.add_password, title=title, message=msg, is_valid=lambda x: x==seed)
def add_password(self, seed):
f = lambda x: self.create_wallet(seed, x)
self.request_password(run_next=f)
示例9: create_hardware_multisig
def create_hardware_multisig(self):
self.storage.put('wallet_type', self.multisig_type)
self.wallet = Multisig_Wallet(self.storage)
# todo: get the xpub from the plugin
self.run('create_wallet', xpub, None)
示例10: BaseWizard
class BaseWizard(object):
def __init__(self, config, network, storage):
super(BaseWizard, self).__init__()
self.config = config
self.network = network
self.storage = storage
self.wallet = None
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):
name = os.path.basename(self.storage.path)
msg = "\n".join([
_("Welcome to the Electrum installation wizard."),
_("The wallet '%s' does not exist.") % name,
_("What kind of wallet do you want to create?")
])
choices = [
(_('Standard wallet'), 'create_standard'),
(_('Multi-signature wallet'), 'create_multisig'),
]
self.choice_dialog(msg=msg, choices=choices, run_prev=self.cancel, run_next=self.run)
def choose_seed(self):
msg = ' '.join([
_("Do you want to create a new seed, or to restore a wallet using an existing seed?")
])
choices = [
(_('Create a new seed'), 'create_seed'),
(_('I already have a seed'), 'restore_seed'),
(_('Watching-only wallet'), 'restore_xpub')
]
self.choice_dialog(msg=msg, choices=choices, run_prev=self.new, run_next=self.run)
def create_multisig(self):
def f(m, n):
self.wallet_type = "%dof%d"%(m, n)
self.run('choose_seed')
name = os.path.basename(self.storage.path)
self.multisig_dialog(run_prev=self.new, run_next=f)
def restore_seed(self):
msg = _('Please type your seed phrase using the virtual keyboard.')
self.restore_seed_dialog(run_prev=self.new, run_next=self.enter_pin, test=Wallet.is_seed, message=msg)
def restore_xpub(self):
title = "MASTER PUBLIC KEY"
message = _('To create a watching-only wallet, paste your master public key, or scan it using the camera button.')
self.add_xpub_dialog(run_prev=self.new, run_next=lambda xpub: self.create_wallet(xpub, None), title=title, message=message, test=Wallet.is_mpk)
def create_standard(self):
self.wallet_type = 'standard'
self.run('choose_seed')
def create_wallet(self, text, password):
if self.wallet_type == 'standard':
self.wallet = Wallet.from_text(text, password, self.storage)
self.run('create_addresses')
else:
self.storage.put('wallet_type', self.wallet_type)
self.wallet = Multisig_Wallet(self.storage)
self.wallet.add_seed(text, password)
self.wallet.create_master_keys(password)
action = self.wallet.get_action()
self.run(action)
def add_cosigners(self):
xpub = self.wallet.master_public_keys.get('x1/')
self.show_xpub_dialog(run_prev=self.create_multisig, run_next=self.add_cosigner, xpub=xpub, test=Wallet.is_xpub)
def add_cosigner(self):
def on_xpub(xpub):
self.wallet.add_cosigner(xpub)
i = self.wallet.get_missing_cosigner()
action = 'add_cosigner' if i else 'create_main_account'
self.run(action)
title = "ADD COSIGNER"
message = _('Please paste your cosigners master public key, or scan it using the camera button.')
self.add_xpub_dialog(run_prev=self.add_cosigners, run_next=on_xpub, title=title, message=message, test=Wallet.is_xpub)
def create_main_account(self):
self.wallet.create_main_account()
self.run('create_addresses')
def create_addresses(self):
def task():
self.wallet.create_main_account()
self.wallet.synchronize()
msg= _("Electrum is generating your addresses, please wait.")
self.waiting_dialog(task, msg, on_complete=self.terminate)
#.........这里部分代码省略.........
示例11: estimated_fee
def estimated_fee(self, tx):
fee = Multisig_Wallet.estimated_fee(self, tx)
x = run_hook("extra_fee", tx)
if x:
fee += x
return fee
示例12: estimated_fee
def estimated_fee(self, tx, fee_per_kb):
fee = Multisig_Wallet.estimated_fee(self, tx, fee_per_kb)
x = run_hook('extra_fee', tx)
if x: fee += x
return fee
示例13: get_tx_fee
def get_tx_fee(self, tx):
fee = Multisig_Wallet.get_tx_fee(self, tx)
x = run_hook('extra_fee', tx)
if x: fee += x
return fee
示例14: get_action
def get_action(self):
if self.storage.file_exists:
self.wallet = Wallet(self.storage)
action = self.wallet.get_action()
else:
action = 'new'
return action
示例15: Wallet
def restore_2fa(self):
self.storage.put('wallet_type', '2fa')
self.wallet = Wallet(self.storage)
self.wallet.plugin.on_restore_wallet(self.wallet, self)