Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,6 @@ android/app/release/

# Optimized SVGs
src/assets/svgs/optimized/

#AI
CLAUDE.md
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-ldk (0.0.159):
- react-native-ldk (0.0.161):
- React
- react-native-mmkv (2.12.2):
- DoubleConversion
Expand Down Expand Up @@ -2397,7 +2397,7 @@ SPEC CHECKSUMS:
react-native-biometrics: 43ed5b828646a7862dbc7945556446be00798e7d
react-native-blur: b06c3fe88680beac622d8d13b8c36ec15c50383b
react-native-image-picker: 037a6ccde76aa165446e1eaeb8866cb00f461916
react-native-ldk: c676f1f7113c2c64cf8470bb76d4954e4b72ff3a
react-native-ldk: 78df73ae001be0700bc0e796dfecd576fa09fec1
react-native-mmkv: a6e08ad1b51b84af075f91798f8a92c878472265
react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187
react-native-pubky: 54d37810f35d9da11f8c199a6036e5729081951b
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@reduxjs/toolkit": "2.2.6",
"@shopify/react-native-skia": "next",
"@synonymdev/blocktank-lsp-http-client": "2.5.0",
"@synonymdev/react-native-ldk": "0.0.159",
"@synonymdev/react-native-ldk": "0.0.163",
"@synonymdev/react-native-lnurl": "0.0.10",
"@synonymdev/react-native-pubky": "^0.3.0",
"@synonymdev/result": "0.0.2",
Expand Down
53 changes: 19 additions & 34 deletions src/screens/Settings/DevSettings/LdkDebug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
TouchableOpacity,
View,
} from 'react-native';
import RNFS from 'react-native-fs';
import Share from 'react-native-share';

import Dialog from '../../../components/Dialog';
import KeyboardAvoidingView from '../../../components/KeyboardAvoidingView';
import NavigationHeader from '../../../components/NavigationHeader';
import SafeAreaInset from '../../../components/SafeAreaInset';
Expand Down Expand Up @@ -53,6 +53,7 @@ const LdkDebug = (): ReactElement => {
const sheetRef = useSheetRef('forceTransfer');
const [peer, setPeer] = useState('');
const [txid, setTxid] = useState('');
const [showDialog, setShowDialog] = useState(false);
const [payingInvoice, setPayingInvoice] = useState(false);
const [refreshingLdk, setRefreshingLdk] = useState(false);
const [restartingLdk, setRestartingLdk] = useState(false);
Expand Down Expand Up @@ -191,8 +192,11 @@ const LdkDebug = (): ReactElement => {
}
};

