1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 17:38:39 +00:00

Wrap long addresses in three lines

This commit is contained in:
Jochen Hoenicke 2017-11-01 21:42:52 +01:00 committed by Pavol Rusnak
parent 97581928de
commit 0f50b816e6
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -101,17 +101,29 @@ void layoutConfirmOutput(const CoinInfo *coin, const TxOutputType *out)
{ {
char str_out[32]; char str_out[32];
bn_format_uint64(out->amount, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY, 0, false, str_out, sizeof(str_out)); bn_format_uint64(out->amount, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY, 0, false, str_out, sizeof(str_out));
static char first_half[17 + 1]; static char lines[2][28];
strlcpy(first_half, out->address, sizeof(first_half)); const char *addr = out->address;
int addrlen = strlen(addr);
int numlines = addrlen <= 34 ? 2 : 3;
strcpy(lines[0], _("to "));
int linelen = (addrlen + (numlines == 3 ? 3 : 0) - 1) / numlines + 1;
if (linelen > 27)
linelen = 27;
if (numlines == 3) {
strlcpy(lines[0] + 3, addr, linelen - 3 + 1);
addr += linelen - 3;
}
strlcpy(lines[1], addr, linelen + 1);
addr += linelen;
layoutDialogSwipe(&bmp_icon_question, layoutDialogSwipe(&bmp_icon_question,
_("Cancel"), _("Cancel"),
_("Confirm"), _("Confirm"),
NULL, NULL,
_("Confirm sending"), _("Confirm sending"),
str_out, str_out,
_("to"), lines[0],
first_half, lines[1],
out->address + 17, addr,
NULL NULL
); );
} }