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


Python account.BIP32_Account类代码示例

本文整理汇总了Python中electrum.account.BIP32_Account的典型用法代码示例。如果您正苦于以下问题:Python BIP32_Account类的具体用法?Python BIP32_Account怎么用?Python BIP32_Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: tx_inputs

    def tx_inputs(self, tx, for_sig=False):
        inputs = []
        for txin in tx.inputs:
            txinputtype = self.types.TxInputType()
            if txin.get('is_coinbase'):
                prev_hash = "\0"*32
                prev_index = 0xffffffff  # signed int -1
            else:
                if for_sig:
                    x_pubkeys = txin['x_pubkeys']
                    if len(x_pubkeys) == 1:
                        x_pubkey = x_pubkeys[0]
                        xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
                        xpub_n = self.client_class.expand_path(self.xpub_path[xpub])
                        txinputtype.address_n.extend(xpub_n + s)
                    else:
                        def f(x_pubkey):
                            if is_extended_pubkey(x_pubkey):
                                xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
                            else:
                                xpub = xpub_from_pubkey(x_pubkey.decode('hex'))
                                s = []
                            node = ckd_public.deserialize(xpub)
                            return self.types.HDNodePathType(node=node, address_n=s)
                        pubkeys = map(f, x_pubkeys)
                        multisig = self.types.MultisigRedeemScriptType(
                            pubkeys=pubkeys,
                            signatures=map(lambda x: x.decode('hex') if x else '', txin.get('signatures')),
                            m=txin.get('num_sig'),
                        )
                        txinputtype = self.types.TxInputType(
                            script_type=self.types.SPENDMULTISIG,
                            multisig=multisig
                        )
                        # find which key is mine
                        for x_pubkey in x_pubkeys:
                            if is_extended_pubkey(x_pubkey):
                                xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
                                if xpub in self.xpub_path:
                                    xpub_n = self.client_class.expand_path(self.xpub_path[xpub])
                                    txinputtype.address_n.extend(xpub_n + s)
                                    break

                prev_hash = unhexlify(txin['prevout_hash'])
                prev_index = txin['prevout_n']

            txinputtype.prev_hash = prev_hash
            txinputtype.prev_index = prev_index

            if 'scriptSig' in txin:
                script_sig = txin['scriptSig'].decode('hex')
                txinputtype.script_sig = script_sig

            if 'sequence' in txin:
                sequence = txin['sequence']
                txinputtype.sequence = sequence

            inputs.append(txinputtype)

        return inputs
开发者ID:andreas-h,项目名称:electrum,代码行数:60,代码来源:plugin.py

示例2: tx_inputs

    def tx_inputs(self, tx, for_sig=False):
        inputs = []
        for txin in tx.inputs:
            txinputtype = types.TxInputType()
            if txin.get("is_coinbase"):
                prev_hash = "\0" * 32
                prev_index = 0xFFFFFFFF  # signed int -1
            else:
                if for_sig:
                    x_pubkeys = txin["x_pubkeys"]
                    if len(x_pubkeys) == 1:
                        x_pubkey = x_pubkeys[0]
                        xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
                        xpub_n = self.get_client().expand_path(self.xpub_path[xpub])
                        txinputtype.address_n.extend(xpub_n + s)
                    else:

                        def f(x_pubkey):
                            if is_extended_pubkey(x_pubkey):
                                xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
                            else:
                                xpub = xpub_from_pubkey(x_pubkey.decode("hex"))
                                s = []
                            node = ckd_public.deserialize(xpub)
                            return types.HDNodePathType(node=node, address_n=s)

                        pubkeys = map(f, x_pubkeys)
                        multisig = types.MultisigRedeemScriptType(
                            pubkeys=pubkeys,
                            signatures=map(lambda x: x.decode("hex") if x else "", txin.get("signatures")),
                            m=txin.get("num_sig"),
                        )
                        txinputtype = types.TxInputType(script_type=types.SPENDMULTISIG, multisig=multisig)
                        # find which key is mine
                        for x_pubkey in x_pubkeys:
                            xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
                            if xpub in self.xpub_path:
                                xpub_n = self.get_client().expand_path(self.xpub_path[xpub])
                                txinputtype.address_n.extend(xpub_n + s)
                                break
                            else:
                                raise

                prev_hash = unhexlify(txin["prevout_hash"])
                prev_index = txin["prevout_n"]

            txinputtype.prev_hash = prev_hash
            txinputtype.prev_index = prev_index

            if "scriptSig" in txin:
                script_sig = txin["scriptSig"].decode("hex")
                txinputtype.script_sig = script_sig

            if "sequence" in txin:
                sequence = txin["sequence"]
                txinputtype.sequence = sequence

            inputs.append(txinputtype)

        return inputs
