@@ -5,39 +5,40 @@ import org.ldk.enums.ConfirmationTarget
55import org.ldk.structs.FeeEstimator
66
77class LdkFeeEstimator {
8- var high: Int = 0
9- var normal: Int = 0
10- var low: Int = 0
11- var mempoolMinimum: Int = 0
12- var feeEstimator = FeeEstimator .new_impl { target: ConfirmationTarget ->
13- if (target.equals(ConfirmationTarget .LDKConfirmationTarget_HighPriority )) {
14- return @new_impl high
15- }
16-
17- if (target.equals(ConfirmationTarget .LDKConfirmationTarget_Normal )) {
18- return @new_impl normal
19- }
20-
21- if (target.equals(ConfirmationTarget .LDKConfirmationTarget_Background )) {
22- return @new_impl low
23- }
24-
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." )
8+ var anchorChannelFee: Int = 0
9+ var nonAnchorChannelFee: Int = 0
10+ var channelCloseMinimum: Int = 0
11+ var minAllowedAnchorChannelRemoteFee: Int = 0
12+ var maxAllowedNonAnchorChannelRemoteFee: Int = 0
13+ var onChainSweep: Int = 0
14+ var minAllowedNonAnchorChannelRemoteFee: Int = 0
15+
16+ fun update (anchorChannelFee : Int , nonAnchorChannelFee : Int , channelCloseMinimum : Int , minAllowedAnchorChannelRemoteFee : Int , maxAllowedNonAnchorChannelRemoteFee : Int , onChainSweep : Int , minAllowedNonAnchorChannelRemoteFee : Int ) {
17+ this .anchorChannelFee = anchorChannelFee
18+ this .nonAnchorChannelFee = nonAnchorChannelFee
19+ this .channelCloseMinimum = channelCloseMinimum
20+ this .minAllowedAnchorChannelRemoteFee = minAllowedAnchorChannelRemoteFee
21+ this .maxAllowedNonAnchorChannelRemoteFee = maxAllowedNonAnchorChannelRemoteFee
22+ this .onChainSweep = onChainSweep
23+ this .minAllowedNonAnchorChannelRemoteFee = minAllowedNonAnchorChannelRemoteFee
3024
31- return @new_impl normal
25+ LdkEventEmitter .send( EventTypes .native_log, " Fee estimator updated " )
3226 }
3327
34- fun update (high : Int , normal : Int , low : Int , mempoolMinimum : Int ) {
35- this .high = high
36- this .normal = normal
37- this .low = low
38- this .mempoolMinimum = mempoolMinimum
39-
40- LdkEventEmitter .send(EventTypes .native_log, " Fee estimator updated" )
28+ var feeEstimator = FeeEstimator .new_impl { target: ConfirmationTarget ->
29+ return @new_impl when (target) {
30+ ConfirmationTarget .LDKConfirmationTarget_AnchorChannelFee -> anchorChannelFee
31+ ConfirmationTarget .LDKConfirmationTarget_NonAnchorChannelFee -> nonAnchorChannelFee
32+ ConfirmationTarget .LDKConfirmationTarget_ChannelCloseMinimum -> channelCloseMinimum
33+ ConfirmationTarget .LDKConfirmationTarget_MinAllowedAnchorChannelRemoteFee -> minAllowedAnchorChannelRemoteFee
34+ ConfirmationTarget .LDKConfirmationTarget_MaxAllowedNonAnchorChannelRemoteFee -> maxAllowedNonAnchorChannelRemoteFee
35+ ConfirmationTarget .LDKConfirmationTarget_OnChainSweep -> onChainSweep
36+ ConfirmationTarget .LDKConfirmationTarget_MinAllowedNonAnchorChannelRemoteFee -> minAllowedNonAnchorChannelRemoteFee
37+ else -> {
38+ LdkEventEmitter .send(EventTypes .native_log, " ERROR: New ConfirmationTarget added. Update LdkFeeEstimator." )
39+ return @new_impl 0
40+ }
41+ }
4142 }
4243}
4344
0 commit comments