diff --git a/core/src/apps/wallet/sign_tx/omni.py b/core/src/apps/wallet/sign_tx/omni.py index a475d2826c..6bbbbcd21c 100644 --- a/core/src/apps/wallet/sign_tx/omni.py +++ b/core/src/apps/wallet/sign_tx/omni.py @@ -2,7 +2,12 @@ from ustruct import unpack from trezor.utils import format_amount -currencies = {1: "OMNI", 2: "tOMNI", 3: "MAID", 31: "USDT"} +currencies = { + 1: ("OMNI", True), + 2: ("tOMNI", True), + 3: ("MAID", False), + 31: ("USDT", True), +} def is_valid(data: bytes) -> bool: @@ -15,9 +20,10 @@ def parse(data: bytes) -> bool: tx_version, tx_type = unpack(">HH", data[4:8]) if tx_version == 0 and tx_type == 0 and len(data) == 20: # OMNI simple send currency, amount = unpack(">IQ", data[8:20]) + suffix, divisible = currencies.get(currency, ("UNKN", False)) return "Simple send of %s %s" % ( - format_amount(amount, 8), - currencies.get(currency, "UNKN"), + format_amount(amount, 8 if divisible else 0), + suffix, ) else: # unknown OMNI transaction diff --git a/legacy/firmware/layout2.c b/legacy/firmware/layout2.c index 7e2877b1c7..7ef3fa2a24 100644 --- a/legacy/firmware/layout2.c +++ b/legacy/firmware/layout2.c @@ -361,25 +361,30 @@ void layoutConfirmOmni(const uint8_t *data, uint32_t size) { desc = _("Simple send of "); REVERSE32(*(const uint32_t *)(data + 8), currency); const char *suffix = " UNKN"; + bool divisible = false; switch (currency) { case 1: suffix = " OMNI"; + divisible = true; break; case 2: suffix = " tOMNI"; + divisible = true; break; case 3: suffix = " MAID"; + divisible = false; break; case 31: suffix = " USDT"; + divisible = true; break; } uint64_t amount_be, amount; memcpy(&amount_be, data + 12, sizeof(uint64_t)); REVERSE64(amount_be, amount); - bn_format_uint64(amount, NULL, suffix, BITCOIN_DIVISIBILITY, 0, false, - str_out, sizeof(str_out)); + bn_format_uint64(amount, NULL, suffix, divisible ? BITCOIN_DIVISIBILITY : 0, + 0, false, str_out, sizeof(str_out)); } else { desc = _("Unknown transaction"); str_out[0] = 0;