开发者ID:Geopay,项目名称:electrum-uno,代码行数:60,代码来源:trezor.py

示例3: tx_inputs

    def tx_inputs(self, tx, for_sig=False):
        inputs = []
        for txinput in tx.inputs:
            txinputtype = types.TxInputType()
            if ('is_coinbase' in txinput and txinput['is_coinbase']):
                prev_hash = "\0"*32
                prev_index = 0xffffffff # signed int -1
            else:

                if for_sig:
                    x_pubkey = txinput['x_pubkeys'][0]
                    xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
                    xpub_n = self.get_client().expand_path(self.xpub_path[xpub])
                    txinputtype.address_n.extend(xpub_n + s)

                prev_hash = unhexlify(txinput['prevout_hash'])
                prev_index = txinput['prevout_n']

            txinputtype.prev_hash = prev_hash
            txinputtype.prev_index = prev_index

            if 'scriptSig' in txinput:
                script_sig = txinput['scriptSig'].decode('hex')
                txinputtype.script_sig = script_sig

            if 'sequence' in txinput:
                sequence = txinput['sequence']
                txinputtype.sequence = sequence

            inputs.append(txinputtype)
            #TODO P2SH
        return inputs
开发者ID:gazdagruja,项目名称:electrum,代码行数:32,代码来源:trezor.py

示例4: f

 def f(x_pubkey):
     if is_extended_pubkey(x_pubkey):
         xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
     else:
         xpub = xpub_from_pubkey(x_pubkey.decode('hex'))
         s = []
     node = ckd_public.deserialize(xpub)
     return types.HDNodePathType(node=node, address_n=s)
开发者ID:FuzzyHobbit,项目名称:electrum,代码行数:8,代码来源:trezor.py

示例5: need_server

def need_server(wallet, tx):
    from electrum.account import BIP32_Account
    # Detect if the server is needed
    long_id, short_id = wallet.get_user_id()
    xpub3 = wallet.master_public_keys['x3/']
    for x in tx.inputs_to_sign():
        if x[0:2] == 'ff':
            xpub, sequence = BIP32_Account.parse_xpubkey(x)
            if xpub == xpub3:
                return True
    return False
开发者ID:CeeCeeCee,项目名称:electrum,代码行数:11,代码来源:qt.py

示例6: sign_transaction

    def sign_transaction(self, tx, password):
        if tx.is_complete():
            return
        if not self.check_proper_device():
            give_error('Wrong device or password')
        # previous transactions used as inputs
        prev_tx = {}
        # path of the xpubs that are involved
        xpub_path = {}
        for txin in tx.inputs:
            tx_hash = txin['prevout_hash']
            prev_tx[tx_hash] = self.transactions[tx_hash]
            address = txin['address']
            address_path = self.address_id(address)
            account_id, (change, address_index) = self.get_address_index(address)

            for x_pubkey in txin['x_pubkeys']:
                xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
                xpub_path[xpub] = "44'/0'/%s'"%account_id

        self.plugin.sign_transaction(tx, prev_tx, xpub_path)
开发者ID:gazdagruja,项目名称:electrum,代码行数:21,代码来源:trezor.py

示例7: can_sign_xpubkey

 def can_sign_xpubkey(self, x_pubkey):
     xpub, sequence = BIP32_Account.parse_xpubkey(x_pubkey)
     return xpub in self.master_public_keys.values()
开发者ID:FuzzyHobbit,项目名称:electrum,代码行数:3,代码来源:trezor.py

示例8: f

 def f(x_pubkey):
     xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
     node = ckd_public.deserialize(xpub)
     return types.HDNodePathType(node=node, address_n=s)
开发者ID:thelonecrouton,项目名称:electrum,代码行数:4,代码来源:trezor.py


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