Exemplo n.º 1
0
    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']

            ptx = self.transactions.get(tx_hash)
            if ptx is None:
                ptx = self.network.synchronous_get([('blockchain.transaction.get', [tx_hash])])[0]
                ptx = Transaction(ptx)
            prev_tx[tx_hash] = ptx

            for x_pubkey in txin['x_pubkeys']:
                if not is_extended_pubkey(x_pubkey):
                    continue
                xpub = x_to_xpub(x_pubkey)
                for k, v in self.master_public_keys.items():
                    if v == xpub:
                        account_id = re.match("x/(\d+)'", k).group(1)
                        account_derivation = "44'/0'/%s'"%account_id
                xpub_path[xpub] = account_derivation

        self.plugin.sign_transaction(tx, prev_tx, xpub_path)
Exemplo n.º 2
0
    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']

            ptx = self.transactions.get(tx_hash)
            if ptx is None:
                ptx = self.network.synchronous_get([
                    ('blockchain.transaction.get', [tx_hash])
                ])[0]
                ptx = Transaction(ptx)
            prev_tx[tx_hash] = ptx

            for x_pubkey in txin['x_pubkeys']:
                if not is_extended_pubkey(x_pubkey):
                    continue
                xpub = x_to_xpub(x_pubkey)
                for k, v in self.master_public_keys.items():
                    if v == xpub:
                        account_id = re.match("x/(\d+)'", k).group(1)
                        account_derivation = "44'/5'/%s'" % account_id
                xpub_path[xpub] = account_derivation

        self.plugin.sign_transaction(tx, prev_tx, xpub_path)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)