Skip to content

Commit a49824b

Browse files
pwltrcatch-21jvsena42ovitrif
authored
fix: persist channel locally in case remote backup fails (#2575)
* fix: persist channel locally in case remote backup fails * chore: bump trigger ci actions * chore: updatr react-native-ldk * chore: update yarn lockfile for react-native-ldk 0.0.163 --------- Co-authored-by: James Browning <[email protected]> Co-authored-by: jvsena42 <[email protected]> Co-authored-by: Ovi Trif <[email protected]>
1 parent 3662576 commit a49824b

File tree

7 files changed

+39
-88
lines changed

7 files changed

+39
-88
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,6 @@ android/app/release/
9999

100100
# Optimized SVGs
101101
src/assets/svgs/optimized/
102+
103+
#AI
104+
CLAUDE.md

ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ PODS:
13311331
- ReactCommon/turbomodule/bridging
13321332
- ReactCommon/turbomodule/core
13331333
- Yoga
1334-
- react-native-ldk (0.0.159):
1334+
- react-native-ldk (0.0.161):
13351335
- React
13361336
- react-native-mmkv (2.12.2):
13371337
- DoubleConversion
@@ -2397,7 +2397,7 @@ SPEC CHECKSUMS:
23972397
react-native-biometrics: 43ed5b828646a7862dbc7945556446be00798e7d
23982398
react-native-blur: b06c3fe88680beac622d8d13b8c36ec15c50383b
23992399
react-native-image-picker: 037a6ccde76aa165446e1eaeb8866cb00f461916
2400-
react-native-ldk: c676f1f7113c2c64cf8470bb76d4954e4b72ff3a
2400+
react-native-ldk: 78df73ae001be0700bc0e796dfecd576fa09fec1
24012401
react-native-mmkv: a6e08ad1b51b84af075f91798f8a92c878472265
24022402
react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187
24032403
react-native-pubky: 54d37810f35d9da11f8c199a6036e5729081951b

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@reduxjs/toolkit": "2.2.6",
4949
"@shopify/react-native-skia": "next",
5050
"@synonymdev/blocktank-lsp-http-client": "2.5.0",
51-
"@synonymdev/react-native-ldk": "0.0.159",
51+
"@synonymdev/react-native-ldk": "0.0.163",
5252
"@synonymdev/react-native-lnurl": "0.0.10",
5353
"@synonymdev/react-native-pubky": "^0.3.0",
5454
"@synonymdev/result": "0.0.2",

src/screens/Settings/DevSettings/LdkDebug.tsx

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {
99
TouchableOpacity,
1010
View,
1111
} from 'react-native';
12-
import RNFS from 'react-native-fs';
1312
import Share from 'react-native-share';
1413

14+
import Dialog from '../../../components/Dialog';
1515
import KeyboardAvoidingView from '../../../components/KeyboardAvoidingView';
1616
import NavigationHeader from '../../../components/NavigationHeader';
1717
import SafeAreaInset from '../../../components/SafeAreaInset';
@@ -53,6 +53,7 @@ const LdkDebug = (): ReactElement => {
5353
const sheetRef = useSheetRef('forceTransfer');
5454
const [peer, setPeer] = useState('');
5555
const [txid, setTxid] = useState('');
56+
const [showDialog, setShowDialog] = useState(false);
5657
const [payingInvoice, setPayingInvoice] = useState(false);
5758
const [refreshingLdk, setRefreshingLdk] = useState(false);
5859
const [restartingLdk, setRestartingLdk] = useState(false);
@@ -191,8 +192,11 @@ const LdkDebug = (): ReactElement => {
191192
}
192193
};
193194

194-
const onExportLogs = async (): Promise<void> => {
195-
const result = await zipLogs();
195+
const onExportFiles = async (): Promise<void> => {
196+
const result = await zipLogs({
197+
includeJson: true,
198+
includeBinaries: true,
199+
});
196200
if (result.isErr()) {
197201
showToast({
198202
type: 'warning',
@@ -208,30 +212,8 @@ const LdkDebug = (): ReactElement => {
208212
url: `file://${result.value}`,
209213
title: t('export_logs'),
210214
});
211-
};
212-
213-
const onSaveLogs = async (): Promise<void> => {
214-
const result = await zipLogs();
215-
if (result.isErr()) {
216-
showToast({
217-
type: 'warning',
218-
title: t('error_logs'),
219-
description: t('error_logs_description'),
220-
});
221-
return;
222-
}
223-
224-
// Define the destination path in the Downloads folder
225-
const downloadsDir = RNFS.DownloadDirectoryPath;
226-
const destinationPath = `${downloadsDir}/bitkit_ldk_logs.zip`;
227-
228-
await RNFS.copyFile(result.value, destinationPath);
229215

230-
showToast({
231-
type: 'success',
232-
title: 'Logs saved', // todo: locale
233-
description: `${destinationPath}`,
234-
});
216+
setShowDialog(false);
235217
};
236218

237219
const onCreateInvoice = async (amountSats = 100): Promise<void> => {
@@ -710,14 +692,8 @@ const LdkDebug = (): ReactElement => {
710692
/>
711693
<Button
712694
style={styles.button}
713-
text="Export Logs"
714-
onPress={onExportLogs}
715-
/>
716-
<Button
717-
style={styles.button}
718-
text="Save Logs"
719-
onPress={onSaveLogs}
720-
testID="SaveLogs"
695+
text="Export Files"
696+
onPress={(): void => setShowDialog(true)}
721697
/>
722698

723699
{openChannels.length > 0 && (
@@ -838,6 +814,15 @@ const LdkDebug = (): ReactElement => {
838814
<SafeAreaInset type="bottom" minPadding={16} />
839815
</ScrollView>
840816
</KeyboardAvoidingView>
817+
818+
<Dialog
819+
visible={showDialog}
820+
title="Export sensitive files?"
821+
description="This export contains sensitive data and gives control over your Lightning funds. Do you want to continue?"
822+
cancelText="Cancel"
823+
onCancel={(): void => setShowDialog(false)}
824+
onConfirm={onExportFiles}
825+
/>
841826
</ThemedView>
842827
);
843828
};

src/screens/Settings/DevSettings/index.tsx

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
33
import RNFS, { unlink, writeFile } from 'react-native-fs';
44
import Share from 'react-native-share';
55

6-
import Dialog from '../../../components/Dialog';
76
import { EItemType, IListData } from '../../../components/List';
87
import { __E2E__ } from '../../../constants/env';
98
import { useAppDispatch, useAppSelector } from '../../../hooks/redux';
@@ -42,8 +41,6 @@ import {
4241
} from '../../../store/slices/wallet';
4342
import { resetWidgetsState } from '../../../store/slices/widgets';
4443
import { wipeApp } from '../../../store/utils/settings';
45-
import { zipLogs } from '../../../utils/lightning/logs';
46-
import { showToast } from '../../../utils/notifications';
4744
import { refreshWallet } from '../../../utils/wallet';
4845
import { runChecks } from '../../../utils/wallet/checks';
4946
import { getFakeTransaction } from '../../../utils/wallet/testing';
@@ -54,7 +51,6 @@ const DevSettings = ({
5451
}: SettingsScreenProps<'DevSettings'>): ReactElement => {
5552
const dispatch = useAppDispatch();
5653
const { t } = useTranslation('lightning');
57-
const [showDialog, setShowDialog] = useState(false);
5854
const [throwError, setThrowError] = useState(false);
5955
const selectedWallet = useAppSelector(selectedWalletSelector);
6056
const selectedNetwork = useAppSelector(selectedNetworkSelector);
@@ -71,30 +67,6 @@ const DevSettings = ({
7167
});
7268
};
7369

74-
const exportLdkLogs = async (): Promise<void> => {
75-
const result = await zipLogs({
76-
includeJson: true,
77-
includeBinaries: true,
78-
});
79-
if (result.isErr()) {
80-
showToast({
81-
type: 'warning',
82-
title: t('error_logs'),
83-
description: t('error_logs_description'),
84-
});
85-
return;
86-
}
87-
88-
// Share the zip file
89-
await Share.open({
90-
type: 'application/zip',
91-
url: `file://${result.value}`,
92-
title: t('export_logs'),
93-
});
94-
95-
setShowDialog(false);
96-
};
97-
9870
const exportStore = async (): Promise<void> => {
9971
const time = new Date().getTime();
10072
const store = JSON.stringify(getStore(), null, 2);
@@ -182,11 +154,6 @@ const DevSettings = ({
182154
type: EItemType.button,
183155
onPress: clearUtxos,
184156
},
185-
{
186-
title: 'Export LDK Logs',
187-
type: EItemType.button,
188-
onPress: () => setShowDialog(true),
189-
},
190157
{
191158
title: 'Export Store',
192159
type: EItemType.button,
@@ -350,19 +317,7 @@ const DevSettings = ({
350317
throw new Error('test render error');
351318
}
352319

353-
return (
354-
<>
355-
<SettingsView title="Dev Settings" listData={settingsListData} />
356-
<Dialog
357-
visible={showDialog}
358-
title="Export sensitive logs?"
359-
description="This export contains sensitive data and gives control over your Lightning funds. Do you want to continue?"
360-
cancelText="Cancel"
361-
onCancel={(): void => setShowDialog(false)}
362-
onConfirm={exportLdkLogs}
363-
/>
364-
</>
365-
);
320+
return <SettingsView title="Dev Settings" listData={settingsListData} />;
366321
};
367322

368323
export default memo(DevSettings);

src/utils/lightning/logs.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,19 @@ const listLogs = async ({
9797
}
9898

9999
if (includeBinaries) {
100+
// Include .bin files from account root
100101
const binFiles = await listFilesForAccount({
101102
path: account.path,
102103
filter: ['.bin'],
103104
});
104105
files.push(...binFiles);
106+
107+
// Include .bin files from channels folder
108+
const channelsBinFiles = await listFilesForAccount({
109+
path: `${account.path}/channels`,
110+
filter: ['.bin'],
111+
});
112+
files.push(...channelsBinFiles);
105113
}
106114

107115
const filePaths = files.map((f) => f.path);

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4585,16 +4585,16 @@ __metadata:
45854585
languageName: node
45864586
linkType: hard
45874587

4588-
"@synonymdev/react-native-ldk@npm:0.0.159":
4589-
version: 0.0.159
4590-
resolution: "@synonymdev/react-native-ldk@npm:0.0.159"
4588+
"@synonymdev/react-native-ldk@npm:0.0.163":
4589+
version: 0.0.163
4590+
resolution: "@synonymdev/react-native-ldk@npm:0.0.163"
45914591
dependencies:
45924592
"@synonymdev/raw-transaction-decoder": 1.1.0
45934593
bech32: ^2.0.0
45944594
bitcoinjs-lib: ^6.0.2
45954595
peerDependencies:
45964596
react-native: "*"
4597-
checksum: b88a630791a4936e9a1dc44a96d3e3e81db4d2ad6fd0fd15a22e439ca9b5d9cd6a2edf0ad36980fa68c000aaed01c8b49a2860eb23d31f09c058d784381289f0
4597+
checksum: 38d47d8c6ff339834fe7bc139cef6e9f52dabbe44eda1afa1cc67023a780a0770f1e03666b566f6267c85e7a7bdd21a23c2ed86090ee4badc1be27f4b0093085
45984598
languageName: node
45994599
linkType: hard
46004600

@@ -5826,7 +5826,7 @@ __metadata:
58265826
"@reduxjs/toolkit": 2.2.6
58275827
"@shopify/react-native-skia": next
58285828
"@synonymdev/blocktank-lsp-http-client": 2.5.0
5829-
"@synonymdev/react-native-ldk": 0.0.159
5829+
"@synonymdev/react-native-ldk": 0.0.163
58305830
"@synonymdev/react-native-lnurl": 0.0.10
58315831
"@synonymdev/react-native-pubky": ^0.3.0
58325832
"@synonymdev/result": 0.0.2

0 commit comments

Comments
 (0)