mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-31 02:48:44 +00:00
stellar: ProcessError
This commit is contained in:
parent
96a91b56e9
commit
2e04dbb2a6
@ -14,6 +14,7 @@ from trezor.messages.StellarManageOfferOp import StellarManageOfferOp
|
|||||||
from trezor.messages.StellarPathPaymentOp import StellarPathPaymentOp
|
from trezor.messages.StellarPathPaymentOp import StellarPathPaymentOp
|
||||||
from trezor.messages.StellarPaymentOp import StellarPaymentOp
|
from trezor.messages.StellarPaymentOp import StellarPaymentOp
|
||||||
from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp
|
from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp
|
||||||
|
from trezor.wire import ProcessError
|
||||||
from ubinascii import hexlify
|
from ubinascii import hexlify
|
||||||
|
|
||||||
|
|
||||||
@ -219,7 +220,7 @@ async def confirm_set_options_op(ctx, op: StellarSetOptionsOp):
|
|||||||
icon_color=ui.GREEN)
|
icon_color=ui.GREEN)
|
||||||
await require_confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
await require_confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
||||||
else:
|
else:
|
||||||
raise ValueError('Stellar: invalid signer type')
|
raise ProcessError('Stellar: invalid signer type')
|
||||||
|
|
||||||
|
|
||||||
def _format_thresholds(op: StellarSetOptionsOp) -> tuple:
|
def _format_thresholds(op: StellarSetOptionsOp) -> tuple:
|
||||||
@ -237,7 +238,7 @@ def _format_thresholds(op: StellarSetOptionsOp) -> tuple:
|
|||||||
|
|
||||||
def _format_flags(flags: int) -> tuple:
|
def _format_flags(flags: int) -> tuple:
|
||||||
if flags > consts.FLAGS_MAX_SIZE:
|
if flags > consts.FLAGS_MAX_SIZE:
|
||||||
raise ValueError('Stellar: invalid')
|
raise ProcessError('Stellar: invalid flags')
|
||||||
text = ()
|
text = ()
|
||||||
if flags & consts.FLAG_AUTH_REQUIRED:
|
if flags & consts.FLAG_AUTH_REQUIRED:
|
||||||
text += ('AUTH_REQUIRED', )
|
text += ('AUTH_REQUIRED', )
|
||||||
|
@ -12,6 +12,7 @@ from trezor.messages.StellarManageOfferOp import StellarManageOfferOp
|
|||||||
from trezor.messages.StellarPathPaymentOp import StellarPathPaymentOp
|
from trezor.messages.StellarPathPaymentOp import StellarPathPaymentOp
|
||||||
from trezor.messages.StellarPaymentOp import StellarPaymentOp
|
from trezor.messages.StellarPaymentOp import StellarPaymentOp
|
||||||
from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp
|
from trezor.messages.StellarSetOptionsOp import StellarSetOptionsOp
|
||||||
|
from trezor.wire import ProcessError
|
||||||
|
|
||||||
|
|
||||||
def serialize_account_merge_op(w, msg: StellarAccountMergeOp):
|
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):
|
def serialize_manage_data_op(w, msg: StellarManageDataOp):
|
||||||
if len(msg.key) > 64:
|
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_string(w, msg.key)
|
||||||
writers.write_bool(w, bool(msg.value))
|
writers.write_bool(w, bool(msg.value))
|
||||||
if 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))
|
writers.write_bool(w, bool(msg.home_domain))
|
||||||
if msg.home_domain:
|
if msg.home_domain:
|
||||||
if len(msg.home_domain) > 32:
|
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)
|
writers.write_string(w, msg.home_domain)
|
||||||
|
|
||||||
# signer
|
# signer
|
||||||
@ -153,7 +154,7 @@ def _serialize_asset_code(w, asset_type: int, asset_code: str):
|
|||||||
# pad with zeros to 12 chars
|
# pad with zeros to 12 chars
|
||||||
writers.write_bytes(w, code + bytearray([0] * (12 - len(code))))
|
writers.write_bytes(w, code + bytearray([0] * (12 - len(code))))
|
||||||
else:
|
else:
|
||||||
raise ValueError('Stellar: invalid asset type')
|
raise ProcessError('Stellar: invalid asset type')
|
||||||
|
|
||||||
|
|
||||||
def _serialize_asset(w, asset: StellarAssetType):
|
def _serialize_asset(w, asset: StellarAssetType):
|
||||||
|
@ -15,7 +15,7 @@ from ubinascii import hexlify
|
|||||||
|
|
||||||
async def sign_tx(ctx, msg: StellarSignTx):
|
async def sign_tx(ctx, msg: StellarSignTx):
|
||||||
if msg.num_operations == 0:
|
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)
|
node = await seed.derive_node(ctx, msg.address_n, consts.STELLAR_CURVE)
|
||||||
pubkey = seed.remove_ed25519_prefix(node.public_key())
|
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:
|
elif msg.memo_type == consts.MEMO_TYPE_TEXT:
|
||||||
# Text: 4 bytes (size) + up to 28 bytes
|
# Text: 4 bytes (size) + up to 28 bytes
|
||||||
if len(msg.memo_text) > 28:
|
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)
|
writers.write_string(w, msg.memo_text)
|
||||||
memo_confirm_text = msg.memo_text
|
memo_confirm_text = msg.memo_text
|
||||||
elif msg.memo_type == consts.MEMO_TYPE_ID:
|
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))
|
writers.write_bytes(w, bytearray(msg.memo_hash))
|
||||||
memo_confirm_text = hexlify(msg.memo_hash).decode()
|
memo_confirm_text = hexlify(msg.memo_hash).decode()
|
||||||
else:
|
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)
|
await layout.require_confirm_memo(ctx, msg.memo_type, memo_confirm_text)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user