Skip to content
Draft
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
22 changes: 22 additions & 0 deletions build_common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use std::process::Command;

/// Expose the liana version. If the `LIANA_VERSION` environment variable is set, we are in release,
/// so we use that, otherwise use the git hash.
pub fn expose_liana_version() {
if let Some(version) = std::env::var_os("LIANA_VERSION") {
println!("cargo:rustc-env=LIANA_VERSION={}", version.to_string_lossy());
} else {
let git_hash = get_git_hash();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
}
}

/// Fetch the short git commit hash.
pub fn get_git_hash() -> String {
let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.expect("Git command should succeed.");

String::from_utf8_lossy(&output.stdout).trim().to_string()
}
3 changes: 2 additions & 1 deletion contrib/release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
set -ex

VERSION="${VERSION:-"12.0"}"
export LIANA_VERSION="$VERSION"
LIANA_PREFIX="liana-$VERSION"
LINUX_DIR_NAME="$LIANA_PREFIX-x86_64-linux-gnu"
LINUX_ARCHIVE="$LINUX_DIR_NAME.tar.gz"
Expand Down Expand Up @@ -42,7 +43,7 @@ create_dir "$BUILD_DIR"

OUT_DIR="$BUILD_DIR" ./contrib/reproducible/guix/guix-build.sh

nix build .#release
LIANA_VERSION="$VERSION" nix build .#release --impure
NIX_BUILD_DIR="$(nix path-info .#release)"

#Create the Linux archive and Debian binary package.
Expand Down
8 changes: 8 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
pkgsCross.mingwW64.windows.pthreads
];

preBuild = ''
export LIANA_VERSION=${builtins.getEnv "LIANA_VERSION"}
'';

installPhaseCommand = ''
mkdir -p $out/x86_64-pc-windows-gnu
cp target/x86_64-pc-windows-gnu/release/liana-gui.exe $out/x86_64-pc-windows-gnu
Expand All @@ -74,6 +78,8 @@
];

preBuild = ''
export LIANA_VERSION=${builtins.getEnv "LIANA_VERSION"}

export SDKROOT=${pkgs.darwin.xcode_12_2}/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

export XDG_CACHE_HOME=$TMPDIR/xdg_cache
Expand Down Expand Up @@ -108,6 +114,8 @@
];

preBuild = ''
export LIANA_VERSION=${builtins.getEnv "LIANA_VERSION"}

export SDKROOT=${pkgs.darwin.xcode_12_2}/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

export XDG_CACHE_HOME=$TMPDIR/xdg_cache
Expand Down
5 changes: 5 additions & 0 deletions liana-gui/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include!("../build_common.rs");

fn main() {
expose_liana_version();
}
16 changes: 8 additions & 8 deletions liana-gui/src/app/view/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ use lianad::config::BitcoindRpcAuth;

use super::{dashboard, message::*};

use liana_ui::{
component::{badge, button, card, form, separation, text::*, tooltip::tooltip},
icon,
theme::{self},
widget::*,
};

