Skip to content

Commit

Permalink
Merge branch 'development' into sw_update_API
Browse files Browse the repository at this point in the history
  • Loading branch information
SWvheerden authored Jan 29, 2024
2 parents 48429ed + a2872bb commit b7bb190
Show file tree
Hide file tree
Showing 23 changed files with 424 additions and 172 deletions.
107 changes: 86 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions applications/minotari_console_wallet/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#![allow(dead_code, unused)]

use std::{fs, path::PathBuf, str::FromStr, sync::Arc};
use std::{fs, path::PathBuf, str::FromStr, sync::Arc, time::Instant};

use log::*;
use minotari_app_utilities::identity_management::setup_node_identity;
Expand Down Expand Up @@ -442,6 +442,8 @@ pub async fn init_wallet(
.map_err(|e| ExitError::new(ExitCode::WalletError, format!("Error consensus manager. {}", e)))?;
let factories = CryptoFactories::default();

let now = Instant::now();

let mut wallet = Wallet::start(
wallet_config,
config.peer_seeds.clone(),
Expand All @@ -463,12 +465,11 @@ pub async fn init_wallet(
WalletError::CommsInitializationError(cie) => cie.to_exit_error(),
e => ExitError::new(ExitCode::WalletError, format!("Error creating Wallet Container: {}", e)),
})?;
if let Some(hs) = wallet.comms.hidden_service() {
wallet
.db
.set_tor_identity(hs.tor_identity().clone())
.map_err(|e| ExitError::new(ExitCode::WalletError, format!("Problem writing tor identity. {}", e)))?;
}

error!(
target: LOG_TARGET,
"Wallet started in {}ms", now.elapsed().as_millis()
);

if let Some(file_name) = seed_words_file_name {
let seed_words = wallet.get_seed_words(&MnemonicLanguage::English)?.join(" ");
Expand Down
38 changes: 37 additions & 1 deletion applications/minotari_console_wallet/src/ui/state/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,12 @@ impl AppStateInner {
});

self.data.contacts = ui_contacts;
self.refresh_network_id().await?;
self.updated = true;
Ok(())
}

pub async fn refresh_burnt_proofs_state(&mut self) -> Result<(), UiError> {
// let db_burnt_proofs = self.wallet.db.get_burnt_proofs()?;
let db_burnt_proofs = self.wallet.db.fetch_burnt_proofs()?;
let mut ui_proofs: Vec<UiBurntProof> = vec![];

Expand All @@ -921,7 +921,43 @@ impl AppStateInner {
Ok(())
}

pub async fn refresh_network_id(&mut self) -> Result<(), UiError> {
let wallet_id = WalletIdentity::new(self.wallet.comms.node_identity(), self.wallet.network.as_network());
let eid = wallet_id.address.to_emoji_string();
let qr_link = format!(
"tari://{}/transactions/send?tariAddress={}",
wallet_id.network,
wallet_id.address.to_hex()
);
let code = QrCode::new(qr_link).unwrap();
let image = code
.render::<unicode::Dense1x2>()
.dark_color(unicode::Dense1x2::Dark)
.light_color(unicode::Dense1x2::Light)
.build()
.lines()
.skip(1)
.fold("".to_string(), |acc, l| format!("{}{}\n", acc, l));
let identity = MyIdentity {
tari_address: wallet_id.address.to_hex(),
network_address: wallet_id
.node_identity
.public_addresses()
.iter()
.map(|a| a.to_string())
.collect::<Vec<_>>()
.join(", "),
emoji_id: eid,
qr_code: image,
node_id: wallet_id.node_identity.node_id().to_string(),
};
self.data.my_identity = identity;
self.updated = true;
Ok(())
}

pub async fn refresh_connected_peers_state(&mut self) -> Result<(), UiError> {
self.refresh_network_id().await?;
let connections = self.wallet.comms.connectivity().get_active_connections().await?;
let peer_manager = self.wallet.comms.peer_manager();
let mut peers = Vec::with_capacity(connections.len());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ impl WalletEventMonitor {
let mut base_node_changed = wallet_connectivity.get_current_base_node_watcher();

let mut base_node_events = self.app_state_inner.read().await.get_base_node_event_stream();
// let mut software_update_notif = self
// .app_state_inner
// .read()
// .await
// .get_software_updater()
// .new_update_notifier()
// .clone();

let mut contacts_liveness_events = self.app_state_inner.read().await.get_contacts_liveness_event_stream();

Expand Down
Loading

0 comments on commit b7bb190

Please sign in to comment.