mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-02-02 10:35:22 -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())
|
let seed = Seed::from_file_or_generate(data_dir.as_path())
|
||||||
.context("Failed to read in seed file")?;
|
.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)
|
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 = monero::WalletRpc::new(data_dir.join("monero")).await?;
|
||||||
|
|
||||||
let monero_wallet_rpc_process = monero_wallet_rpc
|
let monero_wallet_rpc_process = monero_wallet_rpc
|
||||||
.run(network, monero_daemon_address.as_str())
|
.run(network.into(), monero_daemon_address.as_str())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let monero_wallet = monero::Wallet::open_or_create(
|
let monero_wallet = monero::Wallet::open_or_create(
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::bitcoin::{CancelTimelock, PunishTimelock};
|
use crate::bitcoin::{CancelTimelock, PunishTimelock};
|
||||||
|
use crate::monero;
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use time::NumericalStdDurationShort;
|
use time::NumericalStdDurationShort;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
pub mod wallet;
|
pub mod wallet;
|
||||||
mod wallet_rpc;
|
mod wallet_rpc;
|
||||||
|
|
||||||
pub use ::monero::{Address, Network, PrivateKey, PublicKey};
|
pub use ::monero::{Address, PrivateKey, PublicKey};
|
||||||
pub use curve25519_dalek::scalar::Scalar;
|
pub use curve25519_dalek::scalar::Scalar;
|
||||||
pub use wallet::Wallet;
|
pub use wallet::Wallet;
|
||||||
pub use wallet_rpc::{WalletRpc, WalletRpcProcess};
|
pub use wallet_rpc::{WalletRpc, WalletRpcProcess};
|
||||||
@ -19,6 +19,33 @@ use std::str::FromStr;
|
|||||||
|
|
||||||
pub const PICONERO_OFFSET: u64 = 1_000_000_000_000;
|
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 {
|
pub fn private_key_from_secp256k1_scalar(scalar: bitcoin::Scalar) -> PrivateKey {
|
||||||
let mut bytes = scalar.to_bytes();
|
let mut bytes = scalar.to_bytes();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ impl Wallet {
|
|||||||
monero::Address::from_str(client.get_address(0).await?.address.as_str())?;
|
monero::Address::from_str(client.get_address(0).await?.address.as_str())?;
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
inner: Mutex::new(client),
|
inner: Mutex::new(client),
|
||||||
network: env_config.monero_network,
|
network: env_config.monero_network.into(),
|
||||||
name,
|
name,
|
||||||
main_address,
|
main_address,
|
||||||
sync_interval: env_config.monero_sync_interval(),
|
sync_interval: env_config.monero_sync_interval(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user