diff --git a/src/lib.rs b/src/lib.rs index 11d46d5..e269d28 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, }, diff --git a/src/utils.rs b/src/utils.rs index 05d414c..42dad35 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -114,6 +114,22 @@ impl From for RgbNetwork { } } +#[cfg(not(target_os = "windows"))] +pub(crate) fn adjust_canonicalization>(p: P) -> String { + p.as_ref().display().to_string() +} + +#[cfg(target_os = "windows")] +pub(crate) fn adjust_canonicalization>(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 { diff --git a/src/wallet/offline.rs b/src/wallet/offline.rs index 01aaeff..7a893b0 100644 --- a/src/wallet/offline.rs +++ b/src/wallet/offline.rs @@ -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)