@@ -15,76 +15,69 @@ import org.lightningdevkit.ldknode.MaxDustHtlcExposure
1515 * - our_reserve: Our reserve that we get back on close
1616 */
1717val ChannelDetails .amountOnClose: ULong
18+ @Suppress(" ForbiddenComment" )
1819 get() {
20+ // TODO: use channelDetails.claimableOnCloseSats
1921 val outboundCapacitySat = this .outboundCapacityMsat / 1000u
2022 val ourReserve = this .unspendablePunishmentReserve ? : 0u
2123
2224 return outboundCapacitySat + ourReserve
2325 }
2426
2527/* * Returns only `open` channels, filtering out pending ones. */
26- fun List<ChannelDetails>.filterOpen (): List <ChannelDetails > {
27- return this .filter { it.isChannelReady }
28- }
28+ fun List<ChannelDetails>.filterOpen (): List <ChannelDetails > = this .filter { it.isChannelReady }
2929
3030/* * Returns only `pending` channels. */
31- fun List<ChannelDetails>.filterPending (): List <ChannelDetails > {
32- return this .filterNot { it.isChannelReady }
33- }
31+ fun List<ChannelDetails>.filterPending (): List <ChannelDetails > = this .filterNot { it.isChannelReady }
3432
3533/* * Returns a limit in sats as close as possible to the HTLC limit we can currently send. */
36- fun List<ChannelDetails>?.totalNextOutboundHtlcLimitSats (): ULong {
37- return this ?.filter { it.isUsable }
38- ?.sumOf { it.nextOutboundHtlcLimitMsat / 1000u }
39- ? : 0u
40- }
34+ fun List<ChannelDetails>?.totalNextOutboundHtlcLimitSats (): ULong = this ?.filter { it.isUsable }
35+ ?.sumOf { it.nextOutboundHtlcLimitMsat / 1000u }
36+ ? : 0u
4137
4238/* * Calculates the total remote balance (inbound capacity) from open channels. */
43- fun List<ChannelDetails>.calculateRemoteBalance (): ULong {
44- return this
45- .filterOpen()
46- .sumOf { it.inboundCapacityMsat / 1000u }
47- }
39+ fun List<ChannelDetails>.calculateRemoteBalance (): ULong = this
40+ .filterOpen()
41+ .sumOf { it.inboundCapacityMsat / 1000u }
4842
49- fun createChannelDetails (): ChannelDetails {
50- return ChannelDetails (
51- channelId = " channelId" ,
52- counterpartyNodeId = " counterpartyNodeId" ,
53- fundingTxo = null ,
54- shortChannelId = null ,
55- outboundScidAlias = null ,
56- inboundScidAlias = null ,
57- channelValueSats = 0u ,
58- unspendablePunishmentReserve = null ,
59- userChannelId = " 0" ,
60- feerateSatPer1000Weight = 0u ,
61- outboundCapacityMsat = 0u ,
62- inboundCapacityMsat = 0u ,
63- confirmationsRequired = null ,
64- confirmations = null ,
65- isOutbound = false ,
66- isChannelReady = false ,
67- isUsable = false ,
68- isAnnounced = false ,
69- cltvExpiryDelta = null ,
70- counterpartyUnspendablePunishmentReserve = 0u ,
71- counterpartyOutboundHtlcMinimumMsat = null ,
72- counterpartyOutboundHtlcMaximumMsat = null ,
73- counterpartyForwardingInfoFeeBaseMsat = null ,
74- counterpartyForwardingInfoFeeProportionalMillionths = null ,
75- counterpartyForwardingInfoCltvExpiryDelta = null ,
76- nextOutboundHtlcLimitMsat = 0u ,
77- nextOutboundHtlcMinimumMsat = 0u ,
78- forceCloseSpendDelay = null ,
79- inboundHtlcMinimumMsat = 0u ,
80- inboundHtlcMaximumMsat = null ,
81- config = ChannelConfig (
82- forwardingFeeProportionalMillionths = 0u ,
83- forwardingFeeBaseMsat = 0u ,
84- cltvExpiryDelta = 0u ,
85- maxDustHtlcExposure = MaxDustHtlcExposure .FixedLimit (limitMsat = 0u ),
86- forceCloseAvoidanceMaxFeeSatoshis = 0u ,
87- acceptUnderpayingHtlcs = false ,
88- ),
89- )
90- }
43+ fun createChannelDetails (): ChannelDetails = ChannelDetails (
44+ channelId = " channelId" ,
45+ counterpartyNodeId = " counterpartyNodeId" ,
46+ fundingTxo = null ,
47+ shortChannelId = null ,
48+ outboundScidAlias = null ,
49+ inboundScidAlias = null ,
50+ channelValueSats = 0u ,
51+ unspendablePunishmentReserve = null ,
52+ userChannelId = " 0" ,
53+ feerateSatPer1000Weight = 0u ,
54+ outboundCapacityMsat = 0u ,
55+ inboundCapacityMsat = 0u ,
56+ confirmationsRequired = null ,
57+ confirmations = null ,
58+ isOutbound = false ,
59+ isChannelReady = false ,
60+ isUsable = false ,
61+ isAnnounced = false ,
62+ cltvExpiryDelta = null ,
63+ counterpartyUnspendablePunishmentReserve = 0u ,
64+ counterpartyOutboundHtlcMinimumMsat = null ,
65+ counterpartyOutboundHtlcMaximumMsat = null ,
66+ counterpartyForwardingInfoFeeBaseMsat = null ,
67+ counterpartyForwardingInfoFeeProportionalMillionths = null ,
68+ counterpartyForwardingInfoCltvExpiryDelta = null ,
69+ nextOutboundHtlcLimitMsat = 0u ,
70+ nextOutboundHtlcMinimumMsat = 0u ,
71+ forceCloseSpendDelay = null ,
72+ inboundHtlcMinimumMsat = 0u ,
73+ inboundHtlcMaximumMsat = null ,
74+ claimableOnCloseSats = 0u ,
75+ config = ChannelConfig (
76+ forwardingFeeProportionalMillionths = 0u ,
77+ forwardingFeeBaseMsat = 0u ,
78+ cltvExpiryDelta = 0u ,
79+ maxDustHtlcExposure = MaxDustHtlcExposure .FixedLimit (limitMsat = 0u ),
80+ forceCloseAvoidanceMaxFeeSatoshis = 0u ,
81+ acceptUnderpayingHtlcs = false ,
82+ ),
83+ )
0 commit comments