Skip to content
This repository was archived by the owner on Feb 9, 2026. It is now read-only.

Commit 6f053a4

Browse files
authored
Merge pull request #168 from synonymdev/fee-min-fix
fix: new fee type (mempoolMinimum)
2 parents 38b9f9f + a9ab605 commit 6f053a4

8 files changed

Lines changed: 29 additions & 9 deletions

File tree

lib/android/src/main/java/com/reactnativeldk/LdkModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
512512
//MARK: Update methods
513513

514514
@ReactMethod
515-
fun updateFees(high: Double, normal: Double, low: Double, promise: Promise) {
516-
feeEstimator.update(high.toInt(), normal.toInt(), low.toInt())
515+
fun updateFees(high: Double, normal: Double, low: Double, mempoolMinimum: Double, promise: Promise) {
516+
feeEstimator.update(high.toInt(), normal.toInt(), low.toInt(), mempoolMinimum.toInt())
517517
handleResolve(promise, LdkCallbackResponses.fees_updated)
518518
}
519519

lib/android/src/main/java/com/reactnativeldk/classes/LdkFeeEstimator.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class LdkFeeEstimator {
88
var high: Int = 0
99
var normal: Int = 0
1010
var low: Int = 0
11+
var mempoolMinimum: Int = 0
1112
var feeEstimator = FeeEstimator.new_impl { target: ConfirmationTarget ->
1213
if (target.equals(ConfirmationTarget.LDKConfirmationTarget_HighPriority)) {
1314
return@new_impl high
@@ -21,13 +22,20 @@ class LdkFeeEstimator {
2122
return@new_impl low
2223
}
2324

25+
if (target.equals(ConfirmationTarget.LDKConfirmationTarget_MempoolMinimum)) {
26+
return@new_impl mempoolMinimum
27+
}
28+
29+
LdkEventEmitter.send(EventTypes.native_log, "WARNING: New ConfirmationTarget added. Update LdkFeeEstimator.")
30+
2431
return@new_impl normal
2532
}
2633

27-
fun update(high: Int, normal: Int, low: Int) {
34+
fun update(high: Int, normal: Int, low: Int, mempoolMinimum: Int) {
2835
this.high = high
2936
this.normal = normal
3037
this.low = low
38+
this.mempoolMinimum = mempoolMinimum
3139

3240
LdkEventEmitter.send(EventTypes.native_log, "Fee estimator updated")
3341
}

lib/ios/Classes/LdkFeeEstimator.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ class LdkFeeEstimator: FeeEstimator {
1212
private var high: UInt32 = 0
1313
private var normal: UInt32 = 0
1414
private var low: UInt32 = 0
15+
private var mempoolMinimum: UInt32 = 0
1516

16-
func update(high: UInt32, normal: UInt32, low: UInt32) {
17+
func update(high: UInt32, normal: UInt32, low: UInt32, mempoolMinimum: UInt32) {
1718
self.high = high
1819
self.normal = normal
1920
self.low = low
20-
21+
self.mempoolMinimum = mempoolMinimum
22+
2123
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Fee estimator updated")
2224
}
2325

@@ -35,7 +37,13 @@ class LdkFeeEstimator: FeeEstimator {
3537
if case ConfirmationTarget.Background = target {
3638
return low
3739
}
38-
40+
41+
if case ConfirmationTarget.MempoolMinimum = target {
42+
return mempoolMinimum
43+
}
44+
45+
LdkEventEmitter.shared.send(withEvent: .native_log, body: "WARNING: New ConfirmationTarget added. Update LdkFeeEstimator.")
46+
3947
return normal
4048
}
4149
}

lib/ios/Ldk.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ @interface RCT_EXTERN_MODULE(Ldk, NSObject)
3939
RCT_EXTERN_METHOD(updateFees:(NSInteger *)high
4040
normal:(NSInteger *)normal
4141
low:(NSInteger *)low
42+
mempoolMinimum:(NSInteger *)mempoolMinimum
4243
resolve:(RCTPromiseResolveBlock)resolve
4344
reject:(RCTPromiseRejectBlock)reject)
4445
RCT_EXTERN_METHOD(setLogLevel:(NSString *)level

lib/ios/Ldk.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ class Ldk: NSObject {
526526
//MARK: Update methods
527527

528528
@objc
529-
func updateFees(_ high: NSInteger, normal: NSInteger, low: NSInteger, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
530-
feeEstimator.update(high: UInt32(high), normal: UInt32(normal), low: UInt32(low))
529+
func updateFees(_ high: NSInteger, normal: NSInteger, low: NSInteger, mempoolMinimum: NSInteger, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
530+
feeEstimator.update(high: UInt32(high), normal: UInt32(normal), low: UInt32(low), mempoolMinimum: UInt32(mempoolMinimum))
531531
return handleResolve(resolve, .fees_updated)
532532
}
533533

lib/src/ldk.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,14 @@ class LDK {
304304
* @returns {Promise<Err<unknown> | Ok<Ok<string> | Err<string>>>}
305305
*/
306306
async updateFees(fees: TFeeUpdateReq): Promise<Result<string>> {
307-
const { highPriority, normal, background } = fees;
307+
const { highPriority, normal, background, mempoolMinimum } = fees;
308308
try {
309309
const satsPerKw = 250;
310310
const res = await NativeLDK.updateFees(
311311
highPriority * satsPerKw,
312312
normal * satsPerKw,
313313
background * satsPerKw,
314+
mempoolMinimum * satsPerKw,
314315
);
315316
this.writeDebugToLog('updateFees', fees);
316317
return ok(res);

lib/src/lightning-manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class LightningManager {
127127
highPriority: 15,
128128
normal: 10,
129129
background: 5,
130+
mempoolMinimum: 1,
130131
});
131132
trustedZeroConfPeers: string[] = [];
132133
broadcastTransaction: TBroadcastTransaction = async (): Promise<any> => {};

lib/src/utils/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ export type TFeeUpdateReq = {
235235
highPriority: number;
236236
normal: number;
237237
background: number;
238+
mempoolMinimum: number;
238239
};
239240

240241
export type TPeer = {

0 commit comments

Comments
 (0)