From a755e99ccc4e8d16fe79998a0d73042140b5468d Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Fri, 26 Mar 2021 12:14:07 +0100 Subject: [PATCH] feat(legacy): Display nLockTime in human-readable form. --- legacy/firmware/CHANGELOG.md | 2 ++ legacy/firmware/layout2.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/legacy/firmware/CHANGELOG.md b/legacy/firmware/CHANGELOG.md index 992f4f833..c0d638573 100644 --- a/legacy/firmware/CHANGELOG.md +++ b/legacy/firmware/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Allow decreasing the output value in RBF transactions. [#1491] - Support long PIN of up to 50 digits. [#1167] +- Display nLockTime in human-readable form. [#1549] ### Deprecated @@ -384,3 +385,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). [#1415]: https://github.com/trezor/trezor-firmware/pull/1415 [#1491]: https://github.com/trezor/trezor-firmware/issues/1491 [#1518]: https://github.com/trezor/trezor-firmware/pull/1518 +[#1549]: https://github.com/trezor/trezor-firmware/issues/1549 diff --git a/legacy/firmware/layout2.c b/legacy/firmware/layout2.c index 7acb62c90..89e130699 100644 --- a/legacy/firmware/layout2.c +++ b/legacy/firmware/layout2.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "bignum.h" #include "bitmaps.h" @@ -584,10 +585,17 @@ void layoutConfirmNondefaultLockTime(uint32_t lock_time, _("will have no effect."), NULL, _("Continue?"), NULL); } else { - char str_locktime[11] = {0}; - snprintf(str_locktime, sizeof(str_locktime), "%" PRIu32, lock_time); - char *str_type = (lock_time < LOCKTIME_TIMESTAMP_MIN_VALUE) ? "blockheight:" - : "timestamp:"; + char str_locktime[20] = {0}; + char *str_type = NULL; + if (lock_time < LOCKTIME_TIMESTAMP_MIN_VALUE) { + str_type = "blockheight:"; + snprintf(str_locktime, sizeof(str_locktime), "%" PRIu32, lock_time); + } else { + str_type = "timestamp (UTC):"; + time_t time = lock_time; + const struct tm *tm = gmtime(&time); + strftime(str_locktime, sizeof(str_locktime), "%F %T", tm); + } layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Locktime for this"), _("transaction is set to"),