示例#1
0
async def layout_get_address(ctx, msg):
    from trezor.messages.Address import Address
    from trezor.messages.FailureType import ProcessError
    from ..common import coins
    from ..common import seed
    from ..wallet.sign_tx import addresses

    if msg.multisig:
        raise wire.FailureError(ProcessError,
                                'GetAddress.multisig is unsupported')

    address_n = msg.address_n or ()
    coin_name = msg.coin_name or 'Bitcoin'
    coin = coins.by_name(coin_name)

    node = await seed.derive_node(ctx, address_n)
    address = addresses.get_address(msg.script_type, coin, node)

    if msg.show_display:
        while True:
            if await _show_address(ctx, address):
                break
            if await _show_qr(ctx, address):
                break

    return Address(address=address)
示例#2
0
async def get_address(ctx, msg, keychain):
    coin_name = msg.coin_name or "Bitcoin"
    coin = coins.by_name(coin_name)

    await validate_path(
        ctx,
        addresses.validate_full_path,
        keychain,
        msg.address_n,
        coin.curve_name,
        coin=coin,
        script_type=msg.script_type,
    )

    node = keychain.derive(msg.address_n, coin.curve_name)
    address = addresses.get_address(msg.script_type, coin, node, msg.multisig)
    address_short = addresses.address_short(coin, address)
    if msg.script_type == InputScriptType.SPENDWITNESS:
        address_qr = address.upper()  # bech32 address
    else:
        address_qr = address  # base58 address

    if msg.show_display:
        if msg.multisig:
            desc = "Multisig %d of %d" % (msg.multisig.m, len(msg.multisig.pubkeys))
        else:
            desc = address_n_to_str(msg.address_n)

        while True:
            if await show_address(ctx, address_short, desc=desc):
                break
            if await show_qr(ctx, address_qr, desc=desc):
                break

    return Address(address=address)
示例#3
0
async def get_address(ctx, msg):
    coin_name = msg.coin_name or "Bitcoin"
    coin = coins.by_name(coin_name)

    node = await seed.derive_node(ctx, msg.address_n, curve_name=coin.curve_name)
    address = addresses.get_address(msg.script_type, coin, node, msg.multisig)
    address_short = addresses.address_short(coin, address)

    if msg.show_display:
        if msg.multisig:
            desc = "Multisig %d of %d" % (msg.multisig.m, len(msg.multisig.pubkeys))
        else:
            desc = address_n_to_str(msg.address_n)
        while True:
            if await show_address(ctx, address_short, desc=desc):
                break
            if await show_qr(
                ctx,
                address.upper()
                if msg.script_type == InputScriptType.SPENDWITNESS
                else address,
                desc=desc,
            ):
                break

    return Address(address=address)
示例#4
0
async def get_address(ctx: wire.Context, msg: GetAddress, keychain: Keychain,
                      coin: CoinInfo) -> Address:
    if msg.show_display:
        # skip soft-validation for silent calls
        await validate_path(
            ctx,
            keychain,
            msg.address_n,
            validate_path_against_script_type(coin, msg),
        )

    node = keychain.derive(msg.address_n)

    address = addresses.get_address(msg.script_type, coin, node, msg.multisig)
    address_short = addresses.address_short(coin, address)
    if coin.segwit and msg.script_type == InputScriptType.SPENDWITNESS:
        address_qr = address.upper()  # bech32 address
    elif coin.cashaddr_prefix is not None:
        address_qr = address.upper()  # cashaddr address
    else:
        address_qr = address  # base58 address

    if msg.multisig:
        multisig_xpub_magic = coin.xpub_magic
        if coin.segwit and not msg.ignore_xpub_magic:
            if (msg.script_type == InputScriptType.SPENDWITNESS
                    and coin.xpub_magic_multisig_segwit_native is not None):
                multisig_xpub_magic = coin.xpub_magic_multisig_segwit_native
            elif (msg.script_type == InputScriptType.SPENDP2SHWITNESS
                  and coin.xpub_magic_multisig_segwit_p2sh is not None):
                multisig_xpub_magic = coin.xpub_magic_multisig_segwit_p2sh

    if msg.show_display:
        if msg.multisig:
            if msg.multisig.nodes:
                pubnodes = msg.multisig.nodes
            else:
                pubnodes = [hd.node for hd in msg.multisig.pubkeys]
            multisig_index = multisig_pubkey_index(msg.multisig,
                                                   node.public_key())

            desc = "Multisig %d of %d" % (msg.multisig.m, len(pubnodes))
            await show_address(
                ctx,
                address=address_short,
                address_qr=address_qr,
                desc=desc,
                multisig_index=multisig_index,
                xpubs=_get_xpubs(coin, multisig_xpub_magic, pubnodes),
            )
        else:
            desc = address_n_to_str(msg.address_n)
            await show_address(ctx,
                               address=address_short,
                               address_qr=address_qr,
                               desc=desc)

    return Address(address=address)
