From 5831e53854de85b27155692a808d924be992f879 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 9 Oct 2017 23:02:42 +0200 Subject: [PATCH] layout2: refactor and fix layoutCosiCommitSign --- firmware/layout2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/firmware/layout2.c b/firmware/layout2.c index 78d7869f54..6e8fbb2e6e 100644 --- a/firmware/layout2.c +++ b/firmware/layout2.c @@ -645,11 +645,16 @@ void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network) { } } +static inline bool is_slip18(const uint32_t *address_n, size_t address_n_count) +{ + return address_n_count == 2 && address_n[0] == (0x80000000 + 10018) && (address_n[1] & 0x80000000) && (address_n[1] & 0x7FFFFFFF) <= 9; +} + void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count, const uint8_t *data, uint32_t len, bool final_sign) { char *desc = final_sign ? _("CoSi sign message?") : _("CoSi commit message?"); - if (address_n_count == 2 && address_n[0] == (0x80000000 + 10018) && (address_n[1] & 0x80000000) && (address_n[1] & 0x7FFFFFFF) <= 9) { - char desc_buf[32]; + char desc_buf[32]; + if (is_slip18(address_n, address_n_count)) { if (final_sign) { strlcpy(desc_buf, _("CoSi sign index #?"), sizeof(desc_buf)); desc_buf[16] = '0' + (address_n[1] & 0x7FFFFFFF);