diff --git a/src/apps/stellar/__init__.py b/src/apps/stellar/__init__.py index eb8ca62500..a1a032999b 100644 --- a/src/apps/stellar/__init__.py +++ b/src/apps/stellar/__init__.py @@ -1,5 +1,6 @@ from trezor.wire import register, protobuf_workflow from trezor.messages.wire_types import StellarGetPublicKey +from trezor.messages.wire_types import StellarSignTx def dispatch_StellarGetPublicKey(*args, **kwargs): @@ -7,5 +8,11 @@ def dispatch_StellarGetPublicKey(*args, **kwargs): return get_public_key(*args, **kwargs) +def dispatch_StellarSignTx(*args, **kwargs): + from .sign_tx import sign_tx_loop + return sign_tx_loop(*args, **kwargs) + + def boot(): register(StellarGetPublicKey, protobuf_workflow, dispatch_StellarGetPublicKey) + register(StellarSignTx, protobuf_workflow, dispatch_StellarSignTx) diff --git a/src/apps/stellar/get_public_key.py b/src/apps/stellar/get_public_key.py index 4ced0caa70..9bd5958abf 100644 --- a/src/apps/stellar/get_public_key.py +++ b/src/apps/stellar/get_public_key.py @@ -49,7 +49,6 @@ def _address_from_public_key(pubkey: bytes): address.extend(pubkey) address.extend(ustruct.pack("L', n)) + + +def write_uint64(w, n: int): + write_bytes(w, ustruct.pack('>Q', n)) + + +def write_bytes(w, buf: bytearray): + w.extend(buf) + + +def write_bool(w, val: True): + if val: + write_uint32(w, 1) + else: + write_uint32(w, 0) + + +def write_pubkey(w, pubkey: bytes): + # first 4 bytes of an address are the type, there's only one type (0) + write_uint32(w, 0) + write_bytes(w, bytearray(pubkey))