Skip to content

Commit

Permalink
fix(app): Check for old wallet data in correct location
Browse files Browse the repository at this point in the history
I believe some old apps do have a `wallet` file that indicates that
the app should probably be migrated to the new wallet DB via a full
sync.

But this is not the case for fresh 1.9.0 apps. For those, we need to
consider the presence of the `on_chain` directory.
  • Loading branch information
luckysori committed Mar 6, 2024
1 parent b08a309 commit b184698
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mobile/native/src/ln_dlc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,18 @@ pub fn run(seed_dir: String, runtime: &Runtime) -> Result<()> {
pub async fn full_sync_on_wallet_db_migration() {
let node = state::get_node();

let old_wallet_db_path = Path::new(&config::get_data_dir()).join("wallet");
if old_wallet_db_path.exists() {
let old_wallet_dir = Path::new(&config::get_data_dir())
.join(config::get_network().to_string())
.join("on_chain");
if old_wallet_dir.exists() {
event::publish(&EventInternal::BackgroundNotification(
event::BackgroundTask::FullSync(event::TaskStatus::Pending),
));

let stop_gap = 20;
tracing::info!(
%stop_gap,
"Old wallet DB detected. Attempting to populate new wallet with full sync"
"Old wallet directory detected. Attempting to populate new wallet with full sync"
);

match node.inner.full_sync(stop_gap).await {
Expand All @@ -475,8 +477,8 @@ pub async fn full_sync_on_wallet_db_migration() {
event::BackgroundTask::FullSync(event::TaskStatus::Success),
));

if let Err(e) = std::fs::remove_file(old_wallet_db_path) {
tracing::info!("Failed to delete old wallet DB file: {e:#}");
if let Err(e) = std::fs::remove_dir_all(old_wallet_dir) {
tracing::info!("Failed to delete old wallet directory: {e:#}");
}
}
Err(e) => {
Expand Down

0 comments on commit b184698

Please sign in to comment.