Skip to content

Commit

Permalink
fix OS-specific DB URL
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedberg committed May 21, 2024
1 parent 193191f commit ae42403
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ use crate::{
},
error::InternalError,
utils::{
calculate_descriptor_from_xprv, calculate_descriptor_from_xpub,
adjust_canonicalization, calculate_descriptor_from_xprv, calculate_descriptor_from_xpub,
derive_account_xprv_from_mnemonic, get_xpub_from_xprv, load_rgb_runtime, now, setup_logger,
RgbRuntime, LOG_FILE,
},
Expand Down
16 changes: 16 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ impl From<BitcoinNetwork> for RgbNetwork {
}
}

#[cfg(not(target_os = "windows"))]
pub(crate) fn adjust_canonicalization<P: AsRef<Path>>(p: P) -> String {
p.as_ref().display().to_string()
}

#[cfg(target_os = "windows")]
pub(crate) fn adjust_canonicalization<P: AsRef<Path>>(p: P) -> String {
const VERBATIM_PREFIX: &str = r#"\\?\"#;
let p = p.as_ref().display().to_string();
if p.starts_with(VERBATIM_PREFIX) {
p[VERBATIM_PREFIX.len()..].to_string()
} else {
p
}
}

#[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))]
pub(crate) fn get_genesis_hash(bitcoin_network: &BitcoinNetwork) -> &str {
match bitcoin_network {
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,8 @@ impl Wallet {

// RGB-LIB setup
let db_path = wallet_dir.join(RGB_LIB_DB_NAME);
let connection_string = format!("sqlite://{}?mode=rwc", db_path.as_path().display());
let display_db_path = adjust_canonicalization(db_path);
let connection_string = format!("sqlite:{}?mode=rwc", display_db_path);
let mut opt = ConnectOptions::new(connection_string);
opt.max_connections(1)
.min_connections(0)
Expand Down

0 comments on commit ae42403

Please sign in to comment.