feat(wallets): show each external wallet's sub-directory

Prepend the containing folder (last 1-2 path components, e.g. "…/Backups/2021")
to an external wallet's metadata line, so several same-named wallet.dat files
surfaced by the recursive scan are distinguishable at a glance (the info-icon
tooltip still shows the full path).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-11 19:17:45 -05:00
parent 3dc4d2d860
commit b765d62e00

View File

@@ -209,6 +209,18 @@ public:
if (t) s += "\xE2\x80\xA6";
return s;
};
// The containing sub-directory as its last 1-2 components (e.g. "…/Backups/2021"), so several
// same-named wallet.dat files surfaced by the recursive scan are distinguishable at a glance.
auto shortSubdir = [](std::string d) {
while (d.size() > 1 && (d.back() == '/' || d.back() == '\\')) d.pop_back();
const auto p2 = d.find_last_of("/\\");
if (p2 == std::string::npos) return d; // no separator: whole thing
std::string leaf = d.substr(p2 + 1);
const auto p1 = (p2 > 0) ? d.find_last_of("/\\", p2 - 1) : std::string::npos;
std::string parent = (p1 == std::string::npos) ? d.substr(0, p2) : d.substr(p1 + 1, p2 - p1 - 1);
std::string out = parent.empty() ? leaf : (parent + "/" + leaf);
return (p1 != std::string::npos && p1 > 0) ? ("\xE2\x80\xA6/" + out) : out; // "…/" if deeper
};
for (std::size_t k = 0; k < s_order.size(); ++k) {
const std::size_t i = s_order[k]; // sorted display order → actual s_rows index
@@ -301,7 +313,9 @@ public:
// wallet index gives the authoritative user-facing ADDRESS count; the btree walk gives an
// exact tx count and a spendable-KEY count (labeled "keys", not "addresses", since it counts
// change keys the daemon's address list omits — a different figure for the same wallet).
std::string ms = util::Platform::formatFileSize((uint64_t)r.sizeBytes);
std::string ms;
if (!r.inDatadir) ms = shortSubdir(r.dir) + dot; // which sub-directory this wallet is in
ms += util::Platform::formatFileSize((uint64_t)r.sizeBytes);
char b[80];
if (meta && meta->cachedAddressCount >= 0) { snprintf(b, sizeof(b), "%s%lld %s", dot, (long long)meta->cachedAddressCount, TR("wallets_col_addresses")); ms += b; }
else if (pres.hasCounts && pres.keyCount > 0) { snprintf(b, sizeof(b), "%s%d %s", dot, pres.keyCount, TR("wallets_col_keys")); ms += b; }