Exemple #1
0
 def create_output_by_derivation():
     script_type = self.get_trezor_output_script_type(info.script_type)
     deriv = parse_path("/%d/%d" % index)
     multisig = self._make_multisig(m,
                                    [(xpub, deriv) for xpub in xpubs])
     txoutputtype = TxOutputType(multisig=multisig,
                                 amount=amount,
                                 address_n=parse_path(derivation +
                                                      "/%d/%d" % index),
                                 script_type=script_type)
     return txoutputtype
Exemple #2
0
 def sign_message(self, address_str, message):
     coin_name = self.plugin.get_coin_name()
     address_n = parse_path(address_str)
     with self.run_flow():
         return trezorlib.btc.sign_message(
             self.client,
             coin_name,
             address_n,
             message)
Exemple #3
0
 def get_xpub(self, bip32_path, xtype, creating=False):
     address_n = parse_path(bip32_path)
     with self.run_flow(creating_wallet=creating):
         node = trezorlib.btc.get_public_node(self.client, address_n).node
     return BIP32Node(xtype=xtype,
                      eckey=ecc.ECPubkey(node.public_key),
                      chaincode=node.chain_code,
                      depth=node.depth,
                      fingerprint=self.i4b(node.fingerprint),
                      child_number=self.i4b(node.child_num)).to_xpub()
Exemple #4
0
 def show_address(self, address_str, script_type, multisig=None):
     coin_name = self.plugin.get_coin_name()
     address_n = parse_path(address_str)
     with self.run_flow():
         return trezorlib.btc.get_address(
             self.client,
             coin_name,
             address_n,
             show_display=True,
             script_type=script_type,
             multisig=multisig)
Exemple #5
0
    def tx_inputs(self, tx, xpub_path, for_sig=False):
        inputs = []
        for txin in tx.inputs():
            txinputtype = TxInputType()
            if txin['type'] == 'coinbase':
                prev_hash = b"\x00" * 32
                prev_index = 0xffffffff  # signed int -1
            else:
                if for_sig:
                    x_pubkeys = txin['x_pubkeys']
                    xpubs = [parse_xpubkey(x) for x in x_pubkeys]
                    multisig = self._make_multisig(txin.get('num_sig'), xpubs,
                                                   txin.get('signatures'))
                    script_type = self.get_trezor_input_script_type(
                        txin['type'])
                    txinputtype = TxInputType(script_type=script_type,
                                              multisig=multisig)
                    # find which key is mine
                    for xpub, deriv in xpubs:
                        if xpub in xpub_path:
                            xpub_n = parse_path(xpub_path[xpub])
                            txinputtype.address_n = xpub_n + deriv
                            break

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

            if 'value' in txin:
                txinputtype.amount = txin['value']
            txinputtype.prev_hash = prev_hash
            txinputtype.prev_index = prev_index

            if txin.get('scriptSig') is not None:
                script_sig = bfh(txin['scriptSig'])
                txinputtype.script_sig = script_sig

            txinputtype.sequence = txin.get('sequence', 0xffffffff - 1)

            inputs.append(txinputtype)

        return inputs