当前位置: 首页>>代码示例>>Python>>正文


Python Multisig_Wallet.get_action方法代码示例

本文整理汇总了Python中electrum.wallet.Multisig_Wallet.get_action方法的典型用法代码示例。如果您正苦于以下问题:Python Multisig_Wallet.get_action方法的具体用法?Python Multisig_Wallet.get_action怎么用?Python Multisig_Wallet.get_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electrum.wallet.Multisig_Wallet的用法示例。


在下文中一共展示了Multisig_Wallet.get_action方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BaseWizard

# 需要导入模块: from electrum.wallet import Multisig_Wallet [as 别名]
# 或者: from electrum.wallet.Multisig_Wallet import get_action [as 别名]
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)

#.........这里部分代码省略.........
开发者ID:maksverver,项目名称:electrum,代码行数:103,代码来源:base_wizard.py

示例2: BaseWizard

# 需要导入模块: from electrum.wallet import Multisig_Wallet [as 别名]
# 或者: from electrum.wallet.Multisig_Wallet import get_action [as 别名]
class BaseWizard(object):

    def __init__(self, config, network, path):
        super(BaseWizard, self).__init__()
        self.config  = config
        self.network = network
        self.storage = WalletStorage(path)
        self.wallet = None
        self.stack = []

    def run(self, *args):
        action = args[0]
        args = args[1:]
        self.stack.append((action, args))
        if not action:
            return
        if hasattr(self.wallet, 'plugin') and hasattr(self.wallet.plugin, action):
            f = getattr(self.wallet.plugin, action)
            apply(f, (self.wallet, self) + args)
        elif hasattr(self, action):
            f = getattr(self, action)
            apply(f, args)
        else:
            raise BaseException("unknown action", 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

    def get_wallet(self):
        if self.wallet and self.wallet.get_action() is None:
            return self.wallet

    def can_go_back(self):
        return len(self.stack)>1

    def go_back(self):
        if not self.can_go_back():
            return
        self.stack.pop()
        action, args = self.stack.pop()
        self.run(action, *args)

    def new(self):
        name = os.path.basename(self.storage.path)
        title = _("Welcome to the Electrum installation wizard.")
        message = '\n'.join([
            _("The wallet '%s' does not exist.") % name,
            _("What kind of wallet do you want to create?")
        ])
        wallet_kinds = [
            ('standard',  _("Standard wallet")),
            ('twofactor', _("Wallet with two-factor authentication")),
            ('multisig',  _("Multi-signature wallet")),
            ('hardware',  _("Hardware wallet")),
        ]
        registered_kinds = Wallet.categories()
        choices = [pair for pair in wallet_kinds if pair[0] in registered_kinds]
        self.choice_dialog(title = title, message=message, choices=choices, run_next=self.on_wallet_type)

    def on_wallet_type(self, choice):
        self.wallet_type = choice
        if choice == 'standard':
            action = 'choose_seed'
        elif choice == 'multisig':
            action = 'choose_multisig'
        elif choice == 'hardware':
            action = 'choose_hw'
        elif choice == 'twofactor':
            action = 'choose_seed'
        self.run(action)

    def choose_multisig(self):
        def on_multisig(m, n):
            self.multisig_type = "%dof%d"%(m, n)
            self.run('choose_seed')
        self.multisig_dialog(run_next=on_multisig)

    def choose_seed(self):
        title = _('Choose Seed')
        message = _("Do you want to create a new seed, or to restore a wallet using an existing seed?")
        if self.wallet_type == 'standard':
            choices = [
                ('create_seed', _('Create a new seed')),
                ('restore_seed', _('I already have a seed')),
                ('restore_from_key', _('Import keys')),
            ]
        elif self.wallet_type == 'twofactor':
            choices = [
                ('create_2fa', _('Create a new seed')),
                ('restore_2fa', _('I already have a seed')),
            ]
        elif self.wallet_type == 'multisig':
            choices = [
                ('create_seed', _('Create a new seed')),
                ('restore_seed', _('I already have a seed')),
#.........这里部分代码省略.........
开发者ID:CeeCeeCee,项目名称:electrum,代码行数:103,代码来源:base_wizard.py

示例3: BaseWizard

# 需要导入模块: from electrum.wallet import Multisig_Wallet [as 别名]
# 或者: from electrum.wallet.Multisig_Wallet import get_action [as 别名]
class BaseWizard(object):

    def __init__(self, config, network, path):
        super(BaseWizard, self).__init__()
        self.config  = config
        self.network = network
        self.storage = WalletStorage(path)
        self.wallet = None
        self.stack = []

    def run(self, action, *args):
        self.stack.append((action, args))
        if not action:
            return
        if hasattr(self.wallet, 'plugin'):
            if hasattr(self.wallet.plugin, action):
                f = getattr(self.wallet.plugin, action)
                apply(f, (self.wallet, self) + args)
        elif hasattr(self, action):
            f = getattr(self, action)
            apply(f, *args)
        else:
            raise BaseException("unknown action", 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

    def get_wallet(self):
        if self.wallet and self.wallet.get_action() is None:
            return self.wallet

    def can_go_back(self):
        return len(self.stack)>1

    def go_back(self):
        if not self.can_go_back():
            return
        self.stack.pop()
        action, args = self.stack.pop()
        self.run(action, *args)

    def run_wallet(self):
        self.stack = []
        action = self.wallet.get_action()
        if action:
            self.action_dialog(action=action, run_next=lambda x: self.run_wallet())

    def new(self):
        name = os.path.basename(self.storage.path)
        title = _("Welcome to the Electrum installation wizard.")
        message = '\n'.join([
            _("The wallet '%s' does not exist.") % name,
            _("What kind of wallet do you want to create?")
        ])
        wallet_kinds = [
            ('standard',  _("Standard wallet")),
            ('twofactor', _("Wallet with two-factor authentication")),
            ('multisig',  _("Multi-signature wallet")),
            ('hardware',  _("Hardware wallet")),
        ]
        registered_kinds = Wallet.categories()
        choices = [pair for pair in wallet_kinds if pair[0] in registered_kinds]
        self.choice_dialog(title = title, message=message, choices=choices, run_next=self.on_wallet_type)

    def on_wallet_type(self, choice):
        self.wallet_type = choice
        if choice == 'standard':
            action = 'choose_seed'
        elif choice == 'multisig':
            action = 'choose_multisig'
        elif choice == 'hardware':
            action = 'choose_hw'
        elif choice == 'twofactor':
            action = 'choose_seed'
        self.run(action)

    def choose_multisig(self):
        def on_multisig(m, n):
            self.multisig_type = "%dof%d"%(m, n)
            self.run('choose_seed')
        self.multisig_dialog(run_next=on_multisig)

    def choose_seed(self):
        title = _('Private Keys')
        message = _("Do you want to create a new seed, or to restore a wallet using an existing seed?")
        if self.wallet_type == 'standard':
            choices = [
                ('create_seed', _('Create a new seed')),
                ('restore_seed', _('I already have a seed')),
                ('restore_xpub', _('Watching-only wallet')),
            ]
        elif self.wallet_type == 'twofactor':
            choices = [
                ('create_2fa', _('Create a new seed')),
                ('restore_2fa', _('I already have a seed')),
#.........这里部分代码省略.........
开发者ID:ZeroHarbor,项目名称:electrum,代码行数:103,代码来源:base_wizard.py


注:本文中的electrum.wallet.Multisig_Wallet.get_action方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。