diff --git a/gui/src/bitcoind.rs b/gui/src/bitcoind.rs index 0c4fffb10..2e1c9c8c8 100644 --- a/gui/src/bitcoind.rs +++ b/gui/src/bitcoind.rs @@ -16,16 +16,20 @@ use std::os::windows::process::CommandExt; #[cfg(target_os = "windows")] const CREATE_NO_WINDOW: u32 = 0x08000000; -pub const VERSION: &str = "25.0"; +/// Current and previous managed bitcoind versions, in order of descending version. +pub const VERSIONS: [&str; 2] = ["25.1", "25.0"]; + +/// Current managed bitcoind version for new installations. +pub const VERSION: &str = VERSIONS[0]; #[cfg(all(target_os = "macos", target_arch = "x86_64"))] -pub const SHA256SUM: &str = "5708fc639cdfc27347cccfd50db9b73b53647b36fb5f3a4a93537cbe8828c27f"; +pub const SHA256SUM: &str = "1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"; #[cfg(all(target_os = "linux", target_arch = "x86_64"))] -pub const SHA256SUM: &str = "33930d432593e49d58a9bff4c30078823e9af5d98594d2935862788ce8a20aec"; +pub const SHA256SUM: &str = "a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"; #[cfg(all(target_os = "windows", target_arch = "x86_64"))] -pub const SHA256SUM: &str = "7154b35ecc8247589070ae739b7c73c4dee4794bea49eb18dc66faed65b819e7"; +pub const SHA256SUM: &str = "da722a4573b46b9a66aa53992b1ef296ab1b2b75dbdaa3b4eff65cbed438637a"; #[cfg(all(target_os = "macos", target_arch = "x86_64"))] pub fn download_filename() -> String { @@ -64,9 +68,9 @@ pub fn internal_bitcoind_datadir(liana_datadir: &PathBuf) -> PathBuf { } /// Internal bitcoind executable path. -pub fn internal_bitcoind_exe_path(liana_datadir: &PathBuf) -> PathBuf { +pub fn internal_bitcoind_exe_path(liana_datadir: &PathBuf, bitcoind_version: &str) -> PathBuf { internal_bitcoind_directory(liana_datadir) - .join(format!("bitcoin-{}", &VERSION)) + .join(format!("bitcoin-{}", bitcoind_version)) .join("bin") .join(if cfg!(target_os = "windows") { "bitcoind.exe" @@ -114,6 +118,7 @@ pub enum StartInternalBitcoindError { CouldNotCanonicalizeCookiePath(String), CookieFileNotFound(String), BitcoinDError(String), + ExecutableNotFound, } impl std::fmt::Display for StartInternalBitcoindError { @@ -139,6 +144,7 @@ impl std::fmt::Display for StartInternalBitcoindError { ) } Self::BitcoinDError(e) => write!(f, "bitcoind connection check failed: {}", e), + Self::ExecutableNotFound => write!(f, "bitcoind executable not found."), } } } @@ -157,7 +163,23 @@ impl Bitcoind { liana_datadir: &PathBuf, ) -> Result { let bitcoind_datadir = internal_bitcoind_datadir(liana_datadir); - let bitcoind_exe_path = internal_bitcoind_exe_path(liana_datadir); + // Find most recent bitcoind version available. + let bitcoind_exe_path = VERSIONS + .iter() + .filter_map(|v| { + let path = internal_bitcoind_exe_path(liana_datadir, v); + if path.exists() { + Some(path) + } else { + None + } + }) + .next() + .ok_or(StartInternalBitcoindError::ExecutableNotFound)?; + info!( + "Found bitcoind executable at '{}'.", + bitcoind_exe_path.to_string_lossy() + ); let datadir_path_str = bitcoind_datadir .canonicalize() .map_err(|e| StartInternalBitcoindError::CouldNotCanonicalizeDataDir(e.to_string()))? diff --git a/gui/src/installer/step/bitcoind.rs b/gui/src/installer/step/bitcoind.rs index 2c48abcbe..655212a24 100644 --- a/gui/src/installer/step/bitcoind.rs +++ b/gui/src/installer/step/bitcoind.rs @@ -21,7 +21,7 @@ use liana_ui::{component::form, widget::*}; use crate::{ bitcoind::{ self, bitcoind_network_dir, internal_bitcoind_datadir, internal_bitcoind_directory, - Bitcoind, StartInternalBitcoindError, + Bitcoind, StartInternalBitcoindError, VERSION, }, download, hw::HardwareWallets, @@ -633,8 +633,11 @@ impl InternalBitcoindStep { impl Step for InternalBitcoindStep { fn load_context(&mut self, ctx: &Context) { if self.exe_path.is_none() { - if bitcoind::internal_bitcoind_exe_path(&ctx.data_dir).exists() { - self.exe_path = Some(bitcoind::internal_bitcoind_exe_path(&ctx.data_dir)) + // Check if current managed bitcoind version is already installed. + // For new installations, we ignore any previous managed bitcoind versions that might be installed. + let exe_path = bitcoind::internal_bitcoind_exe_path(&ctx.data_dir, VERSION); + if exe_path.exists() { + self.exe_path = Some(exe_path) } else if self.exe_download.is_none() { self.exe_download = Some(Download::new(0)); }; @@ -749,6 +752,7 @@ impl Step for InternalBitcoindStep { self.install_state = Some(InstallState::Finished); self.exe_path = Some(bitcoind::internal_bitcoind_exe_path( &self.liana_datadir, + VERSION, )); return Command::perform(async {}, |_| { Message::InternalBitcoind(