mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
layout: parse and show OMNI transactions
This commit is contained in:
parent
0f2ec16609
commit
9cd261c81a
@ -320,7 +320,49 @@ void layoutConfirmOutput(const CoinInfo *coin, const TxOutputType *out)
|
|||||||
render_address_dialog(coin, address, _("Confirm sending"), str_out, extra_line);
|
render_address_dialog(coin, address, _("Confirm sending"), str_out, extra_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid_ascii(const uint8_t *data, uint32_t size)
|
void layoutConfirmOmni(const uint8_t *data, uint32_t size)
|
||||||
|
{
|
||||||
|
const char *desc;
|
||||||
|
char str_out[32];
|
||||||
|
const uint32_t tx_type = *(const uint32_t *)(data + 4);
|
||||||
|
if (tx_type == 0x00000000 && size == 20) { // OMNI simple send
|
||||||
|
desc = _("Simple send of ");
|
||||||
|
const uint32_t currency = *(const uint32_t *)(data + 8);
|
||||||
|
const char *suffix = "UNKN";
|
||||||
|
switch (currency) {
|
||||||
|
case 1:
|
||||||
|
suffix = "OMNI";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
suffix = "tOMNI";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
suffix = "MAID";
|
||||||
|
break;
|
||||||
|
case 31:
|
||||||
|
suffix = "USDT";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const uint64_t amount = *(const uint64_t *)(data + 12);
|
||||||
|
bn_format_uint64(amount, NULL, suffix, BITCOIN_DIVISIBILITY, 0, false, str_out, sizeof(str_out));
|
||||||
|
} else {
|
||||||
|
desc = _("Unknown transaction");
|
||||||
|
str_out[0] = 0;
|
||||||
|
}
|
||||||
|
layoutDialogSwipe(&bmp_icon_question,
|
||||||
|
_("Cancel"),
|
||||||
|
_("Confirm"),
|
||||||
|
NULL,
|
||||||
|
_("Confirm OMNI Transaction:"),
|
||||||
|
NULL,
|
||||||
|
desc,
|
||||||
|
NULL,
|
||||||
|
str_out,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool is_valid_ascii(const uint8_t *data, uint32_t size)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < size; i++) {
|
for (uint32_t i = 0; i < size; i++) {
|
||||||
if (data[i] < ' ' || data[i] > '~') {
|
if (data[i] < ' ' || data[i] > '~') {
|
||||||
|
@ -44,6 +44,7 @@ void layoutProgressSwipe(const char *desc, int permil);
|
|||||||
void layoutScreensaver(void);
|
void layoutScreensaver(void);
|
||||||
void layoutHome(void);
|
void layoutHome(void);
|
||||||
void layoutConfirmOutput(const CoinInfo *coin, const TxOutputType *out);
|
void layoutConfirmOutput(const CoinInfo *coin, const TxOutputType *out);
|
||||||
|
void layoutConfirmOmni(const uint8_t *data, uint32_t size);
|
||||||
void layoutConfirmOpReturn(const uint8_t *data, uint32_t size);
|
void layoutConfirmOpReturn(const uint8_t *data, uint32_t size);
|
||||||
void layoutConfirmTx(const CoinInfo *coin, uint64_t amount_out, uint64_t amount_fee);
|
void layoutConfirmTx(const CoinInfo *coin, uint64_t amount_out, uint64_t amount_fee);
|
||||||
void layoutFeeOverThreshold(const CoinInfo *coin, uint64_t fee);
|
void layoutFeeOverThreshold(const CoinInfo *coin, uint64_t fee);
|
||||||
@ -73,6 +74,5 @@ void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count, con
|
|||||||
|
|
||||||
const char **split_message(const uint8_t *msg, uint32_t len, uint32_t rowlen);
|
const char **split_message(const uint8_t *msg, uint32_t len, uint32_t rowlen);
|
||||||
const char **split_message_hex(const uint8_t *msg, uint32_t len);
|
const char **split_message_hex(const uint8_t *msg, uint32_t len);
|
||||||
bool is_valid_ascii(const uint8_t *data, uint32_t size);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -200,7 +200,11 @@ int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in, T
|
|||||||
return 0; // failed to compile output
|
return 0; // failed to compile output
|
||||||
}
|
}
|
||||||
if (needs_confirm) {
|
if (needs_confirm) {
|
||||||
layoutConfirmOpReturn(in->op_return_data.bytes, in->op_return_data.size);
|
if (in->op_return_data.size >= 8 && memcmp(in->op_return_data.bytes, "omni", 4) == 0) { // OMNI transaction
|
||||||
|
layoutConfirmOmni(in->op_return_data.bytes, in->op_return_data.size);
|
||||||
|
} else {
|
||||||
|
layoutConfirmOpReturn(in->op_return_data.bytes, in->op_return_data.size);
|
||||||
|
}
|
||||||
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
|
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
|
||||||
return -1; // user aborted
|
return -1; // user aborted
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user