Skip to content

Commit 3bc8048

Browse files
committed
wip stuff
1 parent 09e6cf3 commit 3bc8048

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,25 +591,33 @@ pub enum Balance {
591591
/// [`Balance::MaybeTimeoutClaimableHTLC`] with their
592592
/// [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust
593593
/// HTLCs which would otherwise be represented the same.
594+
///
595+
/// XXX: Talk about how this is included in the overall balance
594596
outbound_payment_htlc_rounded_msat: u64,
595597
/// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound
596598
/// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part
597599
/// of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`]
598600
/// with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as
599601
/// well as any dust HTLCs which would otherwise be represented the same.
602+
///
603+
/// XXX: Talk about how this is included in the overall balance
600604
outbound_forwarded_htlc_rounded_msat: u64,
601605
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
602606
/// to us and for which we know the preimage. This is the sum of the millisatoshis part of
603607
/// all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel
604608
/// close, but who's current value is included in
605609
/// [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which
606610
/// would otherwise be represented the same.
611+
///
612+
/// XXX: Talk about how this is included in the overall balance
607613
inbound_claiming_htlc_rounded_msat: u64,
608614
/// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound
609615
/// to us and for which we do not know the preimage. This is the sum of the millisatoshis
610616
/// part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`]
611617
/// on channel close, as well as any dust HTLCs which would otherwise be represented the
612618
/// same.
619+
///
620+
/// XXX: Talk about how this is included in the overall balance
613621
inbound_htlc_rounded_msat: u64,
614622
},
615623
/// The channel has been closed, and the given balance is ours but awaiting confirmations until
@@ -2097,7 +2105,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
20972105
}
20982106
}
20992107
} else {
2108+
let mut expected_tx_value_sats = if us.holder_pays_commitment_tx_fee.unwrap_or(true) {
2109+
us.channel_value_satoshis
2110+
} else { 0 };
21002111
let mut claimable_inbound_htlc_value_sat = 0;
2112+
let mut claimable_inbound_htlc_value_msat = 0;
21012113
let mut nondust_htlc_count = 0;
21022114
let mut outbound_payment_htlc_rounded_msat = 0;
21032115
let mut outbound_forwarded_htlc_rounded_msat = 0;
@@ -2124,6 +2136,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
21242136
} else {
21252137
outbound_forwarded_htlc_rounded_msat += rounded_value_msat;
21262138
}
2139+
expectex_tx_value_sats -= (htlc.amount_msat + 999) / 1000;
21272140
if htlc.transaction_output_index.is_some() {
21282141
res.push(Balance::MaybeTimeoutClaimableHTLC {
21292142
amount_satoshis: htlc.amount_msat / 1000,
@@ -2150,12 +2163,15 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
21502163
}
21512164
}
21522165
}
2166+
let tx_fee_satoshis = chan_utils::commit_tx_fee_sat(
2167+
us.current_holder_commitment_tx.feerate_per_kw, nondust_htlc_count,
2168+
us.onchain_tx_handler.channel_type_features());
2169+
//XXX: Debug assert that we're able to rebuild the amount_satoshis amount from other
2170+
//information we provide here (and provide such other information)
21532171
res.push(Balance::ClaimableOnChannelClose {
21542172
amount_satoshis: us.current_holder_commitment_tx.to_self_value_sat + claimable_inbound_htlc_value_sat,
21552173
transaction_fee_satoshis: if us.holder_pays_commitment_tx_fee.unwrap_or(true) {
2156-
chan_utils::commit_tx_fee_sat(
2157-
us.current_holder_commitment_tx.feerate_per_kw, nondust_htlc_count,
2158-
us.onchain_tx_handler.channel_type_features())
2174+
tx_fee_satoshis
21592175
} else { 0 },
21602176
outbound_payment_htlc_rounded_msat,
21612177
outbound_forwarded_htlc_rounded_msat,

0 commit comments

Comments
 (0)