Skip to content

Commit

Permalink
fix: fix custom wallet startup logic for console wallet (#5429)
Browse files Browse the repository at this point in the history
Description
---
Added logic so that the wallet will not ask to connect to a detected
base node if a custom base node has already been set in the database.

Motivation and Context
---
The custom-configured base node was ignored.

How Has This Been Tested?
---
System-level testing

What process can a PR reviewer use to test or verify this change?
---
- Start console wallet without `config.wallet.custom_base_node` set
where a base node is running locally and accept the prompt to connect to
the detected base node.
- With _Network_ tab configure a custom base node that is different to
the one that is running locally.
- Exit.
- Restart the console walle.
- Verify that the user is not prompted again to connect to the local
base node.

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
hansieodendaal committed May 31, 2023
1 parent 9d0d8b5 commit 0c1e576
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions applications/tari_console_wallet/src/init/mod.rs
Expand Up @@ -274,15 +274,23 @@ pub async fn get_base_node_peer_config(
wallet: &mut WalletSqlite,
non_interactive_mode: bool,
) -> Result<PeerConfig, ExitError> {
let mut use_custom_base_node_peer = false;
let mut selected_base_node = match config.wallet.custom_base_node {
Some(ref custom) => SeedPeer::from_str(custom)
.map(|node| Some(Peer::from(node)))
.map_err(|err| ExitError::new(ExitCode::ConfigError, format!("Malformed custom base node: {}", err)))?,
None => get_custom_base_node_peer_from_db(wallet),
None => {
if let Some(custom_base_node_peer) = get_custom_base_node_peer_from_db(wallet) {
use_custom_base_node_peer = true;
Some(custom_base_node_peer)
} else {
None
}
},
};

// If the user has not explicitly set a base node in the config, we try detect one
if !non_interactive_mode && config.wallet.custom_base_node.is_none() {
if !non_interactive_mode && config.wallet.custom_base_node.is_none() && !use_custom_base_node_peer {
if let Some(detected_node) = detect_local_base_node(config.wallet.network).await {
match selected_base_node {
Some(ref base_node) if base_node.public_key == detected_node.public_key => {
Expand Down

0 comments on commit 0c1e576

Please sign in to comment.