@@ -9,41 +9,47 @@ import Foundation
99import LightningDevKit
1010
1111class LdkFeeEstimator : FeeEstimator {
12- private var high : UInt32 = 0
13- private var normal : UInt32 = 0
14- private var low : UInt32 = 0
15- private var mempoolMinimum : UInt32 = 0
12+ private var anchorChannelFee : UInt32 = 0
13+ private var nonAnchorChannelFee : UInt32 = 0
14+ private var channelCloseMinimum : UInt32 = 0
15+ private var minAllowedAnchorChannelRemoteFee : UInt32 = 0
16+ private var maxAllowedNonAnchorChannelRemoteFee : UInt32 = 0
17+ private var onChainSweep : UInt32 = 0
18+ private var minAllowedNonAnchorChannelRemoteFee : UInt32 = 0
1619
17- func update( high: UInt32 , normal: UInt32 , low: UInt32 , mempoolMinimum: UInt32 ) {
18- self . high = high
19- self . normal = normal
20- self . low = low
21- self . mempoolMinimum = mempoolMinimum
20+ func update( anchorChannelFee: UInt32 , nonAnchorChannelFee: UInt32 , channelCloseMinimum: UInt32 , minAllowedAnchorChannelRemoteFee: UInt32 , maxAllowedNonAnchorChannelRemoteFee: UInt32 , onChainSweep: UInt32 , minAllowedNonAnchorChannelRemoteFee: UInt32 ) {
21+ self . anchorChannelFee = anchorChannelFee
22+ self . nonAnchorChannelFee = nonAnchorChannelFee
23+ self . channelCloseMinimum = channelCloseMinimum
24+ self . minAllowedAnchorChannelRemoteFee = minAllowedAnchorChannelRemoteFee
25+ self . maxAllowedNonAnchorChannelRemoteFee = maxAllowedNonAnchorChannelRemoteFee
26+ self . onChainSweep = onChainSweep
27+ self . minAllowedNonAnchorChannelRemoteFee = minAllowedNonAnchorChannelRemoteFee
2228
2329 LdkEventEmitter . shared. send ( withEvent: . native_log, body: " Fee estimator updated " )
2430 }
2531
2632 override func getEstSatPer1000Weight( confirmationTarget: Bindings . ConfirmationTarget ) -> UInt32 {
2733 let target = confirmationTarget
2834
29- if case ConfirmationTarget . HighPriority = target {
30- return high
35+ switch target {
36+ case . AnchorChannelFee:
37+ return anchorChannelFee
38+ case . NonAnchorChannelFee:
39+ return nonAnchorChannelFee
40+ case . ChannelCloseMinimum:
41+ return channelCloseMinimum
42+ case . MinAllowedAnchorChannelRemoteFee:
43+ return minAllowedAnchorChannelRemoteFee
44+ case . MaxAllowedNonAnchorChannelRemoteFee:
45+ return maxAllowedNonAnchorChannelRemoteFee
46+ case . OnChainSweep:
47+ return onChainSweep
48+ case . MinAllowedNonAnchorChannelRemoteFee:
49+ return minAllowedNonAnchorChannelRemoteFee
50+ @unknown default :
51+ LdkEventEmitter . shared. send ( withEvent: . native_log, body: " ERROR: New ConfirmationTarget added. Update LdkFeeEstimator. " )
52+ return 0
3153 }
32-
33- if case ConfirmationTarget . Normal = target {
34- return normal
35- }
36-
37- if case ConfirmationTarget . Background = target {
38- return low
39- }
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-
47- return normal
4854 }
4955}
0 commit comments