Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Correctly check for available nodes, remove dead nodes #251

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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
8 changes: 3 additions & 5 deletions swap/src/cli/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,6 @@ impl ContextBuilder {
let initialize_monero_wallet = async {
match self.monero {
Some(monero) => {
let monero_daemon_address = monero.apply_defaults(self.is_testnet);

self.tauri_handle.emit_context_init_progress_event(
TauriContextStatusEvent::Initializing(vec![
TauriPartialInitProgress::OpeningMoneroWallet(
Expand All @@ -376,7 +374,7 @@ impl ContextBuilder {

let (wlt, prc) = init_monero_wallet(
data_dir.clone(),
monero_daemon_address,
monero.monero_daemon_address,
env_config,
self.tauri_handle.clone(),
)
Expand Down Expand Up @@ -548,7 +546,7 @@ async fn init_bitcoin_wallet(

async fn init_monero_wallet(
data_dir: PathBuf,
monero_daemon_address: String,
monero_daemon_address: impl Into<Option<String>> + Clone,
env_config: EnvConfig,
tauri_handle: Option<TauriHandle>,
) -> Result<(monero::Wallet, monero::WalletRpcProcess)> {
Expand All @@ -559,7 +557,7 @@ async fn init_monero_wallet(
let monero_wallet_rpc = monero::WalletRpc::new(data_dir.join("monero"), tauri_handle).await?;

tracing::debug!(
address = monero_daemon_address,
override_monero_daemon_address = monero_daemon_address.clone().into(),
"Attempting to start monero-wallet-rpc process"
);

Expand Down
16 changes: 0 additions & 16 deletions swap/src/cli/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ use uuid::Uuid;
use super::api::request::GetLogsArgs;
use super::api::ContextBuilder;

// See: https://moneroworld.com/
pub const DEFAULT_MONERO_DAEMON_ADDRESS: &str = "node.community.rino.io:18081";
pub const DEFAULT_MONERO_DAEMON_ADDRESS_STAGENET: &str = "stagenet.community.rino.io:38081";

// See: https://1209k.com/bitcoin-eye/ele.php?chain=btc
const DEFAULT_ELECTRUM_RPC_URL: &str = "ssl://blockstream.info:700";
// See: https://1209k.com/bitcoin-eye/ele.php?chain=tbtc
Expand Down Expand Up @@ -506,18 +502,6 @@ pub struct Monero {
pub monero_daemon_address: Option<String>,
}

impl Monero {
pub fn apply_defaults(self, testnet: bool) -> String {
if let Some(address) = self.monero_daemon_address {
address
} else if testnet {
DEFAULT_MONERO_DAEMON_ADDRESS_STAGENET.to_string()
} else {
DEFAULT_MONERO_DAEMON_ADDRESS.to_string()
}
}
}

#[derive(structopt::StructOpt, Debug)]
pub struct Bitcoin {
#[structopt(long = "electrum-rpc", help = "Provide the Bitcoin Electrum RPC URL")]
Expand Down
6 changes: 1 addition & 5 deletions swap/src/monero/wallet_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,15 @@ use crate::cli::api::tauri_bindings::{

// See: https://www.moneroworld.com/#nodes, https://monero.fail
// We don't need any testnet nodes because we don't support testnet at all
static MONERO_DAEMONS: Lazy<[MoneroDaemon; 16]> = Lazy::new(|| {
static MONERO_DAEMONS: Lazy<[MoneroDaemon; 12]> = Lazy::new(|| {
[
MoneroDaemon::new("xmr-node.cakewallet.com", 18081, Network::Mainnet),
MoneroDaemon::new("nodex.monerujo.io", 18081, Network::Mainnet),
MoneroDaemon::new("nodes.hashvault.pro", 18081, Network::Mainnet),
MoneroDaemon::new("p2pmd.xmrvsbeast.com", 18081, Network::Mainnet),
MoneroDaemon::new("node.monerodevs.org", 18089, Network::Mainnet),
MoneroDaemon::new("xmr-node-usa-east.cakewallet.com", 18081, Network::Mainnet),
MoneroDaemon::new("xmr-node-uk.cakewallet.com", 18081, Network::Mainnet),
MoneroDaemon::new("node.community.rino.io", 18081, Network::Mainnet),
MoneroDaemon::new("testingjohnross.com", 20031, Network::Mainnet),
MoneroDaemon::new("xmr.litepay.ch", 18081, Network::Mainnet),
MoneroDaemon::new("node.trocador.app", 18089, Network::Mainnet),
MoneroDaemon::new("stagenet.xmr-tw.org", 38081, Network::Stagenet),
MoneroDaemon::new("node.monerodevs.org", 38089, Network::Stagenet),
MoneroDaemon::new("singapore.node.xmr.pm", 38081, Network::Stagenet),
Expand Down
Loading