Skip to content

Commit 1392fa4

Browse files
TheBlueMattdunxen
authored andcommitted
Explain how rounded millisat values are included in overall balance
1 parent 321a914 commit 1392fa4

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,25 +635,35 @@ pub enum Balance {
635635
/// [`Balance::MaybeTimeoutClaimableHTLC`] with their
636636
/// [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust
637637
/// HTLCs which would otherwise be represented the same.
638+
///
639+
/// This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`.
638640
outbound_payment_htlc_rounded_msat: u64,
639641
/// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound
640642
/// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part
641643
/// of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`]
642644
/// with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as
643645
/// well as any dust HTLCs which would otherwise be represented the same.
646+
///
647+
/// This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`.
644648
outbound_forwarded_htlc_rounded_msat: u64,
645649
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
646650
/// to us and for which we know the preimage. This is the sum of the millisatoshis part of
647651
/// all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel
648-
/// close, but who's current value is included in
652+
/// close, but whose current value is included in
649653
/// [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which
650654
/// would otherwise be represented the same.
655+
///
656+
/// This amount (rounded up to a whole satoshi value) will not be included in the counterparty's
657+
/// `amount_satoshis` or equivalent thereof.
651658
inbound_claiming_htlc_rounded_msat: u64,
652659
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
653660
/// to us and for which we do not know the preimage. This is the sum of the millisatoshis
654661
/// part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`]
655662
/// on channel close, as well as any dust HTLCs which would otherwise be represented the
656663
/// same.
664+
///
665+
/// This amount (rounded up to a whole satoshi value) will not be included in the counterparty's
666+
/// `amount_satoshis` or equivalent thereof.
657667
inbound_htlc_rounded_msat: u64,
658668
},
659669
/// The channel has been closed, and the given balance is ours but awaiting confirmations until
@@ -2391,12 +2401,13 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
23912401
}
23922402
}
23932403
}
2404+
let tx_fee_satoshis = chan_utils::commit_tx_fee_sat(
2405+
us.current_holder_commitment_tx.feerate_per_kw, nondust_htlc_count,
2406+
us.onchain_tx_handler.channel_type_features());
23942407
res.push(Balance::ClaimableOnChannelClose {
23952408
amount_satoshis: us.current_holder_commitment_tx.to_self_value_sat + claimable_inbound_htlc_value_sat,
23962409
transaction_fee_satoshis: if us.holder_pays_commitment_tx_fee.unwrap_or(true) {
2397-
chan_utils::commit_tx_fee_sat(
2398-
us.current_holder_commitment_tx.feerate_per_kw, nondust_htlc_count,
2399-
us.onchain_tx_handler.channel_type_features())
2410+
tx_fee_satoshis
24002411
} else { 0 },
24012412
outbound_payment_htlc_rounded_msat,
24022413
outbound_forwarded_htlc_rounded_msat,

0 commit comments

Comments
 (0)