diff --git a/crypto/tests/test_check_cashaddr.h b/crypto/tests/test_check_cashaddr.h index 7f2a68c55..1568001a2 100644 --- a/crypto/tests/test_check_cashaddr.h +++ b/crypto/tests/test_check_cashaddr.h @@ -55,9 +55,17 @@ START_TEST(test_cashaddr) { rawdata_len = base58_decode_check(valid_cashaddr[i].legacy, HASHER_SHA2D, rawdata, sizeof(rawdata)); ck_assert_uint_eq(rawdata_len, 21); - ck_assert_uint_eq(prog[0], rawdata[0] == 0 ? 0x00 - : rawdata[0] == 5 ? 0x08 - : -1); + + int addr_type = -1; + if (rawdata[0] == 0) { + addr_type = 0x00; // P2PKH + } else if (rawdata[0] == 5) { + addr_type = 0x08; // P2SH + } else { + ck_abort(); + } + ck_assert_uint_eq(prog[0], addr_type); + ck_assert_int_eq(memcmp(rawdata + 1, prog + 1, 20), 0); ret = cash_addr_encode(rebuild, hrp, prog, 21); ck_assert_int_eq(ret, 1); diff --git a/legacy/firmware/layout2.c b/legacy/firmware/layout2.c index da07bff27..708fd59cd 100644 --- a/legacy/firmware/layout2.c +++ b/legacy/firmware/layout2.c @@ -779,10 +779,14 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, oledDrawString(0, 0 * 9, desc, FONT_STANDARD); } if (addrlen > 10) { // don't split short addresses - uint32_t rowlen = (addrlen - 1) / (addrlen <= 42 ? 2 - : addrlen <= 63 ? 3 - : 4) + - 1; + uint32_t rowcount = 4; + if (addrlen <= 42) { + rowcount = 2; + } else if (addrlen <= 63) { + rowcount = 3; + } + + uint32_t rowlen = (addrlen - 1) / rowcount + 1; const char **str = split_message((const uint8_t *)address, addrlen, rowlen); for (int i = 0; i < 4; i++) { diff --git a/legacy/firmware/recovery.c b/legacy/firmware/recovery.c index a302c6b38..9f5094abc 100644 --- a/legacy/firmware/recovery.c +++ b/legacy/firmware/recovery.c @@ -146,9 +146,13 @@ static void recovery_request(void) { WordRequest resp = {0}; memzero(&resp, sizeof(WordRequest)); resp.has_type = true; - resp.type = awaiting_word == 1 ? WordRequestType_WordRequestType_Plain - : (word_index % 4 == 3) ? WordRequestType_WordRequestType_Matrix6 - : WordRequestType_WordRequestType_Matrix9; + if (awaiting_word == 1) { + resp.type = WordRequestType_WordRequestType_Plain; + } else if (word_index % 4 == 3) { + resp.type = WordRequestType_WordRequestType_Matrix6; + } else { + resp.type = WordRequestType_WordRequestType_Matrix9; + } msg_write(MessageType_MessageType_WordRequest, &resp); }