mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-01-23 05:41:07 -05:00
Introduce own de-/serializable monero::Network
This commit is contained in:
parent
69cf12620d
commit
9ac5b635d7
@ -151,7 +151,7 @@ async fn main() -> Result<()> {
|
||||
let seed = Seed::from_file_or_generate(data_dir.as_path())
|
||||
.context("Failed to read in seed file")?;
|
||||
|
||||
if monero_receive_address.network != env_config.monero_network {
|
||||
if monero_receive_address.network != env_config.monero_network.into() {
|
||||
bail!("The given monero address is on network {:?}, expected address of network {:?}.", monero_receive_address.network, env_config.monero_network)
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ async fn init_monero_wallet(
|
||||
let monero_wallet_rpc = monero::WalletRpc::new(data_dir.join("monero")).await?;
|
||||
|
||||
let monero_wallet_rpc_process = monero_wallet_rpc
|
||||
.run(network, monero_daemon_address.as_str())
|
||||
.run(network.into(), monero_daemon_address.as_str())
|
||||
.await?;
|
||||
|
||||
let monero_wallet = monero::Wallet::open_or_create(
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::bitcoin::{CancelTimelock, PunishTimelock};
|
||||
use crate::monero;
|
||||
use std::cmp::max;
|
||||
use std::time::Duration;
|
||||
use time::NumericalStdDurationShort;
|
||||
|
@ -1,7 +1,7 @@
|
||||
pub mod wallet;
|
||||
mod wallet_rpc;
|
||||
|
||||
pub use ::monero::{Address, Network, PrivateKey, PublicKey};
|
||||
pub use ::monero::{Address, PrivateKey, PublicKey};
|
||||
pub use curve25519_dalek::scalar::Scalar;
|
||||
pub use wallet::Wallet;
|
||||
pub use wallet_rpc::{WalletRpc, WalletRpcProcess};
|
||||
@ -19,6 +19,33 @@ use std::str::FromStr;
|
||||
|
||||
pub const PICONERO_OFFSET: u64 = 1_000_000_000_000;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize)]
|
||||
pub enum Network {
|
||||
Mainnet,
|
||||
Stagenet,
|
||||
Testnet,
|
||||
}
|
||||
|
||||
impl From<monero::Network> for Network {
|
||||
fn from(network: monero::Network) -> Self {
|
||||
match network {
|
||||
monero::Network::Mainnet => Self::Mainnet,
|
||||
monero::Network::Stagenet => Self::Stagenet,
|
||||
monero::Network::Testnet => Self::Testnet,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Network> for monero::Network {
|
||||
fn from(network: Network) -> Self {
|
||||
match network {
|
||||
Network::Mainnet => monero::Network::Mainnet,
|
||||
Network::Stagenet => monero::Network::Stagenet,
|
||||
Network::Testnet => monero::Network::Testnet,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn private_key_from_secp256k1_scalar(scalar: bitcoin::Scalar) -> PrivateKey {
|
||||
let mut bytes = scalar.to_bytes();
|
||||
|
||||
|
@ -47,7 +47,7 @@ impl Wallet {
|
||||
monero::Address::from_str(client.get_address(0).await?.address.as_str())?;
|
||||
Ok(Self {
|
||||
inner: Mutex::new(client),
|
||||
network: env_config.monero_network,
|
||||
network: env_config.monero_network.into(),
|
||||
name,
|
||||
main_address,
|
||||
sync_interval: env_config.monero_sync_interval(),
|
||||
|
Loading…
Reference in New Issue
Block a user