Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native wipeLdkStorage call #260

Open
limpbrains opened this issue Jul 12, 2024 · 1 comment
Open

Native wipeLdkStorage call #260

limpbrains opened this issue Jul 12, 2024 · 1 comment
Assignees

Comments

@limpbrains
Copy link
Contributor

Right now we are using custom function that cleans ldk storage in bitkit:

export const wipeLdkStorage = async ({
	selectedWallet = getSelectedWallet(),
	selectedNetwork = getSelectedNetwork(),
}: {
	selectedWallet?: TWalletName;
	selectedNetwork?: EAvailableNetwork;
}): Promise<Result<string>> => {
	await ldk.stop();
	const path = `${RNFS.DocumentDirectoryPath}/ldk/${lm.account.name}`;

	const deleteAllFiles = async (dirpath: string): Promise<void> => {
		const items = await RNFS.readDir(dirpath);
		for (const item of items) {
			if (item.isFile()) {
				await RNFS.unlink(item.path);
			} else {
				await deleteAllFiles(item.path);
			}
		}
	};

	try {
		// delete all files in the directory
		// NOTE: this is a workaround for RNFS.unlink(folder) freezing the app
		await deleteAllFiles(path);
	} catch (e) {
		return err(e);
	}

	return ok(`${selectedNetwork}'s LDK directory wiped for ${selectedWallet}`);
};

I think we should move this logic to native Kotlin/Swift code to make it more robust and handle corner cases, like LDK being running.

@ovitrif
Copy link
Contributor

ovitrif commented Jul 12, 2024

Totally, right now we don't even have only one module concerned with LDK files, this change will help move in that direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants