feat(shield): batch-accurate merge confirm, friendly errors, plural confirm text (F014/F013/F095)

UX audit, Shield/Consolidate surface (batch 2):

- F014: the "Into one address" confirm no longer overstates a single run — it caps to
  what one batch merges ("merges N of M inputs ... run again for the rest"), and both the
  merge and shield confirms now name the network fee and the destination's label.
- F013: the op-failed message and the create-z-address error go through
  util::friendlyRpcError() like the submit paths already do.
- F095: confirm text uses separate singular/plural strings (input/inputs,
  mining address/mining addresses) instead of "(s)".

New strings (English). Build + tests green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 15:41:40 -06:00
co-authored by Claude Opus 4.8
parent af00efc0c3
commit 3434679afe
2 changed files with 27 additions and 7 deletions
+20 -6
View File
@@ -428,7 +428,7 @@ static void pollOperation(App* app)
std::string msg = TR("shield_unknown_error");
if (op.contains("error") && op["error"].is_object() && op["error"].contains("message") &&
op["error"]["message"].is_string())
msg = op["error"]["message"].get<std::string>();
msg = util::friendlyRpcError(op["error"]["message"].get<std::string>()); // F013
s_operation_pending = false; s_op_terminal = true;
s_op_outcome = OpOutcome::Failed;
s_status_message = std::string(TR("shield_op_failed")) + msg;
@@ -645,7 +645,7 @@ void ShieldDialog::render(App* app)
strncpy(s_to_address, addr.c_str(), sizeof(s_to_address) - 1);
Notifications::instance().success(TR("merge_addr_created"));
} else {
Notifications::instance().error(std::string(TR("shield_error_prefix")) + error);
Notifications::instance().error(std::string(TR("shield_error_prefix")) + util::friendlyRpcError(error)); // F013
}
};
});
@@ -930,19 +930,33 @@ void ShieldDialog::render(App* app)
ImGui::TextWrapped("%s", cb);
ImGui::Spacing();
} else if (s_confirm && isMerge) {
char cb[200];
std::snprintf(cb, sizeof(cb), TR("merge_confirm_fmt"),
fmtAmt(srcAmount()).c_str(), srcCount(), shortAddr(s_to_address).c_str());
// Cap the confirm to what ONE batch actually merges (min of scope and the input limit) so the amount
// and count don't overstate a single run; name the fee and the destination's label. (F014/F095)
const int total = srcCount();
const int batch = (total < s_utxo_limit) ? total : s_utxo_limit;
const std::string toLbl = app->getAddressLabel(s_to_address);
const std::string dest = toLbl.empty() ? shortAddr(s_to_address) : toLbl;
char cb[320];
if (batch < total) {
std::snprintf(cb, sizeof(cb), TR("merge_confirm_batch_fmt"),
batch, total, dest.c_str(), fmtAmt(s_fee).c_str());
} else {
std::snprintf(cb, sizeof(cb), TR("merge_confirm_all_fmt"),
fmtAmt(srcAmount()).c_str(), total,
(total == 1 ? TR("input_one") : TR("input_many")),
dest.c_str(), fmtAmt(s_fee).c_str());
}
ImGui::TextWrapped("%s", cb);
ImGui::Spacing();
} else if (s_confirm && !isMerge) {
// Shield-coinbase preview: amount / address count / fee / destination (no amount/count was shown before).
const bool allFrom = std::strcmp(s_from_address, "*") == 0;
const std::string toLbl = app->getAddressLabel(s_to_address);
const int acount = allFrom ? miningAddrCount(state, s_from_address) : 1;
char cb[360];
std::snprintf(cb, sizeof(cb), TR("shield_confirm_fmt"),
fmtAmt(miningBalance(state, s_from_address)).c_str(),
allFrom ? miningAddrCount(state, s_from_address) : 1,
acount, (acount == 1 ? TR("addr_one") : TR("addr_many")), // F095
s_utxo_limit,
toLbl.empty() ? shortAddr(s_to_address).c_str() : toLbl.c_str(),
fmtAmt(s_fee).c_str());
+7 -1
View File
@@ -2876,7 +2876,11 @@ void I18n::loadBuiltinEnglish()
strings_["shield_description"] = "Shield your mining rewards by sending coinbase outputs from transparent addresses to a shielded address. This improves privacy by hiding your mining income.";
strings_["shield_from_address"] = "From mining address:";
strings_["shield_all_mining_addrs"] = "All mining addresses";
strings_["shield_confirm_fmt"] = "Shield up to %s DRGX from %d mining address(es) (at most %d rewards per run) to %s? Network fee: %s DRGX.";
strings_["shield_confirm_fmt"] = "Shield up to %s DRGX from %d %s (at most %d rewards per run) to %s? Network fee: %s DRGX.";
strings_["addr_one"] = "mining address";
strings_["addr_many"] = "mining addresses";
strings_["input_one"] = "input";
strings_["input_many"] = "inputs";
strings_["shield_funds"] = "Shield Funds";
strings_["shield_in_progress"] = "Operation in progress...";
strings_["shield_max_utxos"] = "Max UTXOs per operation";
@@ -2923,6 +2927,8 @@ void I18n::loadBuiltinEnglish()
strings_["merge_creating"] = "Creating address\xE2\x80\xA6";
strings_["merge_addr_created"] = "Shielded address created.";
strings_["merge_confirm_fmt"] = "Consolidate ~%s DRGX from %d input(s) into %s?";
strings_["merge_confirm_all_fmt"] = "Consolidate ~%s DRGX from %d %s into %s? Network fee: %s DRGX.";
strings_["merge_confirm_batch_fmt"] = "This batch merges %d of %d inputs into %s (fee %s DRGX). Run again for the rest.";
strings_["merge_confirm_btn"] = "Confirm";
strings_["merge_back"] = "Back";
strings_["merge_progress"] = "Consolidating\xE2\x80\xA6 this can take a few minutes. You can close this window.";