use crate::{
app::{
cache::Cache,
Expand All @@ -41,6 +34,13 @@ use crate::{
electrum::{self, validate_domain_checkbox},
},
};
use liana_ui::{
component::{badge, button, card, form, separation, text::*, tooltip::tooltip},
icon,
theme::{self},
widget::*,
};
use lianad::LIANA_VERSION;

fn header(title: &str, msg: SettingsMessage) -> Row<'static, Message> {
Row::new()
Expand Down Expand Up @@ -300,7 +300,7 @@ pub fn about_section<'a>(
.push(
Row::new().push(Space::with_width(Length::Fill)).push(
Column::new()
.push(text(format!("liana-gui v{}", crate::VERSION)))
.push(text(format!("liana-gui v{}", LIANA_VERSION)))
.push_maybe(
lianad_version.map(|version| text(format!("lianad v{}", version))),
),
Expand Down
10 changes: 3 additions & 7 deletions liana-gui/src/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use liana::{
use lianad::{
bip329,
commands::{CoinStatus, ListCoinsEntry},
LIANA_VERSION,
};
use serde::{Deserialize, Serialize};
use serde_json::Value;
Expand All @@ -31,17 +32,12 @@ use crate::{
installer::Context,
services::connect::client::backend::api::DEFAULT_LIMIT,
utils::now,
VERSION,
};

const CONFIG_KEY: &str = "config";
const SETTINGS_KEY: &str = "settings";
const LIANA_VERSION_KEY: &str = "liana_version";

pub fn liana_version() -> String {
format!("{}.{}", VERSION.major, VERSION.minor)
}

#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct Backup {
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -139,7 +135,7 @@ impl Backup {
account.timestamp = Some(now);
account
.proprietary
.insert(LIANA_VERSION_KEY.to_string(), liana_version().into());
.insert(LIANA_VERSION_KEY.to_string(), LIANA_VERSION.into());

ctx.keys.iter().for_each(|(k, s)| {
account.keys.insert(*k, s.to_backup());
Expand All @@ -166,7 +162,7 @@ impl Backup {
sender: &UnboundedSender<Progress>,
) -> Result<Self, Error> {
let mut proprietary = serde_json::Map::new();
proprietary.insert(LIANA_VERSION_KEY.to_string(), liana_version().into());
proprietary.insert(LIANA_VERSION_KEY.to_string(), LIANA_VERSION.into());

let name = wallet.name.clone();
let descriptor = wallet.main_descriptor.to_string();
Expand Down
3 changes: 1 addition & 2 deletions liana-gui/src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use crate::{
launcher,
logger::setup_logger,
services::fiat::{Currency, PriceSource},
VERSION,
};

use iced::window::Id;
Expand Down Expand Up @@ -93,7 +92,7 @@ async fn ctrl_c() -> Result<(), ()> {

impl GUI {
pub fn title(&self) -> String {
format!("Liana v{}", VERSION)
format!("Liana v{}", lianad::LIANA_VERSION)
}

pub fn new((config, log_level): (Config, Option<LevelFilter>)) -> (GUI, Task<Message>) {
Expand Down
4 changes: 2 additions & 2 deletions liana-gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use liana_gui::{
dir::LianaDirectory,
gui::{Config, GUI},
node::bitcoind::delete_all_bitcoind_locks_for_process,
VERSION,
};
use lianad::LIANA_VERSION;

#[derive(Debug, PartialEq)]
enum Arg {
Expand All @@ -31,7 +31,7 @@ fn parse_args(args: Vec<String>) -> Result<Vec<Arg>, Box<dyn Error>> {
let mut res = Vec::new();

if args.len() > 1 && (args[1] == "--version" || args[1] == "-v") {
eprintln!("{}", VERSION);
eprintln!("{}", LIANA_VERSION);
process::exit(1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"log_level": null,
"start_internal_bitcoind": false
},
"liana_version": "11.0",
"liana_version": "12.0",
"settings": {
"alias": "My Liana Regtest wallet",
"descriptor_checksum": "jz5sm0xn",
Expand Down
5 changes: 5 additions & 0 deletions lianad/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include!("../build_common.rs");

fn main() {
expose_liana_version();
}
6 changes: 3 additions & 3 deletions lianad/src/bin/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ use std::{
process, thread, time,
};

use lianad::{config::Config, setup_panic_hook, DaemonHandle, VERSION};
use lianad::{config::Config, setup_panic_hook, DaemonHandle, LIANA_VERSION};

fn print_help_exit(code: i32) {
eprintln!("lianad version {}", VERSION);
eprintln!("lianad version {}", LIANA_VERSION);
eprintln!("A TOML configuration file is required to run lianad. By default lianad looks for a 'config.toml' file in its data directory. A different one may be provided like so: '--conf <config file path>'.");
eprintln!("A documented sample is available at 'contrib/lianad_config_example.toml' in the source tree (https://github.com/wizardsardine/liana/blob/v1.0/contrib/lianad_config_example.toml).");
eprintln!("The default data directory path is a 'liana/' folder in the XDG standard configuration directory for all OSes but Linux ones, where it's '~/.liana/'.");
process::exit(code);
}

fn print_version() {
eprintln!("{}", VERSION);
eprintln!("{}", LIANA_VERSION);
process::exit(0);
}

Expand Down
4 changes: 2 additions & 2 deletions lianad/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
database::{Coin, DatabaseConnection, DatabaseInterface},
miniscript::bitcoin::absolute::LockTime,
poller::PollerMessage,
DaemonControl, VERSION,
DaemonControl, LIANA_VERSION,
};

pub use crate::database::{CoinStatus, LabelItem};
Expand Down Expand Up @@ -329,7 +329,7 @@ impl DaemonControl {
.rescan_timestamp
.map(|_| self.bitcoin.rescan_progress().unwrap_or(1.0));
GetInfoResult {
version: VERSION.to_string(),
version: LIANA_VERSION.to_string(),
network: self.config.bitcoin_config.network,
block_height,
sync: self.bitcoin.sync_progress().rounded_up_progress(),
Expand Down
16 changes: 10 additions & 6 deletions lianad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,22 @@ pub fn setup_panic_hook() {
}));
}

const fn get_version() -> &'static str {
if let Some(version) = option_env!("LIANA_VERSION") {
version
} else {
env!("GIT_HASH")
}
}

pub const LIANA_VERSION: &str = get_version();

#[derive(Debug, Clone)]
pub struct Version {
pub major: u32,
pub minor: u32,
}

impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}.{}-dev", self.major, self.minor)
}
}

pub const VERSION: Version = Version {
major: 12,
minor: 0,
Expand Down
1 change: 0 additions & 1 deletion tests/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
def test_getinfo(lianad):
res = lianad.rpc.getinfo()
assert "timestamp" in res.keys()
assert res["version"] == "12.0-dev"
assert res["network"] == "regtest"
wait_for(lambda: lianad.rpc.getinfo()["block_height"] == 101)
res = lianad.rpc.getinfo()
Expand Down
Loading