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

fix: ios and android catch channel write fails #201

Merged
merged 1 commit into from
Jan 18, 2024
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
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ PODS:
- React-jsinspector (0.72.4)
- React-logger (0.72.4):
- glog
- react-native-ldk (0.0.124):
- react-native-ldk (0.0.125):
- React
- react-native-randombytes (3.6.1):
- React-Core
Expand Down Expand Up @@ -723,7 +723,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: c7f826e40fa9cab5d37cab6130b1af237332b594
React-jsinspector: aaed4cf551c4a1c98092436518c2d267b13a673f
React-logger: da1ebe05ae06eb6db4b162202faeafac4b435e77
react-native-ldk: 5ac636bea5e24c687a4a009a339d5ee82e8c8d0f
react-native-ldk: c78b18c8c8fe218481721f7083e3e0f825aa957e
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
react-native-tcp-socket: c1b7297619616b4c9caae6889bcb0aba78086989
React-NativeModulesApple: edb5ace14f73f4969df6e7b1f3e41bef0012740f
Expand Down Expand Up @@ -753,4 +753,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 940323d07de591a59a2ab39fc0ef7b7d6dc89c0d

COCOAPODS: 1.12.1
COCOAPODS: 1.14.3
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ class LdkPersister {
val isNew = !file.exists()

BackupClient.addToPersistQueue(BackupClient.Label.CHANNEL_MONITOR(channelId=channelId), data.write()) {
file.writeBytes(data.write())
try {
file.writeBytes(data.write())
} catch (e: Exception) {
//If this fails we can't do much but LDK will retry on startup
LdkEventEmitter.send(EventTypes.native_log, "Failed to locally persist channel (${id.to_channel_id().hexEncodedString()}) to disk")
return@addToPersistQueue
}

//Update chainmonitor with successful persist
val res = LdkModule.chainMonitor?.channel_monitor_updated(id, update_id)
Expand Down
8 changes: 7 additions & 1 deletion lib/ios/Classes/LdkPersist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ class LdkPersister: Persist {

BackupClient.addToPersistQueue(.channelMonitor(id: channelIdHex), data.write()) {
//Callback for when the persist queue queue entry is processed
try! Data(data.write()).write(to: channelStoragePath)
do {
try Data(data.write()).write(to: channelStoragePath)
} catch {
//If this fails we can't do much but LDK will retry on startup
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Error. Failed to locally persist channel (\(channelIdHex)). \(error.localizedDescription)")
return
}

//Update chainmonitor with successful persist
let res = Ldk.chainMonitor?.channelMonitorUpdated(fundingTxo: channelId, completedUpdateId: updateId)
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@synonymdev/react-native-ldk",
"title": "React Native LDK",
"version": "0.0.124",
"version": "0.0.126",
"description": "React Native wrapper for LDK",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion lib/src/lightning-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,7 @@
if (supports_zero_conf) {
if (isTrustedPeer) {
await ldk.writeToLogFile(
'error',
'info',
`Accepting zero conf channel from peer ${counterparty_node_id}`,
);

Expand Down Expand Up @@ -2022,7 +2022,7 @@
}

private onChannelManagerPendingHtlcsForwardable(
res: TChannelManagerPendingHtlcsForwardable,

Check warning on line 2025 in lib/src/lightning-manager.ts

View workflow job for this annotation

GitHub Actions / Run lint check

'res' is defined but never used. Allowed unused args must match /^_/u
): void {
ldk.processPendingHtlcForwards().catch(console.error);
}
Expand Down
Loading