diff --git a/swap/src/bin/asb.rs b/swap/src/bin/asb.rs index e0fae52b4..f69cc4d3a 100644 --- a/swap/src/bin/asb.rs +++ b/swap/src/bin/asb.rs @@ -100,9 +100,11 @@ pub async fn main() -> Result<()> { let seed = Seed::from_file_or_generate(&config.data.dir).expect("Could not retrieve/initialize seed"); + let db_file = config.data.dir.join("sqlite"); + match cmd { Command::Start { resume_only } => { - let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite, None).await?; + let db = open_db(db_file, AccessMode::ReadWrite, None).await?; // check and warn for duplicate rendezvous points let mut rendezvous_addrs = config.network.rendezvous_point.clone(); @@ -234,7 +236,7 @@ pub async fn main() -> Result<()> { event_loop.run().await; } Command::History => { - let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadOnly, None).await?; + let db = open_db(db_file, AccessMode::ReadOnly, None).await?; let mut table = Table::new(); table.set_header(vec![ @@ -316,7 +318,7 @@ pub async fn main() -> Result<()> { tracing::info!(%bitcoin_balance, %monero_balance, "Current balance"); } Command::Cancel { swap_id } => { - let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite, None).await?; + let db = open_db(db_file, AccessMode::ReadWrite, None).await?; let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?; @@ -325,7 +327,7 @@ pub async fn main() -> Result<()> { tracing::info!("Cancel transaction successfully published with id {}", txid); } Command::Refund { swap_id } => { - let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite, None).await?; + let db = open_db(db_file, AccessMode::ReadWrite, None).await?; let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?; let monero_wallet = init_monero_wallet(&config, env_config).await?; @@ -341,7 +343,7 @@ pub async fn main() -> Result<()> { tracing::info!("Monero successfully refunded"); } Command::Punish { swap_id } => { - let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite, None).await?; + let db = open_db(db_file, AccessMode::ReadWrite, None).await?; let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?; @@ -350,7 +352,7 @@ pub async fn main() -> Result<()> { tracing::info!("Punish transaction successfully published with id {}", txid); } Command::SafelyAbort { swap_id } => { - let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite, None).await?; + let db = open_db(db_file, AccessMode::ReadWrite, None).await?; safely_abort(swap_id, db).await?; @@ -360,7 +362,7 @@ pub async fn main() -> Result<()> { swap_id, do_not_await_finality, } => { - let db = open_db(config.data.dir.join("sqlite"), AccessMode::ReadWrite, None).await?; + let db = open_db(db_file, AccessMode::ReadWrite, None).await?; let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;