mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
stellar: allow different source address (#462)
This commit is contained in:
parent
305a364e73
commit
ea775c2750
@ -6,10 +6,16 @@ from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
from apps.stellar import consts
|
||||
|
||||
|
||||
async def require_confirm_init(ctx, address: str, network_passphrase: str):
|
||||
async def require_confirm_init(
|
||||
ctx, address: str, network_passphrase: str, accounts_match: bool
|
||||
):
|
||||
text = Text("Confirm Stellar", ui.ICON_SEND, icon_color=ui.GREEN)
|
||||
text.normal("Initialize signing with")
|
||||
text.mono(*split(address))
|
||||
if accounts_match:
|
||||
text.normal("your account")
|
||||
text.mono(*split(trim_to_rows(address, 3)))
|
||||
else:
|
||||
text.mono(*split(address))
|
||||
await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
|
||||
network = get_network_warning(network_passphrase)
|
||||
if network:
|
||||
|
@ -49,14 +49,16 @@ async def _init(ctx, w: bytearray, pubkey: bytes, msg: StellarSignTx):
|
||||
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")
|
||||
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, address, msg.network_passphrase)
|
||||
await layout.require_confirm_init(
|
||||
ctx, msg.source_account, msg.network_passphrase, accounts_match
|
||||
)
|
||||
|
||||
|
||||
def _timebounds(w: bytearray, start: int, end: int):
|
||||
@ -78,6 +80,8 @@ async def _operations(ctx, w: bytearray, num_operations: int):
|
||||
|
||||
|
||||
async def _memo(ctx, w: bytearray, msg: StellarSignTx):
|
||||
if msg.memo_type is None:
|
||||
msg.memo_type = consts.MEMO_TYPE_NONE
|
||||
writers.write_uint32(w, msg.memo_type)
|
||||
if msg.memo_type == consts.MEMO_TYPE_NONE:
|
||||
# nothing is serialized
|
||||
|
Loading…
Reference in New Issue
Block a user