fix: Tier-2 mediums — input trims, confirmations, amount normalization
More robustness fixes from the audit (the import-key pattern, lower severity):
- Trim pasted input before use/validation: network add-server URL/label,
lite-wallet key import (+ block empty), validate-address, address-book entry.
- Confirmations for destructive/irreversible actions:
- Address-book Delete now needs a confirming second click (no undo).
- Console `stop` needs a confirming second `stop` (it shuts down the node).
- Wizard "Skip" encryption needs a confirming second click (keys stored
unencrypted).
- Send amount: normalize to 8dp (satoshi precision) on both the DRGX and USD
inputs so digits past 8dp aren't silently dropped between the preview/review
and what's actually sent.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1322,7 +1322,8 @@ void RenderSendTab(App* app)
|
||||
// USD input mode — no step buttons (step=0)
|
||||
ImGui::PushItemWidth(amtInputW);
|
||||
if (ImGui::InputDouble("##AmountUSD", &s_usd_amount, 0, 0, "$%.2f")) {
|
||||
s_amount = s_usd_amount / market.price_usd;
|
||||
// Normalize to 8dp (satoshi precision) so the reviewed/sent DRGX matches the preview.
|
||||
s_amount = std::round((s_usd_amount / market.price_usd) * 1e8) / 1e8;
|
||||
}
|
||||
// Draw DRGX equivalent inside the input field (right-aligned overlay)
|
||||
{
|
||||
@@ -1343,6 +1344,9 @@ void RenderSendTab(App* app)
|
||||
// DRGX input mode — no step buttons (step=0)
|
||||
ImGui::PushItemWidth(amtInputW);
|
||||
if (ImGui::InputDouble("##Amount", &s_amount, 0, 0, "%.8f")) {
|
||||
// Normalize to 8dp so digits past satoshi precision aren't silently dropped at send.
|
||||
s_amount = std::round(s_amount * 1e8) / 1e8;
|
||||
if (s_amount < 0) s_amount = 0;
|
||||
if (market.price_usd > 0)
|
||||
s_usd_amount = s_amount * market.price_usd;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user