#include "balance_recent_tx.h" #include "../../config/version.h" #include "../../util/text_format.h" #include "../../util/i18n.h" #include #include #include namespace dragonx { namespace ui { namespace { std::string formatRecentAmount(const std::string& type, double amount) { char buffer[32]; snprintf(buffer, sizeof(buffer), "%s%.4f %s", type == "send" ? "-" : "+", std::abs(amount), DRAGONX_TICKER); return std::string(buffer); } std::string recentTimeAgo(int64_t timestamp) { return util::formatTimeAgoShort(timestamp); } // Translated type label (the data layer's getTypeDisplay() returns raw English). Never leak a raw RPC // category: anything unrecognized (including "shield") falls back to a generic "Transaction". std::string recentTypeLabel(const std::string& type) { if (type == "send") return TR("sent_type"); if (type == "receive") return TR("received_label"); if (type == "mined" || type == "generate" || type == "immature") return TR("mined_type"); return TR("tx_type_generic"); } } RecentTxDisplay buildRecentTxDisplay(const TransactionInfo& tx, int addressMaxLen) { return { recentTypeLabel(tx.type), util::truncateMiddle(tx.address, addressMaxLen), formatRecentAmount(tx.type, tx.amount), recentTimeAgo(tx.timestamp) }; } } // namespace ui } // namespace dragonx