1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 11:28:14 +00:00

stellar: ProcessError

This commit is contained in:
Tomas Susanka 2018-06-18 15:13:45 +02:00
parent 96a91b56e9
commit 2e04dbb2a6
3 changed files with 10 additions and 8 deletions

View File

@ -14,6 +14,7 @@ from trezor.messages.StellarManageOfferOp import StellarManageOfferOp
from trezor.messages.StellarPathPaymentOp import StellarPathPaymentOp
from trezor.messages.StellarPaymentOp import StellarPaymentOp
from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp
from trezor.wire import ProcessError
from ubinascii import hexlify
@ -219,7 +220,7 @@ async def confirm_set_options_op(ctx, op: StellarSetOptionsOp):
icon_color=ui.GREEN)
await require_confirm(ctx, content, ButtonRequestType.ConfirmOutput)
else:
raise ValueError('Stellar: invalid signer type')
raise ProcessError('Stellar: invalid signer type')
def _format_thresholds(op: StellarSetOptionsOp) -> tuple:
@ -237,7 +238,7 @@ def _format_thresholds(op: StellarSetOptionsOp) -> tuple:
def _format_flags(flags: int) -> tuple:
if flags > consts.FLAGS_MAX_SIZE:
raise ValueError('Stellar: invalid')
raise ProcessError('Stellar: invalid flags')
text = ()
if flags & consts.FLAG_AUTH_REQUIRED:
text += ('AUTH_REQUIRED', )

View File

@ -12,6 +12,7 @@ from trezor.messages.StellarManageOfferOp import StellarManageOfferOp
from trezor.messages.StellarPathPaymentOp import StellarPathPaymentOp
from trezor.messages.StellarPaymentOp import StellarPaymentOp
from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp
from trezor.wire import ProcessError
def serialize_account_merge_op(w, msg: StellarAccountMergeOp):
@ -51,7 +52,7 @@ def serialize_create_passive_offer_op(w, msg: StellarCreatePassiveOfferOp):
def serialize_manage_data_op(w, msg: StellarManageDataOp):
if len(msg.key) > 64:
raise ValueError('Stellar: max length of a key is 64 bytes')
raise ProcessError('Stellar: max length of a key is 64 bytes')
writers.write_string(w, msg.key)
writers.write_bool(w, bool(msg.value))
if msg.value:
@ -123,7 +124,7 @@ def serialize_set_options_op(w, msg: StellarSetOptionsOp):
writers.write_bool(w, bool(msg.home_domain))
if msg.home_domain:
if len(msg.home_domain) > 32:
raise ValueError('Stellar: max length of a home domain is 32 bytes')
raise ProcessError('Stellar: max length of a home domain is 32 bytes')
writers.write_string(w, msg.home_domain)
# signer
@ -153,7 +154,7 @@ def _serialize_asset_code(w, asset_type: int, asset_code: str):
# pad with zeros to 12 chars
writers.write_bytes(w, code + bytearray([0] * (12 - len(code))))
else:
raise ValueError('Stellar: invalid asset type')
raise ProcessError('Stellar: invalid asset type')
def _serialize_asset(w, asset: StellarAssetType):

View File

@ -15,7 +15,7 @@ from ubinascii import hexlify
async def sign_tx(ctx, msg: StellarSignTx):
if msg.num_operations == 0:
raise ValueError('Stellar: At least one operation is required')
raise ProcessError('Stellar: At least one operation is required')
node = await seed.derive_node(ctx, msg.address_n, consts.STELLAR_CURVE)
pubkey = seed.remove_ed25519_prefix(node.public_key())
@ -84,7 +84,7 @@ async def _memo(ctx, w: bytearray, msg: StellarSignTx):
elif msg.memo_type == consts.MEMO_TYPE_TEXT:
# Text: 4 bytes (size) + up to 28 bytes
if len(msg.memo_text) > 28:
raise ValueError('Stellar: max length of a memo text is 28 bytes')
raise ProcessError('Stellar: max length of a memo text is 28 bytes')
writers.write_string(w, msg.memo_text)
memo_confirm_text = msg.memo_text
elif msg.memo_type == consts.MEMO_TYPE_ID:
@ -96,7 +96,7 @@ async def _memo(ctx, w: bytearray, msg: StellarSignTx):
writers.write_bytes(w, bytearray(msg.memo_hash))
memo_confirm_text = hexlify(msg.memo_hash).decode()
else:
raise ValueError('Stellar invalid memo type')
raise ProcessError('Stellar invalid memo type')
await layout.require_confirm_memo(ctx, msg.memo_type, memo_confirm_text)