@@ -1575,6 +1575,12 @@ pub(super) struct FundingScope {
15751575 channel_value_satoshis: u64,
15761576}
15771577
1578+ impl FundingScope {
1579+ pub fn get_value_satoshis(&self) -> u64 {
1580+ self.channel_value_satoshis
1581+ }
1582+ }
1583+
15781584/// Contains everything about the channel including state, and various flags.
15791585pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
15801586 config: LegacyChannelConfig,
@@ -3169,27 +3175,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
31693175 pub fn get_holder_htlc_maximum_msat(&self, funding: &FundingScope) -> Option<u64> {
31703176 self.get_htlc_maximum_msat(funding, self.holder_max_htlc_value_in_flight_msat)
31713177 }
3172- }
3173-
3174- impl<SP: Deref> FundedChannel<SP>
3175- where
3176- SP::Target: SignerProvider,
3177- <SP::Target as SignerProvider>::EcdsaSigner: EcdsaChannelSigner,
3178- {
3179- /// Allowed in any state (including after shutdown)
3180- pub fn get_announced_htlc_max_msat(&self) -> u64 {
3181- return cmp::min(
3182- // Upper bound by capacity. We make it a bit less than full capacity to prevent attempts
3183- // to use full capacity. This is an effort to reduce routing failures, because in many cases
3184- // channel might have been used to route very small values (either by honest users or as DoS).
3185- self.funding.channel_value_satoshis * 1000 * 9 / 10,
3186-
3187- self.context.counterparty_max_htlc_value_in_flight_msat
3188- );
3189- }
3190- }
31913178
3192- impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
31933179 /// Allowed in any state (including after shutdown)
31943180 pub fn get_counterparty_htlc_minimum_msat(&self) -> u64 {
31953181 self.counterparty_htlc_minimum_msat
@@ -3209,15 +3195,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
32093195 )
32103196 })
32113197 }
3212- }
32133198
3214- impl FundingScope {
3215- pub fn get_value_satoshis(&self) -> u64 {
3216- self.channel_value_satoshis
3217- }
3218- }
3219-
3220- impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
32213199 pub fn get_fee_proportional_millionths(&self) -> u32 {
32223200 self.config.options.forwarding_fee_proportional_millionths
32233201 }
@@ -8607,6 +8585,8 @@ impl<SP: Deref> FundedChannel<SP> where
86078585 Ok((shutdown, monitor_update, dropped_outbound_htlcs))
86088586 }
86098587
8588+ // Miscellaneous utilities
8589+
86108590 pub fn inflight_htlc_sources(&self) -> impl Iterator<Item=(&HTLCSource, &PaymentHash)> {
86118591 self.context.holding_cell_htlc_updates.iter()
86128592 .flat_map(|htlc_update| {
@@ -8618,6 +8598,17 @@ impl<SP: Deref> FundedChannel<SP> where
86188598 })
86198599 .chain(self.context.pending_outbound_htlcs.iter().map(|htlc| (&htlc.source, &htlc.payment_hash)))
86208600 }
8601+
8602+ pub fn get_announced_htlc_max_msat(&self) -> u64 {
8603+ return cmp::min(
8604+ // Upper bound by capacity. We make it a bit less than full capacity to prevent attempts
8605+ // to use full capacity. This is an effort to reduce routing failures, because in many cases
8606+ // channel might have been used to route very small values (either by honest users or as DoS).
8607+ self.funding.channel_value_satoshis * 1000 * 9 / 10,
8608+
8609+ self.context.counterparty_max_htlc_value_in_flight_msat
8610+ );
8611+ }
86218612}
86228613
86238614/// A not-yet-funded outbound (from holder) channel using V1 channel establishment.
0 commit comments