From 8b7a0cca1f039924475ab3ddcd3debe39c26b867 Mon Sep 17 00:00:00 2001 From: einliterflasche Date: Wed, 3 Jun 2026 14:57:21 +0200 Subject: [PATCH 1/2] fix(build): enable nixpkg only on x86 linux --- .envrc | 6 +++++- nix/README.md | 3 ++- shell.nix | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.envrc b/.envrc index 1d953f4bd7..badc8aacf9 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,5 @@ -use nix +if [ "$(uname -s)" = "Linux" ] && [ "$(uname -m)" = "x86_64" ]; then + use nix +else + echo "direnv: skipping Nix shell; supported only on x86_64 Linux." >&2 +fi diff --git a/nix/README.md b/nix/README.md index 42df01fef0..a4df1852e2 100644 --- a/nix/README.md +++ b/nix/README.md @@ -8,7 +8,8 @@ kept comment-free. ## Usage - `nix-shell` — impure shell; auto-detects the host NVIDIA driver for GPU rendering. -- `direnv` — `.envrc` runs `use nix`, so the shell loads automatically on `cd`. +- `direnv` — `.envrc` runs `use nix` on x86_64 Linux, so the shell loads + automatically on `cd`. On other systems it intentionally does nothing. - `nix develop` — pure flake shell; uses mesa software rendering (pure eval can't read `/proc`). For GPU acceleration use `nix-shell`, or `nix develop --impure` with an explicit `nvidiaVersion` (e.g. `"580.159.03"`). diff --git a/shell.nix b/shell.nix index 39265cc19c..2a8cb5ed19 100644 --- a/shell.nix +++ b/shell.nix @@ -19,6 +19,10 @@ in if m == null then null else builtins.elemAt m 1 }: +let + supportedSystem = pkgs.stdenv.hostPlatform.system == "x86_64-linux"; +in +if supportedSystem then let prefixWrapper = from: tool: pkgs.writeShellScriptBin "x86_64-linux-gnu-${tool}" ''exec ${from}/bin/${tool} "$@"''; @@ -134,3 +138,9 @@ pkgs.mkShell { export XDG_DATA_DIRS="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS" ''; } +else +pkgs.mkShell { + shellHook = '' + echo "Skipping eigenwallet Nix dev shell; supported only on x86_64 Linux." + ''; +} From 40a231c6f73159321eeff5016ee602efa7f39729 Mon Sep 17 00:00:00 2001 From: einliterflasche Date: Wed, 3 Jun 2026 14:58:03 +0200 Subject: [PATCH 2/2] fix(cli): legacy key derivation --- swap/src/cli/api.rs | 80 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/swap/src/cli/api.rs b/swap/src/cli/api.rs index 1570b0f056..705c1774e1 100644 --- a/swap/src/cli/api.rs +++ b/swap/src/cli/api.rs @@ -893,6 +893,10 @@ pub use builder::ContextBuilder; mod wallet { use super::*; + // Legacy mode uses this Monero monitoring wallet and the seed.pem-derived + // Bitcoin wallet in the same CLI data directory. + const LEGACY_MONITORING_WALLET_NAME: &str = "swap-tool-blockchain-monitoring-wallet"; + pub(super) async fn init_bitcoin_wallet( electrum_rpc_urls: Vec, seed: &Seed, @@ -925,12 +929,20 @@ mod wallet { Ok(wallet) } + fn legacy_wallet_path(data_dir: &Path) -> PathBuf { + data_dir.join(LEGACY_MONITORING_WALLET_NAME) + } + + fn is_legacy_wallet_path(wallet_path: &str, legacy_data_dir: &Path) -> bool { + Path::new(wallet_path) == legacy_wallet_path(legacy_data_dir) + } + pub(super) async fn request_and_open_monero_wallet_legacy( data_dir: &PathBuf, env_config: EnvConfig, daemon: &monero_sys::Daemon, ) -> Result { - let wallet_path = data_dir.join("swap-tool-blockchain-monitoring-wallet"); + let wallet_path = legacy_wallet_path(data_dir); let wallet = monero::Wallet::open_or_create( wallet_path.display().to_string(), @@ -1056,6 +1068,20 @@ mod wallet { SeedChoice::FromWalletPath { ref wallet_path } => { let wallet_path = wallet_path.clone(); + if is_legacy_wallet_path(&wallet_path, legacy_data_dir) { + let wallet = request_and_open_monero_wallet_legacy( + legacy_data_dir, + env_config, + daemon, + ) + .await?; + let seed = Seed::from_file_or_generate(legacy_data_dir) + .await + .context("Failed to read legacy seed from file")?; + + break (wallet, seed); + } + // Helper function to verify password let verify_password = |password: String| -> Result { monero_sys::WalletHandle::verify_wallet_password( @@ -1148,7 +1174,7 @@ mod wallet { .await?; let seed = Seed::from_file_or_generate(legacy_data_dir) .await - .context("Failed to extract seed from wallet")?; + .context("Failed to read legacy seed from file")?; break (wallet, seed); } @@ -1175,7 +1201,7 @@ mod wallet { .await?; let seed = Seed::from_file_or_generate(legacy_data_dir) .await - .context("Failed to extract seed from wallet")?; + .context("Failed to read legacy seed from file")?; (wallet, seed) } @@ -1183,6 +1209,54 @@ mod wallet { Ok(wallet) } + + #[cfg(test)] + mod tests { + use super::*; + use bitcoin_wallet::BitcoinWalletSeed; + + #[test] + fn detects_legacy_monitoring_wallet_path() { + let legacy_data_dir = PathBuf::from("/tmp/eigenwallet-mainnet"); + let wallet_path = legacy_wallet_path(&legacy_data_dir); + + assert!(is_legacy_wallet_path( + wallet_path.to_str().unwrap(), + &legacy_data_dir, + )); + } + + #[test] + fn does_not_treat_other_wallet_files_as_legacy() { + let legacy_data_dir = PathBuf::from("/tmp/eigenwallet-mainnet"); + let wallet_path = "/tmp/eigenwallet/wallets/wallet_123"; + + assert!(!is_legacy_wallet_path(wallet_path, &legacy_data_dir)); + } + + #[tokio::test] + async fn legacy_seed_file_keeps_bitcoin_key_stable() { + let temp_dir = tempfile::tempdir().unwrap(); + + let legacy_seed = Seed::from_file_or_generate(temp_dir.path()).await.unwrap(); + let legacy_key = legacy_seed + .derive_extended_private_key(bitcoin::Network::Bitcoin) + .unwrap(); + + let reread_legacy_seed = Seed::from_file_or_generate(temp_dir.path()).await.unwrap(); + let reread_legacy_key = reread_legacy_seed + .derive_extended_private_key(bitcoin::Network::Bitcoin) + .unwrap(); + + let non_legacy_seed = Seed::from([0; crate::seed::SEED_LENGTH]); + let non_legacy_key = non_legacy_seed + .derive_extended_private_key(bitcoin::Network::Bitcoin) + .unwrap(); + + assert_eq!(legacy_key, reread_legacy_key); + assert_ne!(legacy_key, non_legacy_key); + } + } } pub mod data {