Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 65 additions & 66 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ qrcode = "0.14.1"
nix = { version = "0.31.1", features = ["signal"] }
eframe = { version = "0.33.3", features = ["persistence", "wgpu"] }
base64 = "0.22.1"
dash-sdk = { git = "https://github.com/dashpay/platform", rev = "aa86b74f7e28dd0444fec9ceb13373bd22f768d9", features = [
dash-sdk = { git = "https://github.com/dashpay/platform", rev = "3286fcfc34dd75683054067d589730c2f088acf2", features = [
"core_key_wallet",
"core_key_wallet_manager",
"core_bincode",
Expand Down
16 changes: 8 additions & 8 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl AppState {
let connection_status = Arc::new(ConnectionStatus::new());
let mainnet_app_context = AppContext::new(
data_dir.clone(),
Network::Dash,
Network::Mainnet,
db.clone(),
password_info.clone(),
subtasks.clone(),
Expand Down Expand Up @@ -311,7 +311,7 @@ impl AppState {
testnet_app_context.as_ref(),
devnet_app_context.as_ref(),
local_app_context.as_ref(),
Network::Dash,
Network::Mainnet,
overwrite_dash_conf,
);

Expand All @@ -323,7 +323,7 @@ impl AppState {
// Validate that the saved network has an available context.
// We fail fast instead of silently routing user actions to a different network.
let chosen_network = match settings.network {
Network::Dash => Network::Dash,
Network::Mainnet => Network::Mainnet,
Network::Testnet => {
assert!(
testnet_app_context.is_some(),
Expand Down Expand Up @@ -484,7 +484,7 @@ impl AppState {
.unwrap_or(false);
let mainnet_core_zmq_listener = if !mainnet_disable_zmq {
match CoreZMQListener::spawn_listener(
Network::Dash,
Network::Mainnet,
&mainnet_core_zmq_endpoint,
core_message_sender.clone(),
Some(mainnet_app_context.sx_zmq_status.clone()),
Expand Down Expand Up @@ -787,7 +787,7 @@ impl AppState {
// Invariant: chosen_network must always have a corresponding context.
// Fail fast on violations to avoid silently routing operations to mainnet.
match self.chosen_network {
Network::Dash => &self.mainnet_app_context,
Network::Mainnet => &self.mainnet_app_context,
Network::Testnet => self.testnet_app_context.as_ref().unwrap_or_else(|| {
panic!(
"BUG: chosen network is Testnet but testnet_app_context is missing; refusing silent mainnet fallback"
Expand All @@ -812,7 +812,7 @@ impl AppState {

fn context_available_for_network(&self, network: Network) -> bool {
match network {
Network::Dash => true, // Mainnet is always available
Network::Mainnet => true, // Mainnet is always available
Network::Testnet => self.testnet_app_context.is_some(),
Network::Devnet => self.devnet_app_context.is_some(),
Network::Regtest => self.local_app_context.is_some(),
Expand Down Expand Up @@ -1003,7 +1003,7 @@ impl AppState {
// task::spawn_blocking(move || {
// while let Ok((tx, islock, network)) = instant_send_receiver.recv() {
// let app_context = match network {
// Network::Dash => &mainnet_app_context,
// Network::Mainnet => &mainnet_app_context,
// Network::Testnet => {
// if let Some(context) = testnet_app_context.as_ref() {
// context
Expand Down Expand Up @@ -1198,7 +1198,7 @@ impl App for AppState {
// **Poll the instant_send_receiver for any new InstantSend messages**
while let Ok((message, network)) = self.core_message_receiver.try_recv() {
let app_context = match network {
Network::Dash => &self.mainnet_app_context,
Network::Mainnet => &self.mainnet_app_context,
Network::Testnet => {
if let Some(context) = self.testnet_app_context.as_ref() {
context
Expand Down
4 changes: 2 additions & 2 deletions src/app_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn core_cookie_path(
) -> Result<PathBuf, std::io::Error> {
core_user_data_dir_path().and_then(|path| {
let network_dir = match network {
Network::Dash => "",
Network::Mainnet => "",
Network::Testnet => "testnet3",
Network::Devnet => devnet_name.as_deref().unwrap_or(""),
Network::Regtest => "regtest",
Expand Down Expand Up @@ -135,7 +135,7 @@ pub fn create_dash_core_config_if_not_exists(
network: Network,
) -> Result<PathBuf, io::Error> {
let (resource, filename) = match network {
Network::Dash => (BundledResource::CoreConfigMainnet, "mainnet.conf"),
Network::Mainnet => (BundledResource::CoreConfigMainnet, "mainnet.conf"),
Network::Testnet => (BundledResource::CoreConfigTestnet, "testnet.conf"),
Network::Devnet => (BundledResource::CoreConfigDevnet, "devnet.conf"),
Network::Regtest => {
Expand Down
7 changes: 4 additions & 3 deletions src/backend_task/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const DEFAULT_BIP44_ACCOUNT_INDEX: u32 = 0;
fn networks_address_compatible(a: &Network, b: &Network) -> bool {
matches!(
(a, b),
(Network::Dash, Network::Dash)
(Network::Mainnet, Network::Mainnet)
| (
Network::Testnet | Network::Devnet | Network::Regtest,
Network::Testnet | Network::Devnet | Network::Regtest,
Expand Down Expand Up @@ -182,12 +182,13 @@ impl AppContext {
// Load configs
let config = Config::load_from(&self.data_dir)?;

let maybe_mainnet_config = config.config_for_network(Network::Dash);
let maybe_mainnet_config = config.config_for_network(Network::Mainnet);
let maybe_testnet_config = config.config_for_network(Network::Testnet);
let maybe_devnet_config = config.config_for_network(Network::Devnet);
let maybe_local_config = config.config_for_network(Network::Regtest);

let mainnet_result = Self::get_best_chain_lock(maybe_mainnet_config, Network::Dash);
let mainnet_result =
Self::get_best_chain_lock(maybe_mainnet_config, Network::Mainnet);
let testnet_result =
Self::get_best_chain_lock(maybe_testnet_config, Network::Testnet);
let devnet_result = Self::get_best_chain_lock(maybe_devnet_config, Network::Devnet);
Expand Down
13 changes: 9 additions & 4 deletions src/backend_task/dashpay/hd_derivation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,17 @@ mod tests {
&recipient_id,
)
.expect("Should derive xpub for testnet");
let xpub_mainnet =
derive_dashpay_incoming_xpub(&master_seed, Network::Dash, 0, &sender_id, &recipient_id)
.expect("Should derive xpub for mainnet");
let xpub_mainnet = derive_dashpay_incoming_xpub(
&master_seed,
Network::Mainnet,
0,
&sender_id,
&recipient_id,
)
.expect("Should derive xpub for mainnet");

// Keys should be the same but network should differ
assert_eq!(xpub_testnet.network, Network::Testnet);
assert_eq!(xpub_mainnet.network, Network::Dash);
assert_eq!(xpub_mainnet.network, Network::Mainnet);
}
}
2 changes: 1 addition & 1 deletion src/backend_task/mnlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub async fn run_mnlist_task(
} => {
let client = app.core_client.read()?;
let loaded_list_height = match app.network {
Network::Dash => 2_227_096,
Network::Mainnet => 2_227_096,
Network::Testnet => 1_296_600,
_ => 0,
};
Expand Down
2 changes: 1 addition & 1 deletion src/backend_task/platform_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn format_extended_epoch_info(
};

let epoch_estimated_time = match network {
Network::Dash => 788_400_000,
Network::Mainnet => 788_400_000,
Network::Testnet => 3_600_000,
Network::Devnet => 3_600_000,
Network::Regtest => 1_200_000,
Expand Down
4 changes: 2 additions & 2 deletions src/components/core_p2p_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ enum ReadMessageError {
impl CoreP2PHandler {
pub fn new(network: Network, use_port: Option<u16>) -> Result<CoreP2PHandler, P2PError> {
let port = use_port.unwrap_or(match network {
Network::Dash => 9999,
Network::Mainnet => 9999,
Network::Testnet => 19999,
Network::Devnet => 29999,
Network::Regtest => 29999,
Expand Down Expand Up @@ -190,7 +190,7 @@ impl CoreP2PHandler {
// QRInfo on mainnet can take noticeably longer to prepare.
// Temporarily increase socket read timeout and our overall wait.
let (socket_timeout, overall_timeout) = match self.network {
Network::Dash => (Duration::from_secs(60), Duration::from_secs(60)),
Network::Mainnet => (Duration::from_secs(60), Duration::from_secs(60)),
_ => (Duration::from_secs(15), Duration::from_secs(15)),
};
let previous_socket_timeout = self.stream.read_timeout()?;
Expand Down
15 changes: 9 additions & 6 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct NetworkConfig {
impl Config {
pub fn config_for_network(&self, network: Network) -> &Option<NetworkConfig> {
match network {
Network::Dash => &self.mainnet_config,
Network::Mainnet => &self.mainnet_config,
Network::Testnet => &self.testnet_config,
Network::Devnet => &self.devnet_config,
Network::Regtest => &self.local_config,
Expand Down Expand Up @@ -306,7 +306,7 @@ impl Config {
/// Update (overwrite) the configuration for a particular network.
pub fn update_config_for_network(&mut self, network: Network, new_config: NetworkConfig) {
match network {
Network::Dash => self.mainnet_config = Some(new_config),
Network::Mainnet => self.mainnet_config = Some(new_config),
Network::Testnet => self.testnet_config = Some(new_config),
Network::Devnet => self.devnet_config = Some(new_config),
Network::Regtest => self.local_config = Some(new_config),
Expand Down Expand Up @@ -456,7 +456,7 @@ mod tests {
local_config: None,
developer_mode: None,
};
assert!(config.config_for_network(Network::Dash).is_some());
assert!(config.config_for_network(Network::Mainnet).is_some());
assert!(config.config_for_network(Network::Testnet).is_none());
assert!(config.config_for_network(Network::Devnet).is_none());
assert!(config.config_for_network(Network::Regtest).is_none());
Expand All @@ -471,7 +471,10 @@ mod tests {
local_config: Some(make_network_config("http://127.0.0.1:2443", 20302)),
developer_mode: Some(true),
};
let main = config.config_for_network(Network::Dash).as_ref().unwrap();
let main = config
.config_for_network(Network::Mainnet)
.as_ref()
.unwrap();
assert_eq!(main.core_rpc_port, 9998);
let test = config
.config_for_network(Network::Testnet)
Expand Down Expand Up @@ -500,7 +503,7 @@ mod tests {
};
assert!(config.mainnet_config.is_none());
let new_cfg = make_network_config("https://1.1.1.1:443", 9998);
config.update_config_for_network(Network::Dash, new_cfg);
config.update_config_for_network(Network::Mainnet, new_cfg);
assert!(config.mainnet_config.is_some());
assert_eq!(config.mainnet_config.as_ref().unwrap().core_rpc_port, 9998);
}
Expand All @@ -515,7 +518,7 @@ mod tests {
developer_mode: None,
};
let new_cfg = make_network_config("https://new.example.com:443", 2222);
config.update_config_for_network(Network::Dash, new_cfg);
config.update_config_for_network(Network::Mainnet, new_cfg);
let main = config.mainnet_config.as_ref().unwrap();
assert_eq!(main.core_rpc_port, 2222);
assert_eq!(main.dapi_addresses, "https://new.example.com:443");
Expand Down
2 changes: 1 addition & 1 deletion src/context/connection_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl ConnectionStatus {
local_chainlock: &Option<ChainLock>,
) {
let online = match network {
Network::Dash => mainnet_chainlock.is_some(),
Network::Mainnet => mainnet_chainlock.is_some(),
Network::Testnet => testnet_chainlock.is_some(),
Network::Devnet => devnet_chainlock.is_some(),
Network::Regtest => local_chainlock.is_some(),
Expand Down
2 changes: 1 addition & 1 deletion src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ impl AppContext {
pub(crate) const fn default_platform_version(network: &Network) -> &'static PlatformVersion {
// TODO: Ideally use sdk.load().version() but this is a free function with no sdk access
match network {
Network::Dash => &PLATFORM_V11,
Network::Mainnet => &PLATFORM_V11,
Network::Testnet => &PLATFORM_V11,
Network::Devnet => &PLATFORM_V11,
Network::Regtest => &PLATFORM_V11,
Expand Down
4 changes: 2 additions & 2 deletions src/context/wallet_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ impl AppContext {

pub(crate) fn wallet_network_key(&self) -> WalletNetwork {
match self.network {
Network::Dash => WalletNetwork::Dash,
Network::Mainnet => WalletNetwork::Mainnet,
Network::Testnet => WalletNetwork::Testnet,
Network::Devnet => WalletNetwork::Devnet,
Network::Regtest => WalletNetwork::Regtest,
_ => WalletNetwork::Dash,
_ => WalletNetwork::Mainnet,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/database/contested_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use tracing::{error, info};
impl Database {
pub fn get_all_contested_names(&self, app_context: &AppContext) -> Result<Vec<ContestedName>> {
let network = app_context.network.to_string();
let contest_duration = if app_context.network == Network::Dash {
let contest_duration = if app_context.network == Network::Mainnet {
Duration::from_secs(60 * 60 * 24 * 14)
} else {
Duration::from_secs(60 * 90)
Expand Down Expand Up @@ -183,7 +183,7 @@ impl Database {
app_context: &AppContext,
) -> Result<Vec<ContestedName>> {
let network = app_context.network.to_string();
let contest_duration = if app_context.network == Network::Dash {
let contest_duration = if app_context.network == Network::Mainnet {
Duration::from_secs(60 * 60 * 24 * 14)
} else {
Duration::from_secs(60 * 90)
Expand Down
2 changes: 1 addition & 1 deletion src/database/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ mod tests {
let (network, root_screen, password_info, _, _, _, theme, core_mode, _, _, _, _) =
settings.unwrap();
// Default network is "dash" (mainnet)
assert_eq!(network, Network::Dash);
assert_eq!(network, Network::Mainnet);
Comment on lines 649 to +650

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Update the stale inline comment to match the renamed enum.

Line 649 still says "dash" while Line 650 asserts Network::Mainnet. Please align the comment text to avoid confusion.

Suggested patch
-        // Default network is "dash" (mainnet)
+        // Default network is Mainnet
         assert_eq!(network, Network::Mainnet);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Default network is "dash" (mainnet)
assert_eq!(network, Network::Dash);
assert_eq!(network, Network::Mainnet);
// Default network is Mainnet
assert_eq!(network, Network::Mainnet);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/database/settings.rs` around lines 649 - 650, The inline comment above
the assertion for network is stale ("dash") and should reflect the renamed enum;
update the comment near the assertion that checks network and Network::Mainnet
so it reads that the default network is "mainnet" (or otherwise matches
Network::Mainnet) to avoid confusion—look for the comment immediately preceding
the assert_eq!(network, Network::Mainnet) and change its text accordingly.

// Default start screen is RootScreenDashPayProfile (20)
assert_eq!(root_screen, RootScreenType::RootScreenDashPayProfile);
// No password set initially
Expand Down
4 changes: 2 additions & 2 deletions src/database/utxo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ mod tests {
fn test_utxo_network_filtering() {
let db = create_test_database().expect("Failed to create test database");
let testnet_address = create_test_address(Network::Testnet);
let mainnet_address = create_test_address(Network::Dash);
let mainnet_address = create_test_address(Network::Mainnet);
let txid = create_test_txid();

// Insert UTXO for testnet
Expand All @@ -240,7 +240,7 @@ mod tests {
&mainnet_address,
200_000_000,
mainnet_address.script_pubkey().as_bytes(),
Network::Dash,
Network::Mainnet,
)
.expect("Failed to insert mainnet UTXO");

Expand Down
2 changes: 1 addition & 1 deletion src/model/qualified_identity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl<C> Decode<C> for QualifiedIdentity {
wallet_index: None,
top_ups: Default::default(),
status: IdentityStatus::Unknown, // Loaded from the database, not encoded
network: Network::Dash, // Loaded from the database, not encoded
network: Network::Mainnet, // Loaded from the database, not encoded
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/model/qualified_identity/qualified_identity_public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl QualifiedIdentityPublicKey {

let address = Address::new(network, Payload::PubkeyHash(pubkey_hash));

let testnet_address = if network != Network::Dash {
let testnet_address = if network != Network::Mainnet {
Some(Address::new(
Network::Testnet,
Payload::PubkeyHash(pubkey_hash),
Expand Down Expand Up @@ -100,7 +100,7 @@ impl QualifiedIdentityPublicKey {

let address = Address::p2pkh(&pubkey, network);

let testnet_address = if network != Network::Dash {
let testnet_address = if network != Network::Mainnet {
Some(Address::p2pkh(&pubkey, Network::Testnet))
} else {
None
Expand Down Expand Up @@ -147,7 +147,7 @@ impl QualifiedIdentityPublicKey {

let address = Address::new(network, Payload::PubkeyHash(pubkey_hash));

let testnet_address = if network != Network::Dash {
let testnet_address = if network != Network::Mainnet {
Some(Address::new(
Network::Testnet,
Payload::PubkeyHash(pubkey_hash),
Expand Down
2 changes: 1 addition & 1 deletion src/model/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Default for Settings {
/// Default settings for the application
fn default() -> Self {
Self::new(
Network::Dash,
Network::Mainnet,
RootScreenType::RootScreenDashpay,
None,
None, // autodetect
Expand Down
Loading
Loading