diff --git a/common/bandwidth-controller/src/error.rs b/common/bandwidth-controller/src/error.rs index f8f9315956..2a650aa4bc 100644 --- a/common/bandwidth-controller/src/error.rs +++ b/common/bandwidth-controller/src/error.rs @@ -49,4 +49,7 @@ pub enum BandwidthControllerError { #[error("Threshold not set yet")] NoThreshold, + + #[error("Ecash key is not set yet")] + NoEcashKey, } diff --git a/common/bandwidth-controller/src/lib.rs b/common/bandwidth-controller/src/lib.rs index c6d703a533..a12219793b 100644 --- a/common/bandwidth-controller/src/lib.rs +++ b/common/bandwidth-controller/src/lib.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::error::BandwidthControllerError; +use nym_compact_ecash::scheme::keygen::KeyPairUser; use nym_compact_ecash::scheme::{EcashCredential, Wallet}; use nym_compact_ecash::setup::setup; use nym_compact_ecash::{Base58, PayInfo, SecretKeyUser}; @@ -18,11 +19,16 @@ pub mod error; pub struct BandwidthController { storage: St, client: C, + ecash_keypair: Option, } impl BandwidthController { - pub fn new(storage: St, client: C) -> Self { - BandwidthController { storage, client } + pub fn new(storage: St, client: C, ecash_keypair: Option) -> Self { + BandwidthController { + storage, + client, + ecash_keypair, + } } pub fn storage(&self) -> &St { @@ -99,6 +105,7 @@ where BandwidthController { storage: self.storage.clone(), client: self.client.clone(), + ecash_keypair: self.ecash_keypair.clone(), } } } diff --git a/common/client-core/src/client/base_client/mod.rs b/common/client-core/src/client/base_client/mod.rs index 07d676a6f3..5e32d10863 100644 --- a/common/client-core/src/client/base_client/mod.rs +++ b/common/client-core/src/client/base_client/mod.rs @@ -50,6 +50,7 @@ use nym_topology::provider_trait::TopologyProvider; use nym_topology::HardcodedTopologyProvider; use nym_validator_client::nyxd::contract_traits::DkgQueryClient; use std::fmt::Debug; +use std::ops::Deref; use std::path::Path; use std::sync::Arc; use url::Url; @@ -612,9 +613,13 @@ where // the components are started in very specific order. Unless you know what you are doing, // do not change that. - let bandwidth_controller = self - .dkg_query_client - .map(|client| BandwidthController::new(credential_store, client)); + let bandwidth_controller = self.dkg_query_client.map(|client| { + BandwidthController::new( + credential_store, + client, + Some(init_res.managed_keys.ecash_keypair().deref().clone()), + ) + }); let topology_provider = Self::setup_topology_provider( self.custom_topology_provider.take(), diff --git a/common/client-core/src/client/base_client/non_wasm_helpers.rs b/common/client-core/src/client/base_client/non_wasm_helpers.rs index d0d2d5a058..afcc4fcfeb 100644 --- a/common/client-core/src/client/base_client/non_wasm_helpers.rs +++ b/common/client-core/src/client/base_client/non_wasm_helpers.rs @@ -119,7 +119,7 @@ pub fn create_bandwidth_controller_with_urls( ) -> BandwidthController { let client = default_query_dkg_client(nyxd_url); - BandwidthController::new(storage, client) + BandwidthController::new(storage, client, None) } pub fn default_query_dkg_client_from_config(config: &Config) -> QueryHttpRpcNyxdClient { diff --git a/nym-api/src/network_monitor/mod.rs b/nym-api/src/network_monitor/mod.rs index 29298be436..4de83fcfb8 100644 --- a/nym-api/src/network_monitor/mod.rs +++ b/nym-api/src/network_monitor/mod.rs @@ -98,6 +98,7 @@ impl<'a> NetworkMonitorBuilder<'a> { ) .await, self.nyxd_client.clone(), + None, ) };