@@ -25,69 +25,59 @@ val ChannelDetails.amountOnClose: ULong
2525 }
2626
2727/* * Returns only `open` channels, filtering out pending ones. */
28- fun List<ChannelDetails>.filterOpen (): List <ChannelDetails > {
29- return this .filter { it.isChannelReady }
30- }
28+ fun List<ChannelDetails>.filterOpen (): List <ChannelDetails > = this .filter { it.isChannelReady }
3129
3230/* * Returns only `pending` channels. */
33- fun List<ChannelDetails>.filterPending (): List <ChannelDetails > {
34- return this .filterNot { it.isChannelReady }
35- }
31+ fun List<ChannelDetails>.filterPending (): List <ChannelDetails > = this .filterNot { it.isChannelReady }
3632
3733/* * Returns a limit in sats as close as possible to the HTLC limit we can currently send. */
38- fun List<ChannelDetails>?.totalNextOutboundHtlcLimitSats (): ULong {
39- return this ?.filter { it.isUsable }
40- ?.sumOf { it.nextOutboundHtlcLimitMsat / 1000u }
41- ? : 0u
42- }
34+ fun List<ChannelDetails>?.totalNextOutboundHtlcLimitSats (): ULong = this ?.filter { it.isUsable }
35+ ?.sumOf { it.nextOutboundHtlcLimitMsat / 1000u }
36+ ? : 0u
4337
4438/* * Calculates the total remote balance (inbound capacity) from open channels. */
45- fun List<ChannelDetails>.calculateRemoteBalance (): ULong {
46- return this
47- .filterOpen()
48- .sumOf { it.inboundCapacityMsat / 1000u }
49- }
39+ fun List<ChannelDetails>.calculateRemoteBalance (): ULong = this
40+ .filterOpen()
41+ .sumOf { it.inboundCapacityMsat / 1000u }
5042
51- fun createChannelDetails (): ChannelDetails {
52- return ChannelDetails (
53- channelId = " channelId" ,
54- counterpartyNodeId = " counterpartyNodeId" ,
55- fundingTxo = null ,
56- shortChannelId = null ,
57- outboundScidAlias = null ,
58- inboundScidAlias = null ,
59- channelValueSats = 0u ,
60- unspendablePunishmentReserve = null ,
61- userChannelId = " 0" ,
62- feerateSatPer1000Weight = 0u ,
63- outboundCapacityMsat = 0u ,
64- inboundCapacityMsat = 0u ,
65- confirmationsRequired = null ,
66- confirmations = null ,
67- isOutbound = false ,
68- isChannelReady = false ,
69- isUsable = false ,
70- isAnnounced = false ,
71- cltvExpiryDelta = null ,
72- counterpartyUnspendablePunishmentReserve = 0u ,
73- counterpartyOutboundHtlcMinimumMsat = null ,
74- counterpartyOutboundHtlcMaximumMsat = null ,
75- counterpartyForwardingInfoFeeBaseMsat = null ,
76- counterpartyForwardingInfoFeeProportionalMillionths = null ,
77- counterpartyForwardingInfoCltvExpiryDelta = null ,
78- nextOutboundHtlcLimitMsat = 0u ,
79- nextOutboundHtlcMinimumMsat = 0u ,
80- forceCloseSpendDelay = null ,
81- inboundHtlcMinimumMsat = 0u ,
82- inboundHtlcMaximumMsat = null ,
83- claimableOnCloseSats = 0u ,
84- config = ChannelConfig (
85- forwardingFeeProportionalMillionths = 0u ,
86- forwardingFeeBaseMsat = 0u ,
87- cltvExpiryDelta = 0u ,
88- maxDustHtlcExposure = MaxDustHtlcExposure .FixedLimit (limitMsat = 0u ),
89- forceCloseAvoidanceMaxFeeSatoshis = 0u ,
90- acceptUnderpayingHtlcs = false ,
91- ),
92- )
93- }
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