fix: handle different LND dirs for DEBUG_deleteNeutrinoFiles
This commit is contained in:
@@ -453,8 +453,14 @@ class LndMobileTools extends ReactContextBaseJavaModule {
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void DEBUG_deleteNeutrinoFiles(String network, Promise promise) {
|
||||
String chainFolder = getReactApplicationContext().getFilesDir().toString() + "/data/chain/bitcoin/" + network;
|
||||
public void DEBUG_deleteNeutrinoFiles(String lndDir, String network, Promise promise) {
|
||||
String basePath;
|
||||
if (lndDir == null || lndDir.isEmpty() || lndDir.equals("lnd")) {
|
||||
basePath = getReactApplicationContext().getFilesDir().toString();
|
||||
} else {
|
||||
basePath = getReactApplicationContext().getFilesDir().toString() + "/" + lndDir;
|
||||
}
|
||||
String chainFolder = basePath + "/data/chain/bitcoin/" + network;
|
||||
|
||||
String neutrinoDb = chainFolder + "/neutrino.db";
|
||||
String blockHeadersBin = chainFolder + "/block_headers.bin";
|
||||
|
||||
@@ -66,7 +66,8 @@ RCT_EXTERN_METHOD(
|
||||
)
|
||||
|
||||
RCT_EXTERN_METHOD(
|
||||
DEBUG_deleteNeutrinoFiles: (NSString)network
|
||||
DEBUG_deleteNeutrinoFiles: (NSString)lndDir
|
||||
network: (NSString)network
|
||||
resolver: (RCTPromiseResolveBlock)resolve
|
||||
rejecter: (RCTPromiseRejectBlock)reject
|
||||
)
|
||||
|
||||
@@ -243,14 +243,15 @@ class LndMobileTools: RCTEventEmitter {
|
||||
resolve(true)
|
||||
}
|
||||
|
||||
@objc(DEBUG_deleteNeutrinoFiles:resolver:rejecter:)
|
||||
func DEBUG_deleteNeutrinoFiles(network: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
|
||||
@objc(DEBUG_deleteNeutrinoFiles:network:resolver:rejecter:)
|
||||
func DEBUG_deleteNeutrinoFiles(lndDir: String, network: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
|
||||
let applicationSupport = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
|
||||
let chainPath = applicationSupport.appendingPathComponent("lnd", isDirectory: true)
|
||||
let folderName = lndDir.isEmpty ? "lnd" : lndDir
|
||||
let chainPath = applicationSupport.appendingPathComponent(folderName, isDirectory: true)
|
||||
.appendingPathComponent("data", isDirectory: true)
|
||||
.appendingPathComponent("chain", isDirectory: true)
|
||||
.appendingPathComponent("bitcoin", isDirectory: true)
|
||||
.appendingPathComponent(network ?? "mainnet", isDirectory: true)
|
||||
.appendingPathComponent(network.isEmpty ? "mainnet" : network, isDirectory: true)
|
||||
|
||||
let neutrinoDbPath = chainPath.appendingPathComponent("neutrino.db")
|
||||
let blockHeadersBinPath = chainPath.appendingPathComponent("block_headers.bin")
|
||||
|
||||
Vendored
+4
-1
@@ -112,7 +112,10 @@ export interface ILndMobileTools {
|
||||
DEBUG_deleteSpeedloaderLastrunFile(): Promise<boolean>;
|
||||
DEBUG_deleteSpeedloaderDgraphDirectory(): Promise<null>;
|
||||
deleteLndDirectory(lndDir: string): Promise<null>;
|
||||
DEBUG_deleteNeutrinoFiles(network: string): Promise<boolean>;
|
||||
DEBUG_deleteNeutrinoFiles(
|
||||
lndDir: string,
|
||||
network: string
|
||||
): Promise<boolean>;
|
||||
|
||||
// Android-specific
|
||||
getIntentStringData(): Promise<string | null>;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { Platform, NativeModules, ScrollView, Text, View } from 'react-native';
|
||||
import { Platform, ScrollView, Text, View } from 'react-native';
|
||||
import { Icon, ListItem } from '@rneui/themed';
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
@@ -19,7 +19,6 @@ import SettingsStore, {
|
||||
|
||||
import { localeString } from '../../../utils/LocaleUtils';
|
||||
import { restartNeeded } from '../../../utils/RestartUtils';
|
||||
import { sleep } from '../../../utils/SleepUtils';
|
||||
import { themeColor } from '../../../utils/ThemeUtils';
|
||||
|
||||
import { stopLnd } from '../../../utils/LndMobileUtils';
|
||||
@@ -81,8 +80,7 @@ export default class EmbeddedNodeAdvancedSettings extends React.Component<
|
||||
feeEstimator,
|
||||
customFeeEstimator
|
||||
} = this.state;
|
||||
const { updateSettings, embeddedLndNetwork, settings }: any =
|
||||
SettingsStore;
|
||||
const { updateSettings, settings }: any = SettingsStore;
|
||||
const { bimodalPathfinding } = settings;
|
||||
|
||||
return (
|
||||
@@ -186,64 +184,6 @@ export default class EmbeddedNodeAdvancedSettings extends React.Component<
|
||||
color={themeColor('secondaryText')}
|
||||
/>
|
||||
</ListItem>
|
||||
{false && (
|
||||
<>
|
||||
<ListItem
|
||||
containerStyle={{
|
||||
borderBottomWidth: 0,
|
||||
backgroundColor: 'transparent'
|
||||
}}
|
||||
>
|
||||
<ListItem.Title
|
||||
style={{
|
||||
color: themeColor('text'),
|
||||
fontFamily: 'PPNeueMontreal-Book'
|
||||
}}
|
||||
>
|
||||
{localeString('general.tor')}
|
||||
</ListItem.Title>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'flex-end'
|
||||
}}
|
||||
>
|
||||
<Switch
|
||||
value={embeddedTor}
|
||||
onValueChange={async () => {
|
||||
this.setState({
|
||||
embeddedTor: !embeddedTor
|
||||
});
|
||||
await updateSettings({
|
||||
embeddedTor: !embeddedTor
|
||||
});
|
||||
restartNeeded();
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</ListItem>
|
||||
<View
|
||||
style={{
|
||||
margin: 10
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: themeColor('secondaryText')
|
||||
}}
|
||||
>
|
||||
{`${localeString(
|
||||
'views.Settings.EmbeddedNode.embeddedTor.subtitle'
|
||||
)} ${localeString(
|
||||
'views.Settings.EmbeddedNode.embeddedTor.clearnetWarning'
|
||||
)} ${localeString(
|
||||
'views.Settings.EmbeddedNode.restart'
|
||||
)}`}
|
||||
</Text>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
{Platform.OS === 'android' && (
|
||||
<>
|
||||
<ListItem
|
||||
@@ -480,56 +420,6 @@ export default class EmbeddedNodeAdvancedSettings extends React.Component<
|
||||
/>
|
||||
</ListItem>
|
||||
</>
|
||||
<>
|
||||
<View style={{ marginTop: 20 }}>
|
||||
<Button
|
||||
title={localeString(
|
||||
'views.Settings.EmbeddedNode.stopLndDeleteNeutrino'
|
||||
)}
|
||||
onPress={async () => {
|
||||
try {
|
||||
await NativeModules.LndMobile.stopLnd();
|
||||
await sleep(5000); // Let lnd close down
|
||||
} catch (e: any) {
|
||||
// If lnd was closed down already
|
||||
if (
|
||||
e?.message?.includes?.('closed')
|
||||
) {
|
||||
console.log('yes closed');
|
||||
} else {
|
||||
console.error(e.message, 10000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(
|
||||
await NativeModules.LndMobileTools.DEBUG_deleteNeutrinoFiles(
|
||||
embeddedLndNetwork === 'Mainnet'
|
||||
? 'mainnet'
|
||||
: 'testnet'
|
||||
)
|
||||
);
|
||||
restartNeeded();
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
margin: 10,
|
||||
marginTop: 15
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: themeColor('secondaryText')
|
||||
}}
|
||||
>
|
||||
{localeString(
|
||||
'views.Settings.EmbeddedNode.stopLndDeleteNeutrino.subtitle'
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
</>
|
||||
{false && persistentMode && (
|
||||
<View style={{ margin: 15 }}>
|
||||
<Button
|
||||
|
||||
@@ -64,7 +64,8 @@ export default class EmbeddedNodeTroubleshooting extends React.Component<
|
||||
deleteNeutrinoSuccess,
|
||||
deleteNeutrinoError
|
||||
} = this.state;
|
||||
const { updateSettings, embeddedLndNetwork }: any = SettingsStore;
|
||||
const { updateSettings, embeddedLndNetwork, lndDir }: any =
|
||||
SettingsStore;
|
||||
|
||||
return (
|
||||
<Screen>
|
||||
@@ -295,12 +296,8 @@ export default class EmbeddedNodeTroubleshooting extends React.Component<
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(
|
||||
embeddedLndNetwork === 'Mainnet'
|
||||
? 'mainnet'
|
||||
: 'testnet'
|
||||
);
|
||||
await NativeModules.LndMobileTools.DEBUG_deleteNeutrinoFiles(
|
||||
lndDir || 'lnd',
|
||||
embeddedLndNetwork === 'Mainnet'
|
||||
? 'mainnet'
|
||||
: 'testnet'
|
||||
|
||||
Reference in New Issue
Block a user