Skip to content

Commit

Permalink
Merge #746: gui: Bump managed bitcoind version for new installations …
Browse files Browse the repository at this point in the history
…to 25.1

fbec5e9 gui: bump managed bitcoind version to 25.1 (jp1ac4)
1808f8f gui: allow to bump managed bitcoind version (jp1ac4)

Pull request description:

  This PR bumps the managed bitcoind version for new Liana installations to 25.1.

  The GUI will look for the most recent managed bitcoind version available when starting bitcoind.

  Once a new managed bitcoind version is installed, all wallets using managed bitcoind will use this new version, even if a wallet on a particular network was installed with a previous bitcoind version.

  The approach taken here may change as part of #690.

ACKs for top commit:
  darosior:
    ACK fbec5e9 -- neat PR.

Tree-SHA512: e6067e00e6c55bc112b0d9b873788de7edd2d3157e58ea1bbcbf512d2f2d621629d32c36010e7602e08e2a17f053a8f5690caecab7f86119b6a7b381f7b11df1
  • Loading branch information
darosior committed Oct 27, 2023
2 parents 1a59d03 + fbec5e9 commit d967dc1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
36 changes: 29 additions & 7 deletions gui/src/bitcoind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -114,6 +118,7 @@ pub enum StartInternalBitcoindError {
CouldNotCanonicalizeCookiePath(String),
CookieFileNotFound(String),
BitcoinDError(String),
ExecutableNotFound,
}

impl std::fmt::Display for StartInternalBitcoindError {
Expand All @@ -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."),
}
}
}
Expand All @@ -157,7 +163,23 @@ impl Bitcoind {
liana_datadir: &PathBuf,
) -> Result<Self, StartInternalBitcoindError> {
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()))?
Expand Down
10 changes: 7 additions & 3 deletions gui/src/installer/step/bitcoind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));
};
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit d967dc1

Please sign in to comment.