Пример #1
0
 def create_output_by_address(tx_output: XTxOutput) -> TxOutputType:
     txoutputtype = TxOutputType()
     txoutputtype.amount = tx_output.value
     address = classify_tx_output(tx_output)
     if isinstance(address, Address):
         txoutputtype.script_type = OutputScriptType.PAYTOADDRESS
         txoutputtype.address = address.to_string()
     return txoutputtype
Пример #2
0
def recipient_to_output(address,
                        amount,
                        script_type=OutputScriptType.PAYTOADDRESS):
    output = TxOutputType(amount=int(amount), script_type=script_type)
    if isinstance(address, Address):
        output.address_n = address.path
    else:
        output.address = address
    return output
Пример #3
0
 def create_output_by_address():
     if address:
         return TxOutputType(
             amount=txout.value,
             script_type=OutputScriptType.PAYTOADDRESS,
             address=address,
         )
     else:
         return TxOutputType(
             amount=txout.value,
             script_type=OutputScriptType.PAYTOOPRETURN,
             op_return_data=trezor_validate_op_return_output_and_get_data(txout),
         )
Пример #4
0
        def create_output_by_address():
            txoutputtype = TxOutputType()
            txoutputtype.amount = amount
            if _type == TYPE_SCRIPT:
                script = address.to_script()
                # We only support OP_RETURN with one constant push
                if (script[0] == 0x6a and amount == 0 and
                    script[1] == len(script) - 2 and
                    script[1] <= 75):
                    txoutputtype.script_type = OutputScriptType.PAYTOOPRETURN
                    txoutputtype.op_return_data = script[2:]
                else:
                    raise Exception(_("Unsupported output script."))
            elif _type == TYPE_ADDRESS:
                txoutputtype.script_type = OutputScriptType.PAYTOADDRESS

                # ecash: addresses are not supported yet by trezor
                ui_addr_fmt = address.FMT_UI
                if ui_addr_fmt == address.FMT_CASHADDR:
                    ui_addr_fmt = address.FMT_CASHADDR_BCH

                addr_format = address.FMT_LEGACY
                if client.get_trezor_model() == 'T':
                    if client.atleast_version(2, 0, 8):
                        addr_format = ui_addr_fmt
                    elif client.atleast_version(2, 0, 7):
                        addr_format = address.FMT_CASHADDR_BCH
                else:
                    if client.atleast_version(1, 6, 2):
                        addr_format = ui_addr_fmt
                txoutputtype.address = address.to_full_string(addr_format)
            return txoutputtype
Пример #5
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
Пример #6
0
        def create_output_by_derivation():
            deriv = parse_path("/%d/%d" % index)
            multisig = self._make_multisig(m, [(xpub, deriv) for xpub in xpubs])
            script_type = OutputScriptType.PAYTOADDRESS if multisig is None else OutputScriptType.PAYTOMULTISIG

            txoutputtype = TxOutputType(
                multisig=multisig,
                amount=amount,
                address_n=parse_path(derivation + "/%d/%d" % index),
                script_type=script_type)
            return txoutputtype
Пример #7
0
 def create_output_by_address():
     txoutputtype = TxOutputType()
     txoutputtype.amount = txout.value
     if address:
         txoutputtype.script_type = OutputScriptType.PAYTOADDRESS
         txoutputtype.address = address
     else:
         txoutputtype.script_type = OutputScriptType.PAYTOOPRETURN
         txoutputtype.op_return_data = trezor_validate_op_return_output_and_get_data(txout)
     return txoutputtype
 def create_output_by_address():
     txoutputtype = TxOutputType()
     txoutputtype.amount = amount
     if _type == TYPE_SCRIPT:
         txoutputtype.script_type = OutputScriptType.PAYTOOPRETURN
         txoutputtype.op_return_data = trezor_validate_op_return_output_and_get_data(o)
     elif _type == TYPE_ADDRESS:
         txoutputtype.script_type = OutputScriptType.PAYTOADDRESS
         txoutputtype.address = address
     return txoutputtype
Пример #9
0
 def create_output_by_derivation():
     index, xpubs, m = info
     #script_type = self.get_trezor_output_script_type(info.script_type)
     script_type = OutputScriptType.PAYTOADDRESS
     deriv = TrezorClientBase.expand_path("/%d/%d" % index)
     multisig = self._make_multisig(m, [(xpub, deriv) for xpub in xpubs])
     txoutputtype = TxOutputType(
         multisig=multisig,
         amount=amount,
         address_n=TrezorClientBase.expand_path(derivation + "/%d/%d" % index),
         script_type=script_type)
     return txoutputtype
Пример #10
0
 def create_output_by_derivation(key_derivation: Sequence[int], xpubs,
         m: int) -> TxOutputType:
     multisig = self._make_multisig(m, [(xpub, key_derivation) for xpub in xpubs])
     if multisig is None:
         script_type = OutputScriptType.PAYTOADDRESS
     else:
         script_type = OutputScriptType.PAYTOMULTISIG
     return TxOutputType(
         multisig=multisig,
         amount=tx_output.value,
         address_n=(*account_derivation, *key_derivation),
         script_type=script_type
     )
Пример #11
0
 def create_output_by_address():
     txoutputtype = TxOutputType()
     txoutputtype.amount = tx_output.value
     address = classify_tx_output(tx_output)
     if isinstance(address, Address):
         txoutputtype.script_type = OutputScriptType.PAYTOADDRESS
         txoutputtype.address = address.to_string(coin=Net.COIN)
     elif isinstance(address, OP_RETURN_Output):
         txoutputtype.script_type = OutputScriptType.PAYTOOPRETURN
         txoutputtype.op_return_data = validate_op_return(tx_output)
     return txoutputtype
Пример #12
0
 def create_output_by_derivation():
     deriv = bip32_decompose_chain_string("m/%d/%d" % index)
     multisig = self._make_multisig(m, [(xpub, deriv) for xpub in xpubs])
     if multisig is None:
         script_type = OutputScriptType.PAYTOADDRESS
     else:
         script_type = OutputScriptType.PAYTOMULTISIG
     return TxOutputType(
         multisig=multisig,
         amount=tx_output.value,
         address_n=bip32_decompose_chain_string(derivation + "/%d/%d" % index),
         script_type=script_type
     )
Пример #13
0
 def create_output_by_derivation():
     script_type = self.get_trezor_output_script_type(txout.script_type)
     if len(txout.pubkeys) > 1:
         xpubs_and_deriv_suffixes = get_xpubs_and_der_suffixes_from_txinout(tx, txout)
         multisig = self._make_multisig(txout.num_sig, xpubs_and_deriv_suffixes)
     else:
         multisig = None
     my_pubkey, full_path = keystore.find_my_pubkey_in_txinout(txout)
     assert full_path
     txoutputtype = TxOutputType(
         multisig=multisig,
         amount=txout.value,
         address_n=full_path,
         script_type=script_type)
     return txoutputtype
Пример #14
0
 def create_output_by_address():
     txoutputtype = TxOutputType()
     txoutputtype.amount = amount
     if _type == TYPE_SCRIPT:
         txoutputtype.script_type = OutputScriptType.PAYTOOPRETURN
         txoutputtype.op_return_data = trezor_validate_op_return_output_and_get_data(o)
     elif _type == TYPE_ADDRESS:
         txoutputtype.script_type = OutputScriptType.PAYTOADDRESS
         txoutputtype.address = address
     return txoutputtype