async def get_address(ctx, msg, keychain):
    coin_name = msg.coin_name or "Bitcoin"
    coin = coins.by_name(coin_name)

    await validate_path(
        ctx,
        addresses.validate_full_path,
        keychain,
        msg.address_n,
        coin.curve_name,
        coin=coin,
        script_type=msg.script_type,
    )

    node = keychain.derive(msg.address_n, coin.curve_name)
    address = addresses.get_address(msg.script_type, coin, node, msg.multisig)
    address_short = addresses.address_short(coin, address)
    if msg.script_type == InputScriptType.SPENDWITNESS:
        address_qr = address.upper()  # bech32 address
    elif coin.cashaddr_prefix is not None:
        address_qr = address.upper()  # cashaddr address
    else:
        address_qr = address  # base58 address

    if msg.show_display:
        if msg.multisig:
            if msg.multisig.nodes:
                pubnodes = msg.multisig.nodes
            else:
                pubnodes = [hd.node for hd in msg.multisig.pubkeys]
            multisig_index = multisig_pubkey_index(msg.multisig,
                                                   node.public_key())
            desc = "Multisig %d of %d" % (msg.multisig.m, len(pubnodes))
            while True:
                if await show_address(ctx, address_short, desc=desc):
                    break
                if await show_qr(ctx, address_qr, desc=desc, cancel="XPUBs"):
                    break
                if await show_xpubs(ctx, coin, pubnodes, multisig_index):
                    break
        else:
            desc = address_n_to_str(msg.address_n)
            while True:
                if await show_address(ctx, address_short, desc=desc):
                    break
                if await show_qr(ctx, address_qr, desc=desc):
                    break

    return Address(address=address)
示例#6
0
async def get_address(ctx, msg):
    coin_name = msg.coin_name or 'Bitcoin'
    coin = coins.by_name(coin_name)

    node = await seed.derive_node(ctx, msg.address_n)
    address = addresses.get_address(msg.script_type, coin, node, msg.multisig)
    address_short = address[len(coin.cashaddr_prefix) + 1:] if coin.cashaddr_prefix is not None else address

    if msg.show_display:
        while True:
            if await _show_address(ctx, address_short):
                break
            if await _show_qr(ctx, address.upper() if msg.script_type == InputScriptType.SPENDWITNESS else address):
                break

    return Address(address=address)
示例#7
0
async def get_address(ctx: wire.Context, msg: GetAddress, keychain: Keychain,
                      coin: CoinInfo) -> Address:
    if msg.show_display:
        # skip soft-validation for silent calls
        await validate_path(
            ctx,
            keychain,
            msg.address_n,
            validate_path_against_script_type(coin, msg),
        )

    node = keychain.derive(msg.address_n)

    address = addresses.get_address(msg.script_type, coin, node, msg.multisig)
    address_short = addresses.address_short(coin, address)
    if msg.script_type == InputScriptType.SPENDWITNESS:
        address_qr = address.upper()  # bech32 address
    elif coin.cashaddr_prefix is not None:
        address_qr = address.upper()  # cashaddr address
    else:
        address_qr = address  # base58 address

    if msg.show_display:
        if msg.multisig:
            if msg.multisig.nodes:
                pubnodes = msg.multisig.nodes
            else:
                pubnodes = [hd.node for hd in msg.multisig.pubkeys]
            multisig_index = multisig_pubkey_index(msg.multisig,
                                                   node.public_key())
            desc = "Multisig %d of %d" % (msg.multisig.m, len(pubnodes))
            while True:
                if await show_address(ctx, address_short, desc=desc):
                    break
                if await show_qr(ctx, address_qr, desc=desc, cancel="XPUBs"):
                    break
                if await show_xpubs(ctx, coin, pubnodes, multisig_index):
                    break
        else:
            desc = address_n_to_str(msg.address_n)
            while True:
                if await show_address(ctx, address_short, desc=desc):
                    break
                if await show_qr(ctx, address_qr, desc=desc):
                    break

    return Address(address=address)
示例#8
0
async def layout_get_address(session_id, msg):
    from trezor.messages.Address import Address
    from trezor.messages.FailureType import Other
    from ..common import coins
    from ..common import seed

    if msg.multisig:
        raise wire.FailureError(Other, 'GetAddress.multisig is unsupported')

    address_n = msg.address_n or ()
    coin_name = msg.coin_name or 'Bitcoin'

    node = await seed.get_root(session_id)
    node.derive_path(address_n)
    coin = coins.by_name(coin_name)
    address = node.address(coin.address_type)

    if msg.show_display:
        await _show_address(session_id, address)

    return Address(address=address)
示例#9
0
async def get_address(ctx, msg):
    coin_name = msg.coin_name or "Bitcoin"
    coin = coins.by_name(coin_name)

    node = await seed.derive_node(ctx,
                                  msg.address_n,
                                  curve_name=coin.curve_name)
    address = addresses.get_address(msg.script_type, coin, node, msg.multisig)
    address_short = addresses.address_short(coin, address)

    if msg.show_display:
        while True:
            if await show_address(ctx, address_short):
                break
            if await show_qr(
                    ctx,
                    address.upper() if msg.script_type
                    == InputScriptType.SPENDWITNESS else address,
            ):
                break

    return Address(address=address)