コード例 #1
0
    def test_both(self):
        pubkey = unhexlify('dfcc77d08588601702e02de2dc603f5c5281bea23baa894ae3b3b4778e5bbe40')
        self.assertEqual(public_key_from_address(address_from_public_key(pubkey)), pubkey)

        pubkey = unhexlify('53214e6155469c32fb882b1b1d94930d5445a78202867b7ddc6a33ad42ff4464')
        self.assertEqual(public_key_from_address(address_from_public_key(pubkey)), pubkey)

        pubkey = unhexlify('5ed4690134e5ef79b290ea1e7a4b8f3b6b3bcf287463c18bfe36baa030e7efbd')
        self.assertEqual(public_key_from_address(address_from_public_key(pubkey)), pubkey)
コード例 #2
0
    def test_pubkey_to_address(self):
        addr = address_from_public_key(
            unhexlify(
                '5d55642466b185b843152e9e219151dbc5892027ec40101a517bed5ca030c2e0'
            ))
        self.assertEqual(
            addr, 'GBOVKZBEM2YYLOCDCUXJ4IMRKHN4LCJAE7WEAEA2KF562XFAGDBOB64V')

        addr = address_from_public_key(
            unhexlify(
                '9ba568e6eec16bea4fed0f17b134a1d692eae199a578ba6fb44c0c24431bfdb4'
            ))
        self.assertEqual(
            addr, 'GCN2K2HG53AWX2SP5UHRPMJUUHLJF2XBTGSXROTPWRGAYJCDDP63J2U6')
コード例 #3
0
async def get_address(ctx, msg: StellarGetAddress):
    node = await seed.derive_node(ctx, msg.address_n, helpers.STELLAR_CURVE)
    pubkey = seed.remove_ed25519_prefix(node.public_key())
    address = helpers.address_from_public_key(pubkey)

    if msg.show_display:
        while True:
            if await show_address(ctx, address):
                break
            if await show_qr(ctx, address.upper()):
                break

    return StellarAddress(address=address)
コード例 #4
0
async def confirm_set_options_op(ctx, op: StellarSetOptionsOp):
    if op.inflation_destination_account:
        text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
        text.bold("Set Inflation Destination")
        text.mono(*split(op.inflation_destination_account))
        await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
    if op.clear_flags:
        t = _format_flags(op.clear_flags)
        text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
        text.bold("Clear Flags")
        text.mono(*t)
        await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
    if op.set_flags:
        t = _format_flags(op.set_flags)
        text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
        text.bold("Set Flags")
        text.mono(*t)
        await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
    thresholds = _format_thresholds(op)
    if thresholds:
        text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
        text.bold("Account Thresholds")
        text.mono(*thresholds)
        await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
    if op.home_domain:
        text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
        text.bold("Home Domain")
        text.mono(*split(op.home_domain))
        await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
    if op.signer_type is not None:
        if op.signer_weight > 0:
            t = "Add Signer (%s)"
        else:
            t = "Remove Signer (%s)"
        if op.signer_type == consts.SIGN_TYPE_ACCOUNT:
            text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
            text.bold(t % "acc")
            text.mono(*split(helpers.address_from_public_key(op.signer_key)))
            await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
        elif op.signer_type in (consts.SIGN_TYPE_PRE_AUTH,
                                consts.SIGN_TYPE_HASH):
            if op.signer_type == consts.SIGN_TYPE_PRE_AUTH:
                signer_type = "auth"
            else:
                signer_type = "hash"
            text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
            text.bold(t % signer_type)
            text.mono(*split(hexlify(op.signer_key).decode()))
            await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
        else:
            raise ProcessError("Stellar: invalid signer type")
コード例 #5
0
async def _init(ctx, w: bytearray, pubkey: bytes, msg: StellarSignTx):
    network_passphrase_hash = sha256(msg.network_passphrase).digest()
    writers.write_bytes(w, network_passphrase_hash)
    writers.write_bytes(w, consts.TX_TYPE)

    address = helpers.address_from_public_key(pubkey)
    writers.write_pubkey(w, address)
    if helpers.public_key_from_address(msg.source_account) != pubkey:
        raise ProcessError("Stellar: source account does not match address_n")
    writers.write_uint32(w, msg.fee)
    writers.write_uint64(w, msg.sequence_number)

    # confirm init
    await layout.require_confirm_init(ctx, address, msg.network_passphrase)
コード例 #6
0
async def _init(ctx, w: bytearray, pubkey: bytes, msg: StellarSignTx):
    network_passphrase_hash = sha256(msg.network_passphrase).digest()
    writers.write_bytes_unchecked(w, network_passphrase_hash)
    writers.write_bytes_unchecked(w, consts.TX_TYPE)

    address = helpers.address_from_public_key(pubkey)
    accounts_match = msg.source_account == address

    writers.write_pubkey(w, msg.source_account)
    writers.write_uint32(w, msg.fee)
    writers.write_uint64(w, msg.sequence_number)

    # confirm init
    await layout.require_confirm_init(ctx, msg.source_account,
                                      msg.network_passphrase, accounts_match)
コード例 #7
0
ファイル: get_address.py プロジェクト: stopstopstop/emu
async def get_address(ctx, msg: StellarGetAddress, keychain):
    await paths.validate_path(ctx, helpers.validate_full_path, keychain,
                              msg.address_n, CURVE)

    node = keychain.derive(msg.address_n, CURVE)
    pubkey = seed.remove_ed25519_prefix(node.public_key())
    address = helpers.address_from_public_key(pubkey)

    if msg.show_display:
        desc = address_n_to_str(msg.address_n)
        while True:
            if await show_address(ctx, address, desc=desc):
                break
            if await show_qr(ctx, address.upper(), desc=desc):
                break

    return StellarAddress(address=address)