auto-select custom node on wallet creation (#3592)
What changed, and why it matters
This commit fixes a wallet setup flow where a user-added custom server node was saved but not actually selected for use. It also adds a safeguard so node-change notifications only reconnect the active wallet when the node's cryptocurrency type matches the wallet's type. The practical effect is to prevent the wallet from silently ignoring a user's custom node choice or from trying to connect a wallet to an incompatible node.
No immediate action required; this appears to be a defensive correctness fix. Users creating wallets with custom nodes should verify the selected node is active after wallet creation. Reviewers may want to confirm that setAsCurrent handles null editingNode safely and that the type comparison covers all wallet/node type mappings.
Security signals we found
UI flow fix ensuring user-configured custom node is actually activated
Type guard added before node reconnection to prevent mismatched wallet/node connections
Asynchronous save operations now awaited before subsequent logic runs
Evidence from the diff
Two changes: (1) In advanced_privacy_settings_page.dart, after saving a custom node during wallet creation, the code now calls nodeViewModel.setAsCurrent(…) so the newly saved node becomes the current node. The save calls are also awaited. (2) In on_current_node_change.dart, observers for nodes and powNodes now check change.newValue?.type == appStore.wallet!.type before calling connectToNode/connectToPowNode. This avoids cross-type node connection attempts and ensures the reaction only applies to the relevant wallet type.
Changed components
lib/reactions/on_current_node_change.dartlib/src/screens/new_wallet/advanced_privacy_settings_page.dartInspect captured patch +10 / −5
diff --git a/lib/reactions/on_current_node_change.dart b/lib/reactions/on_current_node_change.dart
index 4b49d05a..8b67674a 100644
--- a/lib/reactions/on_current_node_change.dart
+++ b/lib/reactions/on_current_node_change.dart
@@ -8,14 +8,18 @@ void startOnCurrentNodeChangeReaction(AppStore appStore) {
_onCurrentNodeChangeReaction?.reaction.dispose();
appStore.settingsStore.nodes.observe((change) async {
try {
- await appStore.wallet!.connectToNode(node: change.newValue!);
+ if(change.newValue?.type == appStore.wallet!.type) {
+ await appStore.wallet!.connectToNode(node: change.newValue!);
+ }
} catch (e) {
printV(e.toString());
}
});
appStore.settingsStore.powNodes.observe((change) async {
try {
- await appStore.wallet!.connectToPowNode(node: change.newValue!);
+ if(change.newValue?.type == appStore.wallet!.type) {
+ await appStore.wallet!.connectToPowNode(node: change.newValue!);
+ }
} catch (e) {
printV(e.toString());
}
diff --git a/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart b/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart
index 2f190c85..a39235b8 100644
--- a/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart
+++ b/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart
@@ -343,13 +343,14 @@ class _AdvancedPrivacySettingsBodyState extends State<_AdvancedPrivacySettingsBo
),
const SizedBox(height: 24),
LoadingPrimaryButton(
- onPressed: () {
+ onPressed: () async {
if (widget.privacySettingsViewModel.addCustomNode) {
if (_formKey.currentState != null && !_formKey.currentState!.validate()) {
return;
}
- widget.nodeViewModel.save();
+ await widget.nodeViewModel.save();
+ widget.nodeViewModel.setAsCurrent(widget.nodeViewModel.editingNode!);
}
if (testnetValue == true &&
widget.privacySettingsViewModel.type == WalletType.bitcoin) {
@@ -358,7 +359,7 @@ class _AdvancedPrivacySettingsBodyState extends State<_AdvancedPrivacySettingsBo
widget.nodeViewModel.address = publicBitcoinTestnetElectrumAddress;
widget.nodeViewModel.port = publicBitcoinTestnetElectrumPort;
- widget.nodeViewModel.save();
+ await widget.nodeViewModel.save();
}
if (_passphraseFormKey.currentState != null &&
!_passphraseFormKey.currentState!.validate()) {
Why this scored 27/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.