From 476651912dca80193486b1b43e4a12e385f51430 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 28 Nov 2024 10:56:50 +0200 Subject: [PATCH 1/4] fix: handle output spending fee --- .../src/main/java/com/reactnativeldk/LdkModule.kt | 4 ++-- .../com/reactnativeldk/classes/LdkFeeEstimator.kt | 9 ++++----- lib/ios/Classes/LdkFeeEstimator.swift | 15 ++++++++------- lib/ios/Ldk.swift | 5 +++-- lib/src/ldk.ts | 2 ++ lib/src/lightning-manager.ts | 1 + lib/src/utils/types.ts | 1 + 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt b/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt index 51dcc560..a74c47ea 100644 --- a/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt +++ b/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt @@ -592,8 +592,8 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod //MARK: Update methods @ReactMethod - fun updateFees(anchorChannelFee: Double, nonAnchorChannelFee: Double, channelCloseMinimum: Double, minAllowedAnchorChannelRemoteFee: Double, onChainSweep: Double, minAllowedNonAnchorChannelRemoteFee: Double, promise: Promise) { - feeEstimator.update(anchorChannelFee.toInt(), nonAnchorChannelFee.toInt(), channelCloseMinimum.toInt(), minAllowedAnchorChannelRemoteFee.toInt(), onChainSweep.toInt(), minAllowedNonAnchorChannelRemoteFee.toInt()) + fun updateFees(anchorChannelFee: Double, nonAnchorChannelFee: Double, channelCloseMinimum: Double, minAllowedAnchorChannelRemoteFee: Double, onChainSweep: Double, minAllowedNonAnchorChannelRemoteFee: Double, outputSpendingFee: Double, promise: Promise) { + feeEstimator.update(anchorChannelFee.toInt(), nonAnchorChannelFee.toInt(), channelCloseMinimum.toInt(), minAllowedAnchorChannelRemoteFee.toInt(), onChainSweep.toInt(), minAllowedNonAnchorChannelRemoteFee.toInt(), outputSpendingFee.toInt()) handleResolve(promise, LdkCallbackResponses.fees_updated) } diff --git a/lib/android/src/main/java/com/reactnativeldk/classes/LdkFeeEstimator.kt b/lib/android/src/main/java/com/reactnativeldk/classes/LdkFeeEstimator.kt index 9c7b1f98..e68245eb 100644 --- a/lib/android/src/main/java/com/reactnativeldk/classes/LdkFeeEstimator.kt +++ b/lib/android/src/main/java/com/reactnativeldk/classes/LdkFeeEstimator.kt @@ -11,14 +11,16 @@ class LdkFeeEstimator { var minAllowedAnchorChannelRemoteFee: Int = 0 var onChainSweep: Int = 0 var minAllowedNonAnchorChannelRemoteFee: Int = 0 + var outputSpendingFee: Int = 0 - fun update(anchorChannelFee: Int, nonAnchorChannelFee: Int, channelCloseMinimum: Int, minAllowedAnchorChannelRemoteFee: Int, onChainSweep: Int, minAllowedNonAnchorChannelRemoteFee: Int) { + fun update(anchorChannelFee: Int, nonAnchorChannelFee: Int, channelCloseMinimum: Int, minAllowedAnchorChannelRemoteFee: Int, onChainSweep: Int, minAllowedNonAnchorChannelRemoteFee: Int, outputSpendingFee: Int) { this.anchorChannelFee = anchorChannelFee this.nonAnchorChannelFee = nonAnchorChannelFee this.channelCloseMinimum = channelCloseMinimum this.minAllowedAnchorChannelRemoteFee = minAllowedAnchorChannelRemoteFee this.onChainSweep = onChainSweep this.minAllowedNonAnchorChannelRemoteFee = minAllowedNonAnchorChannelRemoteFee + this.outputSpendingFee = outputSpendingFee LdkEventEmitter.send(EventTypes.native_log, "Fee estimator updated") } @@ -31,10 +33,7 @@ class LdkFeeEstimator { ConfirmationTarget.LDKConfirmationTarget_MinAllowedAnchorChannelRemoteFee -> minAllowedAnchorChannelRemoteFee ConfirmationTarget.LDKConfirmationTarget_OnChainSweep -> onChainSweep ConfirmationTarget.LDKConfirmationTarget_MinAllowedNonAnchorChannelRemoteFee -> minAllowedNonAnchorChannelRemoteFee - else -> { - LdkEventEmitter.send(EventTypes.native_log, "ERROR: New ConfirmationTarget added. Update LdkFeeEstimator.") - return@new_impl 0 - } + ConfirmationTarget.LDKConfirmationTarget_OutputSpendingFee -> outputSpendingFee } } } diff --git a/lib/ios/Classes/LdkFeeEstimator.swift b/lib/ios/Classes/LdkFeeEstimator.swift index c19cad67..2e8c0f23 100644 --- a/lib/ios/Classes/LdkFeeEstimator.swift +++ b/lib/ios/Classes/LdkFeeEstimator.swift @@ -15,21 +15,23 @@ class LdkFeeEstimator: FeeEstimator { private var minAllowedAnchorChannelRemoteFee: UInt32 = 0 private var onChainSweep: UInt32 = 0 private var minAllowedNonAnchorChannelRemoteFee: UInt32 = 0 - - func update(anchorChannelFee: UInt32, nonAnchorChannelFee: UInt32, channelCloseMinimum: UInt32, minAllowedAnchorChannelRemoteFee: UInt32, onChainSweep: UInt32, minAllowedNonAnchorChannelRemoteFee: UInt32) { + private var outputSpendingFee: UInt32 = 0 + + func update(anchorChannelFee: UInt32, nonAnchorChannelFee: UInt32, channelCloseMinimum: UInt32, minAllowedAnchorChannelRemoteFee: UInt32, onChainSweep: UInt32, minAllowedNonAnchorChannelRemoteFee: UInt32, outputSpendingFee: UInt32) { self.anchorChannelFee = anchorChannelFee self.nonAnchorChannelFee = nonAnchorChannelFee self.channelCloseMinimum = channelCloseMinimum self.minAllowedAnchorChannelRemoteFee = minAllowedAnchorChannelRemoteFee self.onChainSweep = onChainSweep self.minAllowedNonAnchorChannelRemoteFee = minAllowedNonAnchorChannelRemoteFee + self.outputSpendingFee = outputSpendingFee LdkEventEmitter.shared.send(withEvent: .native_log, body: "Fee estimator updated") } - + override func getEstSatPer1000Weight(confirmationTarget: Bindings.ConfirmationTarget) -> UInt32 { let target = confirmationTarget - + switch target { case .AnchorChannelFee: return anchorChannelFee @@ -43,9 +45,8 @@ class LdkFeeEstimator: FeeEstimator { return onChainSweep case .MinAllowedNonAnchorChannelRemoteFee: return minAllowedNonAnchorChannelRemoteFee - @unknown default: - LdkEventEmitter.shared.send(withEvent: .native_log, body: "ERROR: New ConfirmationTarget added. Update LdkFeeEstimator.") - return 0 + case .OutputSpendingFee: + return outputSpendingFee } } } diff --git a/lib/ios/Ldk.swift b/lib/ios/Ldk.swift index 7cb441c1..da5e7fda 100644 --- a/lib/ios/Ldk.swift +++ b/lib/ios/Ldk.swift @@ -618,14 +618,15 @@ class Ldk: NSObject { // MARK: Update methods @objc - func updateFees(_ anchorChannelFee: NSInteger, nonAnchorChannelFee: NSInteger, channelCloseMinimum: NSInteger, minAllowedAnchorChannelRemoteFee: NSInteger, onChainSweep: NSInteger, minAllowedNonAnchorChannelRemoteFee: NSInteger, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { + func updateFees(_ anchorChannelFee: NSInteger, nonAnchorChannelFee: NSInteger, channelCloseMinimum: NSInteger, minAllowedAnchorChannelRemoteFee: NSInteger, onChainSweep: NSInteger, minAllowedNonAnchorChannelRemoteFee: NSInteger, outputSpendingFee: NSInteger, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { feeEstimator.update( anchorChannelFee: UInt32(anchorChannelFee), nonAnchorChannelFee: UInt32(nonAnchorChannelFee), channelCloseMinimum: UInt32(channelCloseMinimum), minAllowedAnchorChannelRemoteFee: UInt32(minAllowedAnchorChannelRemoteFee), onChainSweep: UInt32(onChainSweep), - minAllowedNonAnchorChannelRemoteFee: UInt32(minAllowedNonAnchorChannelRemoteFee) + minAllowedNonAnchorChannelRemoteFee: UInt32(minAllowedNonAnchorChannelRemoteFee), + outputSpendingFee: UInt32(outputSpendingFee) ) return handleResolve(resolve, .fees_updated) } diff --git a/lib/src/ldk.ts b/lib/src/ldk.ts index 62d408cd..6fae8efa 100644 --- a/lib/src/ldk.ts +++ b/lib/src/ldk.ts @@ -346,6 +346,7 @@ class LDK { minAllowedAnchorChannelRemoteFee, onChainSweep, minAllowedNonAnchorChannelRemoteFee, + outputSpendingFee, } = fees; try { const satsPerKw = 250; @@ -356,6 +357,7 @@ class LDK { minAllowedAnchorChannelRemoteFee * satsPerKw, onChainSweep * satsPerKw, minAllowedNonAnchorChannelRemoteFee * satsPerKw, + outputSpendingFee * satsPerKw, ); this.writeDebugToLog('updateFees', fees); return ok(res); diff --git a/lib/src/lightning-manager.ts b/lib/src/lightning-manager.ts index cbc1a80f..564718c8 100644 --- a/lib/src/lightning-manager.ts +++ b/lib/src/lightning-manager.ts @@ -140,6 +140,7 @@ class LightningManager { minAllowedAnchorChannelRemoteFee: 5, minAllowedNonAnchorChannelRemoteFee: 5, onChainSweep: 5, + outputSpendingFee: 5, }); broadcastTransaction: TBroadcastTransaction = async (): Promise => {}; lspLogEvent: TLspLogEvent | undefined; diff --git a/lib/src/utils/types.ts b/lib/src/utils/types.ts index c43dae07..43be0b68 100644 --- a/lib/src/utils/types.ts +++ b/lib/src/utils/types.ts @@ -252,6 +252,7 @@ export type TFeeUpdateReq = { minAllowedAnchorChannelRemoteFee: number; onChainSweep: number; minAllowedNonAnchorChannelRemoteFee: number; + outputSpendingFee: number; }; export type TPeer = { From 0e8d83e90814d83c6819bc897b2f308e9cd4a5da Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 28 Nov 2024 10:56:50 +0200 Subject: [PATCH 2/4] fix: handle output spending fee --- .../src/main/java/com/reactnativeldk/LdkModule.kt | 4 ++-- .../com/reactnativeldk/classes/LdkFeeEstimator.kt | 9 ++++----- lib/ios/Classes/LdkFeeEstimator.swift | 15 ++++++++------- lib/ios/Ldk.m | 1 + lib/ios/Ldk.swift | 5 +++-- lib/src/ldk.ts | 2 ++ lib/src/lightning-manager.ts | 1 + lib/src/utils/types.ts | 1 + 8 files changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt b/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt index 51dcc560..a74c47ea 100644 --- a/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt +++ b/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt @@ -592,8 +592,8 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod //MARK: Update methods @ReactMethod - fun updateFees(anchorChannelFee: Double, nonAnchorChannelFee: Double, channelCloseMinimum: Double, minAllowedAnchorChannelRemoteFee: Double, onChainSweep: Double, minAllowedNonAnchorChannelRemoteFee: Double, promise: Promise) { - feeEstimator.update(anchorChannelFee.toInt(), nonAnchorChannelFee.toInt(), channelCloseMinimum.toInt(), minAllowedAnchorChannelRemoteFee.toInt(), onChainSweep.toInt(), minAllowedNonAnchorChannelRemoteFee.toInt()) + fun updateFees(anchorChannelFee: Double, nonAnchorChannelFee: Double, channelCloseMinimum: Double, minAllowedAnchorChannelRemoteFee: Double, onChainSweep: Double, minAllowedNonAnchorChannelRemoteFee: Double, outputSpendingFee: Double, promise: Promise) { + feeEstimator.update(anchorChannelFee.toInt(), nonAnchorChannelFee.toInt(), channelCloseMinimum.toInt(), minAllowedAnchorChannelRemoteFee.toInt(), onChainSweep.toInt(), minAllowedNonAnchorChannelRemoteFee.toInt(), outputSpendingFee.toInt()) handleResolve(promise, LdkCallbackResponses.fees_updated) } diff --git a/lib/android/src/main/java/com/reactnativeldk/classes/LdkFeeEstimator.kt b/lib/android/src/main/java/com/reactnativeldk/classes/LdkFeeEstimator.kt index 9c7b1f98..e68245eb 100644 --- a/lib/android/src/main/java/com/reactnativeldk/classes/LdkFeeEstimator.kt +++ b/lib/android/src/main/java/com/reactnativeldk/classes/LdkFeeEstimator.kt @@ -11,14 +11,16 @@ class LdkFeeEstimator { var minAllowedAnchorChannelRemoteFee: Int = 0 var onChainSweep: Int = 0 var minAllowedNonAnchorChannelRemoteFee: Int = 0 + var outputSpendingFee: Int = 0 - fun update(anchorChannelFee: Int, nonAnchorChannelFee: Int, channelCloseMinimum: Int, minAllowedAnchorChannelRemoteFee: Int, onChainSweep: Int, minAllowedNonAnchorChannelRemoteFee: Int) { + fun update(anchorChannelFee: Int, nonAnchorChannelFee: Int, channelCloseMinimum: Int, minAllowedAnchorChannelRemoteFee: Int, onChainSweep: Int, minAllowedNonAnchorChannelRemoteFee: Int, outputSpendingFee: Int) { this.anchorChannelFee = anchorChannelFee this.nonAnchorChannelFee = nonAnchorChannelFee this.channelCloseMinimum = channelCloseMinimum this.minAllowedAnchorChannelRemoteFee = minAllowedAnchorChannelRemoteFee this.onChainSweep = onChainSweep this.minAllowedNonAnchorChannelRemoteFee = minAllowedNonAnchorChannelRemoteFee + this.outputSpendingFee = outputSpendingFee LdkEventEmitter.send(EventTypes.native_log, "Fee estimator updated") } @@ -31,10 +33,7 @@ class LdkFeeEstimator { ConfirmationTarget.LDKConfirmationTarget_MinAllowedAnchorChannelRemoteFee -> minAllowedAnchorChannelRemoteFee ConfirmationTarget.LDKConfirmationTarget_OnChainSweep -> onChainSweep ConfirmationTarget.LDKConfirmationTarget_MinAllowedNonAnchorChannelRemoteFee -> minAllowedNonAnchorChannelRemoteFee - else -> { - LdkEventEmitter.send(EventTypes.native_log, "ERROR: New ConfirmationTarget added. Update LdkFeeEstimator.") - return@new_impl 0 - } + ConfirmationTarget.LDKConfirmationTarget_OutputSpendingFee -> outputSpendingFee } } } diff --git a/lib/ios/Classes/LdkFeeEstimator.swift b/lib/ios/Classes/LdkFeeEstimator.swift index c19cad67..2e8c0f23 100644 --- a/lib/ios/Classes/LdkFeeEstimator.swift +++ b/lib/ios/Classes/LdkFeeEstimator.swift @@ -15,21 +15,23 @@ class LdkFeeEstimator: FeeEstimator { private var minAllowedAnchorChannelRemoteFee: UInt32 = 0 private var onChainSweep: UInt32 = 0 private var minAllowedNonAnchorChannelRemoteFee: UInt32 = 0 - - func update(anchorChannelFee: UInt32, nonAnchorChannelFee: UInt32, channelCloseMinimum: UInt32, minAllowedAnchorChannelRemoteFee: UInt32, onChainSweep: UInt32, minAllowedNonAnchorChannelRemoteFee: UInt32) { + private var outputSpendingFee: UInt32 = 0 + + func update(anchorChannelFee: UInt32, nonAnchorChannelFee: UInt32, channelCloseMinimum: UInt32, minAllowedAnchorChannelRemoteFee: UInt32, onChainSweep: UInt32, minAllowedNonAnchorChannelRemoteFee: UInt32, outputSpendingFee: UInt32) { self.anchorChannelFee = anchorChannelFee self.nonAnchorChannelFee = nonAnchorChannelFee self.channelCloseMinimum = channelCloseMinimum self.minAllowedAnchorChannelRemoteFee = minAllowedAnchorChannelRemoteFee self.onChainSweep = onChainSweep self.minAllowedNonAnchorChannelRemoteFee = minAllowedNonAnchorChannelRemoteFee + self.outputSpendingFee = outputSpendingFee LdkEventEmitter.shared.send(withEvent: .native_log, body: "Fee estimator updated") } - + override func getEstSatPer1000Weight(confirmationTarget: Bindings.ConfirmationTarget) -> UInt32 { let target = confirmationTarget - + switch target { case .AnchorChannelFee: return anchorChannelFee @@ -43,9 +45,8 @@ class LdkFeeEstimator: FeeEstimator { return onChainSweep case .MinAllowedNonAnchorChannelRemoteFee: return minAllowedNonAnchorChannelRemoteFee - @unknown default: - LdkEventEmitter.shared.send(withEvent: .native_log, body: "ERROR: New ConfirmationTarget added. Update LdkFeeEstimator.") - return 0 + case .OutputSpendingFee: + return outputSpendingFee } } } diff --git a/lib/ios/Ldk.m b/lib/ios/Ldk.m index 56114719..52929e84 100644 --- a/lib/ios/Ldk.m +++ b/lib/ios/Ldk.m @@ -51,6 +51,7 @@ @interface RCT_EXTERN_MODULE(Ldk, NSObject) minAllowedAnchorChannelRemoteFee:(NSInteger *)minAllowedAnchorChannelRemoteFee onChainSweep:(NSInteger *)onChainSweep minAllowedNonAnchorChannelRemoteFee:(NSInteger *)minAllowedNonAnchorChannelRemoteFee + outputSpendingFee:(NSInteger *)outputSpendingFee resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) RCT_EXTERN_METHOD(setLogLevel:(NSString *)level diff --git a/lib/ios/Ldk.swift b/lib/ios/Ldk.swift index 7cb441c1..da5e7fda 100644 --- a/lib/ios/Ldk.swift +++ b/lib/ios/Ldk.swift @@ -618,14 +618,15 @@ class Ldk: NSObject { // MARK: Update methods @objc - func updateFees(_ anchorChannelFee: NSInteger, nonAnchorChannelFee: NSInteger, channelCloseMinimum: NSInteger, minAllowedAnchorChannelRemoteFee: NSInteger, onChainSweep: NSInteger, minAllowedNonAnchorChannelRemoteFee: NSInteger, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { + func updateFees(_ anchorChannelFee: NSInteger, nonAnchorChannelFee: NSInteger, channelCloseMinimum: NSInteger, minAllowedAnchorChannelRemoteFee: NSInteger, onChainSweep: NSInteger, minAllowedNonAnchorChannelRemoteFee: NSInteger, outputSpendingFee: NSInteger, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { feeEstimator.update( anchorChannelFee: UInt32(anchorChannelFee), nonAnchorChannelFee: UInt32(nonAnchorChannelFee), channelCloseMinimum: UInt32(channelCloseMinimum), minAllowedAnchorChannelRemoteFee: UInt32(minAllowedAnchorChannelRemoteFee), onChainSweep: UInt32(onChainSweep), - minAllowedNonAnchorChannelRemoteFee: UInt32(minAllowedNonAnchorChannelRemoteFee) + minAllowedNonAnchorChannelRemoteFee: UInt32(minAllowedNonAnchorChannelRemoteFee), + outputSpendingFee: UInt32(outputSpendingFee) ) return handleResolve(resolve, .fees_updated) } diff --git a/lib/src/ldk.ts b/lib/src/ldk.ts index 62d408cd..6fae8efa 100644 --- a/lib/src/ldk.ts +++ b/lib/src/ldk.ts @@ -346,6 +346,7 @@ class LDK { minAllowedAnchorChannelRemoteFee, onChainSweep, minAllowedNonAnchorChannelRemoteFee, + outputSpendingFee, } = fees; try { const satsPerKw = 250; @@ -356,6 +357,7 @@ class LDK { minAllowedAnchorChannelRemoteFee * satsPerKw, onChainSweep * satsPerKw, minAllowedNonAnchorChannelRemoteFee * satsPerKw, + outputSpendingFee * satsPerKw, ); this.writeDebugToLog('updateFees', fees); return ok(res); diff --git a/lib/src/lightning-manager.ts b/lib/src/lightning-manager.ts index cbc1a80f..564718c8 100644 --- a/lib/src/lightning-manager.ts +++ b/lib/src/lightning-manager.ts @@ -140,6 +140,7 @@ class LightningManager { minAllowedAnchorChannelRemoteFee: 5, minAllowedNonAnchorChannelRemoteFee: 5, onChainSweep: 5, + outputSpendingFee: 5, }); broadcastTransaction: TBroadcastTransaction = async (): Promise => {}; lspLogEvent: TLspLogEvent | undefined; diff --git a/lib/src/utils/types.ts b/lib/src/utils/types.ts index c43dae07..43be0b68 100644 --- a/lib/src/utils/types.ts +++ b/lib/src/utils/types.ts @@ -252,6 +252,7 @@ export type TFeeUpdateReq = { minAllowedAnchorChannelRemoteFee: number; onChainSweep: number; minAllowedNonAnchorChannelRemoteFee: number; + outputSpendingFee: number; }; export type TPeer = { From 7e251a575c0740082f57d2090570ceb09e3eb313 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 28 Nov 2024 11:31:01 +0200 Subject: [PATCH 3/4] chore: update podfile --- example/ios/Podfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 5850b302..580479b1 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -316,7 +316,7 @@ PODS: - React-jsinspector (0.72.4) - React-logger (0.72.4): - glog - - react-native-ldk (0.0.151): + - react-native-ldk (0.0.152): - React - react-native-randombytes (3.6.1): - React-Core @@ -621,7 +621,7 @@ SPEC CHECKSUMS: React-jsiexecutor: c7f826e40fa9cab5d37cab6130b1af237332b594 React-jsinspector: aaed4cf551c4a1c98092436518c2d267b13a673f React-logger: da1ebe05ae06eb6db4b162202faeafac4b435e77 - react-native-ldk: a7e71785237dd3d12dc52b4287abd88c865f5262 + react-native-ldk: 1d25080cfadac349eab355725da66de140fbc7a8 react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846 react-native-tcp-socket: c1b7297619616b4c9caae6889bcb0aba78086989 React-NativeModulesApple: edb5ace14f73f4969df6e7b1f3e41bef0012740f @@ -650,4 +650,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 940323d07de591a59a2ab39fc0ef7b7d6dc89c0d -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 From 4201c97bc31489c44a4320d07470b124d5c936eb Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 28 Nov 2024 11:36:57 +0200 Subject: [PATCH 4/4] tests: added outputSpendingFee to test fees --- example/ldk/index.ts | 1 + example/tests/eclair.ts | 1 + example/tests/unit.ts | 2 ++ example/tests/utils/test-profile.ts | 1 + lib/src/lightning-manager.ts | 1 - 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/example/ldk/index.ts b/example/ldk/index.ts index 544bb221..019f5341 100644 --- a/example/ldk/index.ts +++ b/example/ldk/index.ts @@ -134,6 +134,7 @@ export const setupLdk = async ( maxAllowedNonAnchorChannelRemoteFee: 10, onChainSweep: 10, minAllowedNonAnchorChannelRemoteFee: 10, + outputSpendingFee: 10, }), getTransactionData, getTransactionPosition, diff --git a/example/tests/eclair.ts b/example/tests/eclair.ts index ab356c15..ca7a6ea0 100644 --- a/example/tests/eclair.ts +++ b/example/tests/eclair.ts @@ -112,6 +112,7 @@ describe('Eclair', function () { anchorChannelFee: 10, nonAnchorChannelFee: 20, channelCloseMinimum: 5, + outputSpendingFee: 10, }); }, }); diff --git a/example/tests/unit.ts b/example/tests/unit.ts index 87c5a140..d01c85aa 100644 --- a/example/tests/unit.ts +++ b/example/tests/unit.ts @@ -71,6 +71,7 @@ describe('Unit', function () { minAllowedAnchorChannelRemoteFee: 5, minAllowedNonAnchorChannelRemoteFee: 5, onChainSweep: 5, + outputSpendingFee: 5, }); }, getTransactionData: async () => ({ @@ -214,6 +215,7 @@ describe('Unit', function () { minAllowedAnchorChannelRemoteFee: 5, minAllowedNonAnchorChannelRemoteFee: 5, onChainSweep: 5, + outputSpendingFee: 5, }); }, getTransactionData: async () => ({ diff --git a/example/tests/utils/test-profile.ts b/example/tests/utils/test-profile.ts index 4f0cc83a..42babd87 100644 --- a/example/tests/utils/test-profile.ts +++ b/example/tests/utils/test-profile.ts @@ -82,6 +82,7 @@ export default class TestProfile { anchorChannelFee: 2, nonAnchorChannelFee: 3, channelCloseMinimum: 1, + outputSpendingFee: 5, }), getTransactionData: this.getTransactionData, getTransactionPosition: this.getTransactionPosition, diff --git a/lib/src/lightning-manager.ts b/lib/src/lightning-manager.ts index 564718c8..1396acb0 100644 --- a/lib/src/lightning-manager.ts +++ b/lib/src/lightning-manager.ts @@ -2466,7 +2466,6 @@ class LightningManager { EEventTypes.channel_manager_channel_closed, (eventRes: TChannelManagerChannelClosed) => { if (eventRes.channel_id === res.value) { - clearTimeout(timeout); if (eventRes.peer_message) { resolve(err(eventRes.peer_message));