diff --git a/locales/de.yml b/locales/de.yml index ac8da44..4b50f39 100644 --- a/locales/de.yml +++ b/locales/de.yml @@ -23,8 +23,8 @@ scan_result: Scan Ergebnis back: zurück share: teilen theme: 'Theme:' -dark: dunkel -light: hell +dark: Dunkel +light: Hell choose_file: Datei auswählen wallets: await_conf_amount: Erwarte Bestätigung @@ -146,7 +146,7 @@ transport: network: self: Netzwerk type: 'Netzwerk Typ:' - mainnet: Haupt + mainnet: Main testnet: Test connections: Verbindungen node: Integrierte Node @@ -226,6 +226,7 @@ network_settings: stratum_port: 'Stratum Port:' port_unavailable: Der angegebene Port ist nicht verfügbar restart_node_required: Ein Neustart der Node ist erforderlich, um die Änderungen zu übernehmen. + choose_wallet: Wählen Wallet enable: Aktivieren disable: Deaktivieren restart: Neustarten diff --git a/locales/en.yml b/locales/en.yml index 94bc247..476035d 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -226,6 +226,7 @@ network_settings: stratum_port: 'Stratum port:' port_unavailable: Specified port is unavailable restart_node_required: Node restart is required to apply changes. + choose_wallet: Choose wallet enable: Enable disable: Disable restart: Restart diff --git a/locales/fr.yml b/locales/fr.yml index 2baadca..ea2568c 100644 --- a/locales/fr.yml +++ b/locales/fr.yml @@ -226,6 +226,7 @@ network_settings: stratum_port: 'Port Stratum :' port_unavailable: Le port spécifié est indisponible restart_node_required: Le redémarrage du noeud est nécessaire pour appliquer les modifications. + choose_wallet: Choisir un portefeuille enable: Activer disable: Désactiver restart: Redémarrer diff --git a/locales/ru.yml b/locales/ru.yml index 67beea1..e91ad0a 100644 --- a/locales/ru.yml +++ b/locales/ru.yml @@ -226,6 +226,7 @@ network_settings: stratum_port: 'Порт Stratum:' port_unavailable: Указанный порт недоступен restart_node_required: Для применения изменений требуется перезапуск узла. + choose_wallet: Выбрать кошелёк enable: Включить disable: Выключить restart: Перезапуск diff --git a/locales/tr.yml b/locales/tr.yml index ac2d890..a3305a6 100644 --- a/locales/tr.yml +++ b/locales/tr.yml @@ -226,6 +226,7 @@ network_settings: stratum_port: 'Stratum port:' port_unavailable: Belirlenen port mevcut degil restart_node_required: Degisiklikler için yeniden Node BASLAT + choose_wallet: Cüzdan seç enable: Etkinlestir disable: Devredisi birak restart: Restart diff --git a/src/gui/views/modal.rs b/src/gui/views/modal.rs index c60dbe2..6cff50e 100644 --- a/src/gui/views/modal.rs +++ b/src/gui/views/modal.rs @@ -319,24 +319,19 @@ impl Modal { // Draw title content. let title_resp = ui.allocate_ui_at_rect(rect, |ui| { ui.vertical_centered_justified(|ui| { - ui.add_space(Self::DEFAULT_MARGIN + if !View::is_desktop() { - 1.0 - } else { - 0.0 - }); + ui.add_space(Self::DEFAULT_MARGIN + 1.0); ui.label(RichText::new(self.title.as_ref().unwrap()) .size(19.0) .color(Colors::title(true)) ); ui.add_space(Self::DEFAULT_MARGIN); + // Draw line below title. + View::horizontal_line(ui, Colors::item_stroke()); }); }).response; // Setup background shape to be painted behind title content. bg_shape.rect = title_resp.rect; ui.painter().set(bg_idx, bg_shape); - - // Draw line below title. - View::horizontal_line(ui, Colors::stroke()); } } \ No newline at end of file diff --git a/src/gui/views/network/mining.rs b/src/gui/views/network/mining.rs index 9961a5d..5a7475d 100644 --- a/src/gui/views/network/mining.rs +++ b/src/gui/views/network/mining.rs @@ -24,17 +24,27 @@ use crate::gui::views::{NetworkContent, Content, View}; use crate::gui::views::network::setup::StratumSetup; use crate::gui::views::network::types::{NetworkTab, NetworkTabType}; use crate::node::{Node, NodeConfig}; +use crate::wallet::WalletConfig; /// Mining tab content. pub struct NetworkMining { /// Stratum server setup content. stratum_server_setup: StratumSetup, + + /// Wallet name for rewards. + wallet_name: String, } impl Default for NetworkMining { fn default() -> Self { + let wallet_name = if let Some(id) = NodeConfig::get_stratum_wallet_id() { + WalletConfig::name_by_id(id).unwrap_or("-".to_string()) + } else { + "-".to_string() + }; Self { - stratum_server_setup: StratumSetup::default() + stratum_server_setup: StratumSetup::default(), + wallet_name, } } } @@ -103,10 +113,8 @@ impl NetworkTab for NetworkMining { [true, false, true, false]); }); columns[1].vertical_centered(|ui| { - //TODO: Stratum mining wallet listening address. Replace with local wallet name. - let wallet_addr = NodeConfig::get_stratum_wallet_addr().replace("http://", ""); View::rounded_box(ui, - wallet_addr, + self.wallet_name.clone(), t!("network_mining.rewards_wallet"), [false, true, false, true]); }); diff --git a/src/gui/views/network/setup/stratum.rs b/src/gui/views/network/setup/stratum.rs index 474b17d..09c8581 100644 --- a/src/gui/views/network/setup/stratum.rs +++ b/src/gui/views/network/setup/stratum.rs @@ -21,6 +21,7 @@ use crate::gui::views::{Modal, View}; use crate::gui::views::network::settings::NetworkSettings; use crate::gui::views::types::{ModalContainer, ModalPosition, TextEditOptions}; use crate::node::{Node, NodeConfig}; +use crate::wallet::WalletConfig; /// Stratum server setup section content. pub struct StratumSetup { @@ -35,6 +36,9 @@ pub struct StratumSetup { /// Flag to check if stratum port from saved config value is available. is_port_available: bool, + /// Wallet name to receive rewards. + wallet_name: Option, + /// Attempt time value in seconds to mine on a particular header. attempt_time_edit: String, @@ -56,11 +60,17 @@ impl Default for StratumSetup { fn default() -> Self { let (ip, port) = NodeConfig::get_stratum_address(); let is_port_available = NodeConfig::is_stratum_port_available(&ip, &port); + let wallet_name = if let Some(id) = NodeConfig::get_stratum_wallet_id() { + WalletConfig::name_by_id(id) + } else { + None + }; Self { available_ips: NodeConfig::get_ip_addrs(), stratum_port_edit: port, stratum_port_available_edit: is_port_available, is_port_available, + wallet_name, attempt_time_edit: NodeConfig::get_stratum_attempt_time(), min_share_diff_edit: NodeConfig::get_stratum_min_share_diff(), modal_ids: vec![ @@ -101,7 +111,7 @@ impl StratumSetup { ui.vertical_centered(|ui| { // Show loading indicator or controls to start/stop stratum server if port is available. - if self.is_port_available { + if self.is_port_available && self.wallet_name.is_some() { if Node::is_stratum_starting() || Node::is_stratum_stopping() { ui.vertical_centered(|ui| { ui.add_space(8.0); @@ -145,6 +155,25 @@ impl StratumSetup { View::horizontal_line(ui, Colors::item_stroke()); ui.add_space(6.0); + // Show wallet name. + ui.add_space(2.0); + ui.label(RichText::new(t!("wallets.wallet")) + .size(16.0) + .color(Colors::gray())); + ui.add_space(2.0); + ui.label(RichText::new(self.wallet_name.as_ref().unwrap_or(&"-".to_string())) + .size(16.0) + .color(Colors::white_or_black(true))); + ui.add_space(8.0); + + View::button(ui, t!("network_settings.choose_wallet"), Colors::button(), || { + //TODO: select wallet + }); + + ui.add_space(12.0); + View::horizontal_line(ui, Colors::item_stroke()); + ui.add_space(6.0); + // Show message when IP addresses are not available on the system. if self.available_ips.is_empty() { NetworkSettings::no_ip_address_ui(ui); diff --git a/src/gui/views/wallets/modals/connection.rs b/src/gui/views/wallets/modals/conn.rs similarity index 98% rename from src/gui/views/wallets/modals/connection.rs rename to src/gui/views/wallets/modals/conn.rs index bc26042..634a2fe 100644 --- a/src/gui/views/wallets/modals/connection.rs +++ b/src/gui/views/wallets/modals/conn.rs @@ -30,6 +30,7 @@ pub struct WalletConnectionModal { /// Flag to show connection creation. show_conn_creation: bool, + /// External connection creation content. add_ext_conn_content: ExternalConnectionModal } @@ -72,7 +73,7 @@ impl WalletConnectionModal { }) .id_source("integrated_node") .scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden) - .auto_shrink([false; 2]) + .auto_shrink([true; 2]) .show(ui, |ui| { ui.add_space(2.0); diff --git a/src/gui/views/wallets/modals/mod.rs b/src/gui/views/wallets/modals/mod.rs index 511957c..a4b1622 100644 --- a/src/gui/views/wallets/modals/mod.rs +++ b/src/gui/views/wallets/modals/mod.rs @@ -12,5 +12,5 @@ // See the License for the specific language governing permissions and // limitations under the License. -mod connection; -pub use connection::*; \ No newline at end of file +mod conn; +pub use conn::*; \ No newline at end of file diff --git a/src/node/config.rs b/src/node/config.rs index 06d28a4..4fbca49 100644 --- a/src/node/config.rs +++ b/src/node/config.rs @@ -185,6 +185,9 @@ impl NodeConfig { // Generate random p2p and api ports. Self::setup_default_ports(&mut config); + // Clear wallet listener url (actually it will be wallet id). + config.server.stratum_mining_config.clone().unwrap().wallet_listener_url = "".to_string(); + Settings::write_to_file(&config, path); config } @@ -364,9 +367,30 @@ impl NodeConfig { } /// Get stratum mining server wallet address to get rewards. - pub fn get_stratum_wallet_addr() -> String { + pub fn get_stratum_wallet_id() -> Option { let r_config = Settings::node_config_to_read(); - r_config.node.clone().server.stratum_mining_config.unwrap().wallet_listener_url + let id = r_config.node.clone().server.stratum_mining_config.unwrap().wallet_listener_url; + return if id.is_empty() { + None + } else { + if let Ok(id) = id.parse::() { + Some(id) + } else { + None + } + } + } + + /// Save stratum mining server wallet address to get rewards. + pub fn save_stratum_wallet_id(id: i64) { + let w_config = Settings::node_config_to_update(); + w_config.node + .clone() + .server + .stratum_mining_config + .unwrap() + .wallet_listener_url = id.to_string(); + w_config.save(); } /// Get the amount of time in seconds to attempt to mine on a particular header. diff --git a/src/wallet/config.rs b/src/wallet/config.rs index 6256c72..a7c46a9 100644 --- a/src/wallet/config.rs +++ b/src/wallet/config.rs @@ -92,6 +92,16 @@ impl WalletConfig { None } + /// Get wallet name by provided identifier. + pub fn name_by_id(id: i64) -> Option { + let mut wallet_dir = WalletConfig::get_base_path(AppConfig::chain_type()); + wallet_dir.push(id.to_string()); + if let Some(cfg) = Self::load(wallet_dir) { + return Some(cfg.name); + } + None + } + /// Save wallet config. pub fn save(&self) { let config_path = Self::get_config_file_path(self.chain_type, self.id);