reset desktop fee rate type state provider
What changed, and why it matters
This commit fixes a state-carryover bug in the desktop version of Stack Wallet. A global fee-rate setting was not being reset when a user opened a new send form, so a custom fee chosen in one wallet could silently carry over to another wallet's send form. If the user did not notice, a transaction could be sent with an unexpected (possibly very low or very high) custom fee. The patch resets the fee type to 'average' each time the desktop send form is initialized.
Review whether other global desktop state providers (especially those controlling transaction parameters such as fee rate, send amount, or recipient address) are similarly reset when their associated forms are initialized or disposed. Consider adding automated UI/state tests that verify no cross-wallet state leakage for fee settings.
Security signals we found
State-carryover/cross-wallet UI state bug
Potential use of unintended custom transaction fee
Global provider not disposed between wallet contexts
Defensive reset of fee rate type on form initialization
Evidence from the diff
The change adds a post-frame callback in initState() of DesktopSendFeeForm that resets feeRateTypeDesktopStateProvider.state to FeeRateType.average. The accompanying comment explains the provider is global and never disposed, so without this reset a stale custom selection from another wallet/send form could lead to a send using an unset custom fee rate. The fix is localized to the desktop send fee form and does not alter the provider lifecycle.
Changed components
lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dartDesktop send fee form UI statefeeRateTypeDesktopStateProviderInspect captured patch +10 / −0
diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart
index 1f9dd69..b17725b 100644
--- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart
+++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart
@@ -92,6 +92,16 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
void initState() {
super.initState();
cryptoCurrency = ref.read(pWalletCoin(widget.walletId));
+
+ // The fee rate type provider is global and never disposed. Reset it here
+ // so a stale custom selection from another wallet/send form can't cause a
+ // send using an unset custom fee rate.
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) {
+ ref.read(feeRateTypeDesktopStateProvider.state).state =
+ FeeRateType.average;
+ }
+ });
}
@override
Why this scored 50/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.