gui: allow to bump managed bitcoind version
This makes it possible to bump the managed bitcoind version used when installing a new Liana wallet. The GUI will look for the most recent managed bitcoind version available when starting bitcoind so that existing wallets with a previous managed bitcoind version will not be affected.
This commit is contained in:
parent
1a59d03858
commit
1808f8f1de
@ -16,7 +16,11 @@ use std::os::windows::process::CommandExt;
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
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; 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"))]
|
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
|
||||||
pub const SHA256SUM: &str = "5708fc639cdfc27347cccfd50db9b73b53647b36fb5f3a4a93537cbe8828c27f";
|
pub const SHA256SUM: &str = "5708fc639cdfc27347cccfd50db9b73b53647b36fb5f3a4a93537cbe8828c27f";
|
||||||
@ -64,9 +68,9 @@ pub fn internal_bitcoind_datadir(liana_datadir: &PathBuf) -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Internal bitcoind executable path.
|
/// 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)
|
internal_bitcoind_directory(liana_datadir)
|
||||||
.join(format!("bitcoin-{}", &VERSION))
|
.join(format!("bitcoin-{}", bitcoind_version))
|
||||||
.join("bin")
|
.join("bin")
|
||||||
.join(if cfg!(target_os = "windows") {
|
.join(if cfg!(target_os = "windows") {
|
||||||
"bitcoind.exe"
|
"bitcoind.exe"
|
||||||
@ -114,6 +118,7 @@ pub enum StartInternalBitcoindError {
|
|||||||
CouldNotCanonicalizeCookiePath(String),
|
CouldNotCanonicalizeCookiePath(String),
|
||||||
CookieFileNotFound(String),
|
CookieFileNotFound(String),
|
||||||
BitcoinDError(String),
|
BitcoinDError(String),
|
||||||
|
ExecutableNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for StartInternalBitcoindError {
|
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::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,
|
liana_datadir: &PathBuf,
|
||||||
) -> Result<Self, StartInternalBitcoindError> {
|
) -> Result<Self, StartInternalBitcoindError> {
|
||||||
let bitcoind_datadir = internal_bitcoind_datadir(liana_datadir);
|
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
|
let datadir_path_str = bitcoind_datadir
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
.map_err(|e| StartInternalBitcoindError::CouldNotCanonicalizeDataDir(e.to_string()))?
|
.map_err(|e| StartInternalBitcoindError::CouldNotCanonicalizeDataDir(e.to_string()))?
|
||||||
|
|||||||
@ -21,7 +21,7 @@ use liana_ui::{component::form, widget::*};
|
|||||||
use crate::{
|
use crate::{
|
||||||
bitcoind::{
|
bitcoind::{
|
||||||
self, bitcoind_network_dir, internal_bitcoind_datadir, internal_bitcoind_directory,
|
self, bitcoind_network_dir, internal_bitcoind_datadir, internal_bitcoind_directory,
|
||||||
Bitcoind, StartInternalBitcoindError,
|
Bitcoind, StartInternalBitcoindError, VERSION,
|
||||||
},
|
},
|
||||||
download,
|
download,
|
||||||
hw::HardwareWallets,
|
hw::HardwareWallets,
|
||||||
@ -633,8 +633,11 @@ impl InternalBitcoindStep {
|
|||||||
impl Step for InternalBitcoindStep {
|
impl Step for InternalBitcoindStep {
|
||||||
fn load_context(&mut self, ctx: &Context) {
|
fn load_context(&mut self, ctx: &Context) {
|
||||||
if self.exe_path.is_none() {
|
if self.exe_path.is_none() {
|
||||||
if bitcoind::internal_bitcoind_exe_path(&ctx.data_dir).exists() {
|
// Check if current managed bitcoind version is already installed.
|
||||||
self.exe_path = Some(bitcoind::internal_bitcoind_exe_path(&ctx.data_dir))
|
// 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() {
|
} else if self.exe_download.is_none() {
|
||||||
self.exe_download = Some(Download::new(0));
|
self.exe_download = Some(Download::new(0));
|
||||||
};
|
};
|
||||||
@ -749,6 +752,7 @@ impl Step for InternalBitcoindStep {
|
|||||||
self.install_state = Some(InstallState::Finished);
|
self.install_state = Some(InstallState::Finished);
|
||||||
self.exe_path = Some(bitcoind::internal_bitcoind_exe_path(
|
self.exe_path = Some(bitcoind::internal_bitcoind_exe_path(
|
||||||
&self.liana_datadir,
|
&self.liana_datadir,
|
||||||
|
VERSION,
|
||||||
));
|
));
|
||||||
return Command::perform(async {}, |_| {
|
return Command::perform(async {}, |_| {
|
||||||
Message::InternalBitcoind(
|
Message::InternalBitcoind(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user