const onExportLogs = async (): Promise<void> => {
const result = await zipLogs();
const onExportFiles = async (): Promise<void> => {
const result = await zipLogs({
includeJson: true,
includeBinaries: true,
});
if (result.isErr()) {
showToast({
type: 'warning',
Expand All @@ -208,30 +212,8 @@ const LdkDebug = (): ReactElement => {
url: `file://${result.value}`,
title: t('export_logs'),
});
};

const onSaveLogs = async (): Promise<void> => {
const result = await zipLogs();
if (result.isErr()) {
showToast({
type: 'warning',
title: t('error_logs'),
description: t('error_logs_description'),
});
return;
}

// Define the destination path in the Downloads folder
const downloadsDir = RNFS.DownloadDirectoryPath;
const destinationPath = `${downloadsDir}/bitkit_ldk_logs.zip`;

await RNFS.copyFile(result.value, destinationPath);

showToast({
type: 'success',
title: 'Logs saved', // todo: locale
description: `${destinationPath}`,
});
setShowDialog(false);
};

const onCreateInvoice = async (amountSats = 100): Promise<void> => {
Expand Down Expand Up @@ -710,14 +692,8 @@ const LdkDebug = (): ReactElement => {
/>
<Button
style={styles.button}
text="Export Logs"
onPress={onExportLogs}
/>
<Button
style={styles.button}
text="Save Logs"
onPress={onSaveLogs}
testID="SaveLogs"
text="Export Files"
onPress={(): void => setShowDialog(true)}
/>

{openChannels.length > 0 && (
Expand Down Expand Up @@ -838,6 +814,15 @@ const LdkDebug = (): ReactElement => {
<SafeAreaInset type="bottom" minPadding={16} />
</ScrollView>
</KeyboardAvoidingView>

<Dialog
visible={showDialog}
title="Export sensitive files?"
description="This export contains sensitive data and gives control over your Lightning funds. Do you want to continue?"
cancelText="Cancel"
onCancel={(): void => setShowDialog(false)}
onConfirm={onExportFiles}
/>
</ThemedView>
);
};
Expand Down
47 changes: 1 addition & 46 deletions src/screens/Settings/DevSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
import RNFS, { unlink, writeFile } from 'react-native-fs';
import Share from 'react-native-share';

import Dialog from '../../../components/Dialog';
import { EItemType, IListData } from '../../../components/List';
import { __E2E__ } from '../../../constants/env';
import { useAppDispatch, useAppSelector } from '../../../hooks/redux';
Expand Down Expand Up @@ -42,8 +41,6 @@ import {
} from '../../../store/slices/wallet';
import { resetWidgetsState } from '../../../store/slices/widgets';
import { wipeApp } from '../../../store/utils/settings';
import { zipLogs } from '../../../utils/lightning/logs';
import { showToast } from '../../../utils/notifications';
import { refreshWallet } from '../../../utils/wallet';
import { runChecks } from '../../../utils/wallet/checks';
import { getFakeTransaction } from '../../../utils/wallet/testing';
Expand All @@ -54,7 +51,6 @@ const DevSettings = ({
}: SettingsScreenProps<'DevSettings'>): ReactElement => {
const dispatch = useAppDispatch();
const { t } = useTranslation('lightning');
const [showDialog, setShowDialog] = useState(false);
const [throwError, setThrowError] = useState(false);
const selectedWallet = useAppSelector(selectedWalletSelector);
const selectedNetwork = useAppSelector(selectedNetworkSelector);
Expand All @@ -71,30 +67,6 @@ const DevSettings = ({
});
};

const exportLdkLogs = async (): Promise<void> => {
const result = await zipLogs({
includeJson: true,
includeBinaries: true,
});
if (result.isErr()) {
showToast({
type: 'warning',
title: t('error_logs'),
description: t('error_logs_description'),
});
return;
}

// Share the zip file
await Share.open({
type: 'application/zip',
url: `file://${result.value}`,
title: t('export_logs'),
});

setShowDialog(false);
};

const exportStore = async (): Promise<void> => {
const time = new Date().getTime();
const store = JSON.stringify(getStore(), null, 2);
Expand Down Expand Up @@ -182,11 +154,6 @@ const DevSettings = ({
type: EItemType.button,
onPress: clearUtxos,
},
{
title: 'Export LDK Logs',
type: EItemType.button,
onPress: () => setShowDialog(true),
},
{
title: 'Export Store',
type: EItemType.button,
Expand Down Expand Up @@ -350,19 +317,7 @@ const DevSettings = ({
throw new Error('test render error');
}

return (
<>
<SettingsView title="Dev Settings" listData={settingsListData} />
<Dialog
visible={showDialog}
title="Export sensitive logs?"
description="This export contains sensitive data and gives control over your Lightning funds. Do you want to continue?"
cancelText="Cancel"
onCancel={(): void => setShowDialog(false)}
onConfirm={exportLdkLogs}
/>
</>
);
return <SettingsView title="Dev Settings" listData={settingsListData} />;
};

export default memo(DevSettings);
8 changes: 8 additions & 0 deletions src/utils/lightning/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,19 @@ const listLogs = async ({
}

if (includeBinaries) {
// Include .bin files from account root
const binFiles = await listFilesForAccount({
path: account.path,
filter: ['.bin'],
});
files.push(...binFiles);

// Include .bin files from channels folder
const channelsBinFiles = await listFilesForAccount({
path: `${account.path}/channels`,
filter: ['.bin'],
});
files.push(...channelsBinFiles);
}

const filePaths = files.map((f) => f.path);
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4585,16 +4585,16 @@ __metadata:
languageName: node
linkType: hard

"@synonymdev/react-native-ldk@npm:0.0.159":
version: 0.0.159
resolution: "@synonymdev/react-native-ldk@npm:0.0.159"
"@synonymdev/react-native-ldk@npm:0.0.163":
version: 0.0.163
resolution: "@synonymdev/react-native-ldk@npm:0.0.163"
dependencies:
"@synonymdev/raw-transaction-decoder": 1.1.0
bech32: ^2.0.0
bitcoinjs-lib: ^6.0.2
peerDependencies:
react-native: "*"
checksum: b88a630791a4936e9a1dc44a96d3e3e81db4d2ad6fd0fd15a22e439ca9b5d9cd6a2edf0ad36980fa68c000aaed01c8b49a2860eb23d31f09c058d784381289f0
checksum: 38d47d8c6ff339834fe7bc139cef6e9f52dabbe44eda1afa1cc67023a780a0770f1e03666b566f6267c85e7a7bdd21a23c2ed86090ee4badc1be27f4b0093085
languageName: node
linkType: hard

Expand Down Expand Up @@ -5826,7 +5826,7 @@ __metadata:
"@reduxjs/toolkit": 2.2.6
"@shopify/react-native-skia": next
"@synonymdev/blocktank-lsp-http-client": 2.5.0
"@synonymdev/react-native-ldk": 0.0.159
"@synonymdev/react-native-ldk": 0.0.163
"@synonymdev/react-native-lnurl": 0.0.10
"@synonymdev/react-native-pubky": ^0.3.0
"@synonymdev/result": 0.0.2
Expand Down
Loading