From 8f22db5eea5ba2306506321285d56598b689f6e2 Mon Sep 17 00:00:00 2001 From: DanS Date: Sun, 7 Jun 2026 14:18:16 -0500 Subject: [PATCH] fix(send): resolve source balance by address, not list index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GetAvailableBalance() read state.addresses[s_selected_from_idx], but the index desyncs from s_from_address (the value actually debited) after an address-list refresh, and is left at -1 when the source is chosen from another tab's "Send from this address" — which made the sufficiency check see a 0 balance and wrongly block a valid send. Look the balance up by matching the source address string. Co-Authored-By: Claude Opus 4.8 --- src/ui/windows/send_tab.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ui/windows/send_tab.cpp b/src/ui/windows/send_tab.cpp index ca0ff2a..d045039 100644 --- a/src/ui/windows/send_tab.cpp +++ b/src/ui/windows/send_tab.cpp @@ -130,6 +130,15 @@ static void ClearFormWithUndo() { static double GetAvailableBalance(App* app) { const auto& state = app->getWalletState(); + // Resolve the balance by the source ADDRESS STRING (the value actually debited on send), + // not a stored list index. The index desyncs from s_from_address after an address-list + // refresh, and is left at -1 when the source is chosen from another tab ("Send from this + // address") — which previously made the sufficiency check see 0 and block a valid send. + if (s_from_address[0] != '\0') { + for (const auto& a : state.addresses) { + if (a.address == s_from_address) return a.balance; + } + } if (s_selected_from_idx >= 0 && s_selected_from_idx < static_cast(state.addresses.size())) { return state.addresses[s_selected_from_idx].balance; }