From 2bc87b1968230301ec59b86d80f0bae521caba1f Mon Sep 17 00:00:00 2001 From: pshenmic Date: Sun, 20 Oct 2024 23:10:59 +0700 Subject: [PATCH] Allow mainnet as a network type --- src/commands/masternode_vote_dpns_name.rs | 3 ++- src/commands/register_dpns_name.rs | 3 ++- src/commands/withdraw.rs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/commands/masternode_vote_dpns_name.rs b/src/commands/masternode_vote_dpns_name.rs index 2670fd3..5acaa2b 100644 --- a/src/commands/masternode_vote_dpns_name.rs +++ b/src/commands/masternode_vote_dpns_name.rs @@ -84,7 +84,8 @@ impl MasternodeVoteDPNSNameCommand { let secp = Secp256k1::new(); - let network_type = Network::from_str(&self.network).expect("Could not parse network"); + let network = if &self.network == "mainnet" { "dash" } else { &self.network }; + let network_type = Network::from_str(network).expect("Could not parse network"); let private_key_data = fs::read_to_string(&self.private_key).expect("Unable to read private key file"); let private_key = Utils::decode_private_key_from_input_string(private_key_data.as_str(), network_type)?; let public_key = private_key.public_key(&secp); diff --git a/src/commands/register_dpns_name.rs b/src/commands/register_dpns_name.rs index 72e0419..ff05771 100644 --- a/src/commands/register_dpns_name.rs +++ b/src/commands/register_dpns_name.rs @@ -101,7 +101,8 @@ impl RegisterDPNSNameCommand { let secp = Secp256k1::new(); - let network_type = Network::from_str(&self.network).expect("Could not parse network"); + let network = if &self.network == "mainnet" { "dash" } else { &self.network }; + let network_type = Network::from_str(network).expect("Could not parse network"); let private_key_data = fs::read_to_string(&self.private_key).expect("Unable to read private key file"); let private_key = Utils::decode_private_key_from_input_string(private_key_data.as_str(), network_type)?; let public_key = private_key.public_key(&secp); diff --git a/src/commands/withdraw.rs b/src/commands/withdraw.rs index a5f8264..42e4419 100644 --- a/src/commands/withdraw.rs +++ b/src/commands/withdraw.rs @@ -87,7 +87,8 @@ impl WithdrawCommand { let secp = Secp256k1::new(); - let network_type = Network::from_str(&self.network).expect("Could not parse network"); + let network = if &self.network == "mainnet" { "dash" } else { &self.network }; + let network_type = Network::from_str(network).expect("Could not parse network"); let private_key_data = fs::read_to_string(&self.private_key).expect("Unable to read private key file"); let private_key = Utils::decode_private_key_from_input_string(private_key_data.as_str(), network_type)?; let public_key = private_key.public_key(&secp);