feat(ui): treat transparent addresses as mining-only addresses
DragonX is a private chain (-ac_private=1): consensus rejects any
non-coinbase output to a transparent address, so a t-address can only
ever receive mining rewards, and its coins can only move to a shielded
address. The wallet treated them like ordinary recipients.
Block paying one:
- Send: a transparent recipient shows "Mining address - can't be paid"
and disables Review Send (tooltip explains; ask for a zs... address).
Typing, paste, contacts and payment URIs all go through this field.
- Overview drag-to-transfer: a mining-address row is never a transfer
target (it only reorders).
- Pool payout must be shielded (pools pay with ordinary transactions):
field tooltip, disabled Start button and the start check say why.
- isValidRecipientAddress() is now shielded-only; new isDragonXAddress()
and classifyRecipient() (Shielded / MiningOnly / Invalid).
Call them mining addresses:
- Overview: "Mining rewards" card (amber "Not yet shielded" when there
is a balance; hover explains; click opens the Shield dialog), "New
mining address" button with a tooltip, rows typed "Mining".
- QR / label dialogs, portfolio filter, contact badge ("Mining only"),
Receive notifications.
i18n: 17 new keys in all 8 languages, 12 dead keys removed, CJK subset
rebuilt. Tests: recipient classification, translation completeness.
UI sweep: new "send-mining-recipient" target.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -71,7 +71,7 @@ public:
|
||||
|
||||
// Address preview
|
||||
Type().textColored(TypeStyle::Caption, OnSurfaceMedium(),
|
||||
s_isZ ? TR("shielded_address") : TR("transparent_address"));
|
||||
s_isZ ? TR("shielded_address") : TR("mining_address"));
|
||||
ImGui::Spacing();
|
||||
{
|
||||
std::string display = s_address;
|
||||
|
||||
@@ -213,12 +213,13 @@ void RenderSharedAddressList(App* app, float listH, float availW,
|
||||
});
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (TactileButton(TR("new_t_address"), ImVec2(buttonWidth, 0),
|
||||
if (TactileButton(TR("new_mining_address"), ImVec2(buttonWidth, 0),
|
||||
S.resolveFont(addrBtn.font.empty() ? "button" : addrBtn.font))) {
|
||||
app->createNewTAddress([](const std::string& addr) {
|
||||
DEBUG_LOGF("Created new t-address: %s\n", addr.c_str());
|
||||
});
|
||||
}
|
||||
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("tt_new_mining_address"));
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::Dummy(ImVec2(0, Layout::spacingXs()));
|
||||
@@ -402,13 +403,13 @@ void RenderSharedAddressList(App* app, float listH, float availW,
|
||||
const auto& target = rows[s_dropTargetIdx];
|
||||
material::Tooltip("%s\n%s\n\n%s %s",
|
||||
truncateAddress(addr.address, 32).c_str(),
|
||||
row.isZ ? TR("shielded") : TR("transparent"),
|
||||
row.isZ ? TR("shielded") : TR("addr_type_mining"),
|
||||
TR("transfer_to"),
|
||||
truncateAddress(target.info->address, 32).c_str());
|
||||
} else {
|
||||
material::Tooltip("%s\n%s\n\n%s",
|
||||
truncateAddress(addr.address, 32).c_str(),
|
||||
row.isZ ? TR("shielded") : TR("transparent"),
|
||||
row.isZ ? TR("shielded") : TR("addr_type_mining"),
|
||||
TR("address_reorder_hint"));
|
||||
}
|
||||
}
|
||||
@@ -440,7 +441,8 @@ void RenderSharedAddressList(App* app, float listH, float availW,
|
||||
if (s_dragActive && s_dragIdx != row_idx && material::IsRectHovered(rowPos, rowEnd)) {
|
||||
s_dropTargetIdx = row_idx;
|
||||
const float relY = rowH > 0.0f ? (mousePos.y - rowPos.y) / rowH : 0.5f;
|
||||
s_dropMode = (relY < 0.30f || relY > 0.70f) ? 1 : 0;
|
||||
// A mining (transparent) address can't be paid, so it is never a transfer target: reorder only.
|
||||
s_dropMode = (!row.isZ || relY < 0.30f || relY > 0.70f) ? 1 : 0;
|
||||
if (s_dropMode == 0) {
|
||||
// Transfer: highlight the whole target row.
|
||||
dl->AddRectFilled(rowPos, rowEnd, WithAlpha(Primary(), 40), 4.0f * dp);
|
||||
@@ -542,7 +544,7 @@ void RenderSharedAddressList(App* app, float listH, float availW,
|
||||
// ---- Type label (first line) ----
|
||||
float labelX = rowLayout.labelX;
|
||||
{
|
||||
const char* typeLabel = row.isZ ? TR("shielded") : TR("transparent");
|
||||
const char* typeLabel = row.isZ ? TR("shielded") : TR("addr_type_mining");
|
||||
const char* hiddenTag = row.hidden ? TR("hidden_tag") : "";
|
||||
const char* miningTag = row.mining ? TR("mining_tag") : "";
|
||||
char typeBuf[64];
|
||||
@@ -682,7 +684,7 @@ void RenderSharedAddressList(App* app, float listH, float availW,
|
||||
KeyExportDialog::show(addr.address, KeyExportDialog::KeyType::Viewing);
|
||||
}
|
||||
if (ImGui::MenuItem(TR("show_qr_code")))
|
||||
QRPopupDialog::show(addr.address, row.isZ ? TR("z_address") : TR("t_address"));
|
||||
QRPopupDialog::show(addr.address, row.isZ ? TR("z_address") : TR("mining_address"));
|
||||
ImGui::Separator();
|
||||
if (row.hidden) {
|
||||
if (ImGui::MenuItem(TR("restore_address")))
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "qr_popup_dialog.h"
|
||||
#include "address_label_dialog.h"
|
||||
#include "address_transfer_dialog.h"
|
||||
#include "shield_dialog.h"
|
||||
#include "send_tab.h"
|
||||
#include "../../app.h"
|
||||
#include "../../config/settings.h"
|
||||
@@ -531,7 +532,7 @@ static void RenderBalanceClassic(App* app)
|
||||
float cy = cMin.y + cardPadLg;
|
||||
|
||||
dl->AddText(ovFont, ovFont->LegacySize, ImVec2(cx, cy),
|
||||
OnSurfaceMedium(), TR("transparent"));
|
||||
OnSurfaceMedium(), TR("mining_rewards"));
|
||||
cy += ovFont->LegacySize + ovGap;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%.8f", s_dispTransparent);
|
||||
@@ -543,18 +544,24 @@ static void RenderBalanceClassic(App* app)
|
||||
OnSurfaceMedium(), DRAGONX_TICKER);
|
||||
cy += sub1->LegacySize + valGap;
|
||||
|
||||
snprintf(buf, sizeof(buf), TR("baltab_t_addresses_count"),
|
||||
(int)state.t_addresses.size());
|
||||
// Rewards waiting at a mining address: say so, and let a click shield them now.
|
||||
const bool unshielded = s_dispTransparent > 0.0;
|
||||
if (unshielded) snprintf(buf, sizeof(buf), "%s", TR("mining_rewards_unshielded"));
|
||||
else snprintf(buf, sizeof(buf), TR("baltab_mining_addresses_count"), (int)state.t_addresses.size());
|
||||
dl->AddText(capFont, capFont->LegacySize, ImVec2(cx, cy),
|
||||
OnSurfaceDisabled(), buf);
|
||||
unshielded ? amberCol : OnSurfaceDisabled(), buf);
|
||||
|
||||
// Hover glow + click to Receive
|
||||
// Hover glow + explain; click shields waiting rewards (else opens Receive)
|
||||
if (material::IsRectHovered(cMin, cMax)) {
|
||||
dl->AddRect(cMin, cMax, IM_COL32(255, 255, 255, (int)S.drawElement("tabs.balance", "hover-glow-alpha").sizeOr(40.0f)),
|
||||
cardSpec.rounding, 0, S.drawElement("tabs.balance", "hover-glow-thickness").sizeOr(1.5f) * dp);
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
|
||||
if (ImGui::IsMouseClicked(0))
|
||||
app->setCurrentPage(NavPage::Receive);
|
||||
material::Tooltip("%s%s%s", TR("mining_card_tooltip"), unshielded ? "\n\n" : "",
|
||||
unshielded ? TR("mining_card_click_to_shield") : "");
|
||||
if (ImGui::IsMouseClicked(0)) {
|
||||
if (unshielded) ShieldDialog::showShieldCoinbase();
|
||||
else app->setCurrentPage(NavPage::Receive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,7 +810,7 @@ static void RenderBalanceDonut(App* app) {
|
||||
|
||||
// Transparent legend
|
||||
dl->AddCircleFilled(ImVec2(legendX + 5 * dp, legendY + capFont->LegacySize * 0.5f), legendDotR, Warning());
|
||||
snprintf(buf, sizeof(buf), TR("baltab_transparent_amount"), s_dispTransparent);
|
||||
snprintf(buf, sizeof(buf), TR("baltab_mining_amount"), s_dispTransparent);
|
||||
dl->AddText(capFont, capFont->LegacySize, ImVec2(legendX + legendXOff, legendY), Warning(), buf);
|
||||
legendY += capFont->LegacySize + legendSectionGap;
|
||||
|
||||
@@ -976,7 +983,7 @@ static void RenderBalanceConsolidated(App* app) {
|
||||
// Transparent bar
|
||||
float transX = cardMin.x + pad * 2 + halfW;
|
||||
barY = divY + Layout::spacingSm();
|
||||
std::string transLabelUpper = TR("transparent");
|
||||
std::string transLabelUpper = TR("mining_rewards");
|
||||
std::transform(transLabelUpper.begin(), transLabelUpper.end(), transLabelUpper.begin(),
|
||||
[](unsigned char c){ return (char)std::toupper(c); });
|
||||
dl->AddText(ovFont, ovFont->LegacySize, ImVec2(transX, barY), Warning(), transLabelUpper.c_str());
|
||||
@@ -1100,7 +1107,7 @@ static void RenderBalanceDashboard(App* app) {
|
||||
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c){ return (char)std::toupper(c); });
|
||||
return s;
|
||||
};
|
||||
std::string lblShielded = upperTR("shielded"), lblTransparent = upperTR("transparent");
|
||||
std::string lblShielded = upperTR("shielded"), lblTransparent = upperTR("mining_rewards");
|
||||
std::string lblQuickSend = upperTR("quick_send"), lblQuickReceive = upperTR("quick_receive");
|
||||
|
||||
TileInfo tiles[4] = {
|
||||
@@ -1240,7 +1247,7 @@ static void RenderBalanceVerticalStack(App* app) {
|
||||
RowInfo rowInfos[4] = {
|
||||
{TR("baltab_total_balance"), ICON_MD_ACCOUNT_BALANCE_WALLET, S.resolveColor("var(--accent-total)", OnSurface()), s_dispTotal, 1.0f},
|
||||
{TR("baltab_shielded"), ICON_MD_SHIELD, S.resolveColor("var(--accent-shielded)", Success()), s_dispShielded, shieldRatio},
|
||||
{TR("baltab_transparent"), ICON_MD_CIRCLE, S.resolveColor("var(--accent-transparent)", Warning()), s_dispTransparent, transRatio},
|
||||
{TR("mining_rewards"), ICON_MD_CIRCLE, S.resolveColor("var(--accent-transparent)", Warning()), s_dispTransparent, transRatio},
|
||||
{TR("baltab_market"), ICON_MD_TRENDING_UP, S.resolveColor("var(--accent-action)", Primary()), state.market.price_usd, 0.0f},
|
||||
};
|
||||
|
||||
@@ -1437,7 +1444,7 @@ static void RenderBalanceVertical2x2(App* app) {
|
||||
// Row 1: Market (left), Transparent (right)
|
||||
{
|
||||
{TR("baltab_market"), ICON_MD_TRENDING_UP, S.resolveColor("var(--accent-action)", Primary()), state.market.price_usd, 0.0f, true, false},
|
||||
{TR("baltab_transparent"), ICON_MD_CIRCLE, S.resolveColor("var(--accent-transparent)", Warning()), s_dispTransparent, transRatio, false, true},
|
||||
{TR("mining_rewards"), ICON_MD_CIRCLE, S.resolveColor("var(--accent-transparent)", Warning()), s_dispTransparent, transRatio, false, true},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1696,7 +1703,7 @@ static void RenderBalanceShield(App* app) {
|
||||
std::string shieldLabelUpper = TR("shielded");
|
||||
std::transform(shieldLabelUpper.begin(), shieldLabelUpper.end(), shieldLabelUpper.begin(),
|
||||
[](unsigned char c){ return (char)std::toupper(c); });
|
||||
std::string transLabelUpper = TR("transparent");
|
||||
std::string transLabelUpper = TR("mining_rewards");
|
||||
std::transform(transLabelUpper.begin(), transLabelUpper.end(), transLabelUpper.begin(),
|
||||
[](unsigned char c){ return (char)std::toupper(c); });
|
||||
dl->AddText(ovFont, ovFont->LegacySize, ImVec2(infoX, infoY), Success(), shieldLabelUpper.c_str());
|
||||
@@ -1855,7 +1862,7 @@ static void RenderBalanceTimeline(App* app) {
|
||||
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c){ return (char)std::toupper(c); });
|
||||
return s;
|
||||
};
|
||||
std::string cShielded = upperTR("shielded"), cTransparent = upperTR("transparent"), cMarket = upperTR("market");
|
||||
std::string cShielded = upperTR("shielded"), cTransparent = upperTR("mining_rewards"), cMarket = upperTR("market");
|
||||
SumCard cards[3] = {
|
||||
{cShielded.c_str(), Success(), s_dispShielded, false},
|
||||
{cTransparent.c_str(), Warning(), s_dispTransparent, false},
|
||||
@@ -2137,7 +2144,7 @@ static void RenderBalanceMinimal(App* app) {
|
||||
snprintf(buf, sizeof(buf), TR("balance_shielded_fmt"), s_dispShielded);
|
||||
Type().textColored(TypeStyle::Caption, Success(), buf);
|
||||
ImGui::SameLine(0, Layout::spacingLg());
|
||||
snprintf(buf, sizeof(buf), TR("balance_transparent_fmt"), s_dispTransparent);
|
||||
snprintf(buf, sizeof(buf), TR("balance_mining_fmt"), s_dispTransparent);
|
||||
Type().textColored(TypeStyle::Caption, Warning(), buf);
|
||||
|
||||
// USD value
|
||||
|
||||
@@ -624,7 +624,7 @@ void RenderContactsTab(App* app)
|
||||
float cy = origin.y + std::max(0.0f, (a.y - blockH) * 0.42f);
|
||||
float cx = origin.x + a.x * 0.5f;
|
||||
struct Chip { bool sh; const char* lbl; };
|
||||
Chip chips[2] = { { true, TR("contact_avatar_shielded") }, { false, TR("contact_avatar_transparent") } };
|
||||
Chip chips[2] = { { true, TR("contact_avatar_shielded") }, { false, TR("contact_chip_mining") } };
|
||||
for (int i = 0; i < 2; i++) {
|
||||
float ccx = cx + (i == 0 ? -(chipR + chipGap * 0.5f) : (chipR + chipGap * 0.5f));
|
||||
ImVec2 cc(ccx, cy + chipR);
|
||||
|
||||
@@ -624,7 +624,7 @@ static void pfDrawAddressSection(App* app)
|
||||
// Funded (right). Select-all is deferred so it applies to the freshly-filtered set below.
|
||||
bool selAllClicked = false;
|
||||
{
|
||||
const char* flabels[3] = { TR("portfolio_select_all"), TR("shielded"), TR("transparent") };
|
||||
const char* flabels[3] = { TR("portfolio_select_all"), TR("shielded"), TR("addr_type_mining") };
|
||||
const char* selLbl = TR("portfolio_select_shown");
|
||||
const char* clrLbl = TR("portfolio_clear_sel");
|
||||
ImGuiStyle& st = ImGui::GetStyle();
|
||||
|
||||
@@ -957,7 +957,9 @@ void RenderMiningControls(App* app, const WalletState& state, const MiningInfo&
|
||||
else if (poolBlockedBySolo)
|
||||
material::Tooltip("%s", TR("mining_stop_solo_for_pool"));
|
||||
else if (poolNeedsPayout)
|
||||
material::Tooltip("%s", TR("mining_pool_needs_payout_tooltip"));
|
||||
material::Tooltip("%s", util::isTransparentAddress(poolPayoutStr)
|
||||
? TR("mining_payout_needs_shielded")
|
||||
: TR("mining_pool_needs_payout_tooltip"));
|
||||
else
|
||||
material::Tooltip("%s", isMiningActive ? TR("stop_mining") : TR("start_mining"));
|
||||
}
|
||||
|
||||
@@ -413,7 +413,10 @@ void RenderMiningModeToggle(App* app, const WalletState& state, const MiningInfo
|
||||
if (currentWorkerStr.empty()) {
|
||||
material::Tooltip("%s", TR("mining_generate_z_address_hint"));
|
||||
} else if (currentWorkerStr != "x" && !util::isValidRecipientAddress(currentWorkerStr)) {
|
||||
material::Tooltip("%s", TR("mining_payout_invalid")); // block start below too (M-01)
|
||||
// Block start below too (M-01). A pool pays with ordinary transactions, which can't reach
|
||||
// a transparent (mining) address on this private chain: say so rather than "invalid".
|
||||
material::Tooltip("%s", util::isTransparentAddress(currentWorkerStr)
|
||||
? TR("mining_payout_needs_shielded") : TR("mining_payout_invalid"));
|
||||
} else {
|
||||
material::Tooltip("%s", TR("mining_payout_tooltip"));
|
||||
}
|
||||
|
||||
@@ -325,10 +325,10 @@ static void RenderAddressDropdown(App* app, float width) {
|
||||
app->createNewTAddress([](const std::string& addr) {
|
||||
s_generating_address = false;
|
||||
if (addr.empty())
|
||||
Notifications::instance().error(TR("failed_create_transparent"));
|
||||
Notifications::instance().error(TR("failed_create_mining_address"));
|
||||
else {
|
||||
s_pending_select_address = addr;
|
||||
Notifications::instance().success(TR("new_transparent_created"));
|
||||
Notifications::instance().success(TR("new_mining_address_created"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -693,6 +693,14 @@ static void RenderTxProgress(ImDrawList* dl, float x, float y, float w,
|
||||
// ============================================================================
|
||||
// Confirmation dialog
|
||||
// ============================================================================
|
||||
void SweepSetSendRecipient(App* app, const char* to) {
|
||||
(void)app;
|
||||
std::snprintf(s_from_address, sizeof(s_from_address), "%s",
|
||||
to ? "zs1demoprimaryshieldedaddressforuisweep000000000000000000000000000" : "");
|
||||
std::snprintf(s_to_address, sizeof(s_to_address), "%s", to ? to : "");
|
||||
s_amount = to ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
void SweepShowSendConfirm(App* app, bool show) {
|
||||
(void)app;
|
||||
if (show) {
|
||||
@@ -975,7 +983,7 @@ static bool RenderZeroBalanceCTA(App* app, ImDrawList* dl, float width) {
|
||||
// Action buttons (Send + Clear + Undo)
|
||||
// ============================================================================
|
||||
static void RenderActionButtons(App* app, float width, float vScale,
|
||||
bool is_valid_address, double available,
|
||||
bool is_valid_address, bool is_mining_addr, double available,
|
||||
const char* suffix = "") {
|
||||
auto& S = schema::UI();
|
||||
const float dp = Layout::dpiScale();
|
||||
@@ -1027,6 +1035,8 @@ static void RenderActionButtons(App* app, float width, float vScale,
|
||||
material::Tooltip("%s", TR("send_tooltip_syncing"));
|
||||
else if (s_from_address[0] == '\0')
|
||||
material::Tooltip("%s", TR("send_tooltip_select_source"));
|
||||
else if (is_mining_addr)
|
||||
material::Tooltip("%s", TR("send_mining_addr_blocked"));
|
||||
else if (!is_valid_address)
|
||||
material::Tooltip("%s", TR("send_tooltip_invalid_address"));
|
||||
else if (s_amount <= 0)
|
||||
@@ -1255,8 +1265,10 @@ void RenderSendTab(App* app)
|
||||
|
||||
double available = GetAvailableBalance(app);
|
||||
bool is_valid_z = IsValidShieldedAddr(s_to_address);
|
||||
// A transparent address is a mining address: it only ever receives mining rewards, and the network
|
||||
// rejects a payment to it (DragonX is a private chain). Recognise it, but never send to it.
|
||||
bool is_valid_t = IsValidTransparentAddr(s_to_address);
|
||||
bool is_valid_address = is_valid_z || is_valid_t;
|
||||
bool is_valid_address = is_valid_z;
|
||||
float sectionGap = Layout::spacingXl() * vScale;
|
||||
|
||||
char buf[128];
|
||||
@@ -1365,7 +1377,9 @@ void RenderSendTab(App* app)
|
||||
if (vz)
|
||||
Type().textColored(TypeStyle::Caption, Success(), TR("send_valid_shielded"));
|
||||
else
|
||||
Type().textColored(TypeStyle::Caption, Warning(), TR("send_valid_transparent"));
|
||||
Type().textColored(TypeStyle::Caption, Error(), TR("send_mining_addr_short"));
|
||||
if (vt && ImGui::IsItemHovered())
|
||||
material::Tooltip("%s", TR("send_mining_addr_blocked"));
|
||||
} else if (!checkPreview) {
|
||||
ImGui::SameLine();
|
||||
Type().textColored(TypeStyle::Caption, Error(), TR("invalid_address"));
|
||||
@@ -1405,7 +1419,8 @@ void RenderSendTab(App* app)
|
||||
trimmed.erase(trimmed.begin());
|
||||
while (!trimmed.empty() && (trimmed.back() == ' ' || trimmed.back() == '\n' || trimmed.back() == '\r' || trimmed.back() == '\t'))
|
||||
trimmed.pop_back();
|
||||
bool looksValid = dragonx::util::isValidRecipientAddress(trimmed);
|
||||
// Preview any address, a mining one too: once pasted, the field explains why it can't be paid.
|
||||
bool looksValid = dragonx::util::isDragonXAddress(trimmed);
|
||||
if (looksValid && s_to_address[0] == '\0') {
|
||||
s_preview_text = trimmed;
|
||||
s_paste_previewing = true;
|
||||
@@ -1626,7 +1641,7 @@ void RenderSendTab(App* app)
|
||||
ImGui::Dummy(ImVec2(0, innerGap * 0.5f));
|
||||
|
||||
// ---- ACTION BUTTONS (full width) ----
|
||||
RenderActionButtons(app, innerW, vScale, is_valid_address, available, "##main");
|
||||
RenderActionButtons(app, innerW, vScale, is_valid_address, is_valid_t, available, "##main");
|
||||
|
||||
// Add bottom padding
|
||||
ImGui::Dummy(ImVec2(0, pad * vScale));
|
||||
|
||||
@@ -30,6 +30,8 @@ void RenderSendConfirmPopup(App* app);
|
||||
* the only way an external driver (the full UI sweep) can reveal it. Fires no send.
|
||||
*/
|
||||
void SweepShowSendConfirm(App* app, bool show);
|
||||
// UI sweep: put `to` (nullptr: clear) in the recipient field, e.g. a mining address to show it can't be paid.
|
||||
void SweepSetSendRecipient(App* app, const char* to);
|
||||
|
||||
/**
|
||||
* @brief Pre-fill the "from" address in the send tab
|
||||
|
||||
Reference in New Issue
Block a user