You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
log_trace!(logger, " ...not including inbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, htlc.payment_hash, htlc.amount_msat, htlc.state);
4606
4607
if let Some(preimage) = htlc.state.preimage() {
4607
4608
inbound_htlc_preimages.push(preimage);
4608
-
value_to_self_msat_offset += htlc.amount_msat as i64;
4609
+
value_to_self_claimed_msat += htlc.amount_msat;
4609
4610
}
4610
4611
}
4611
4612
};
@@ -4620,26 +4621,24 @@ where
4620
4621
} else {
4621
4622
log_trace!(logger, " ...not including outbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, htlc.payment_hash, htlc.amount_msat, htlc.state);
4622
4623
if htlc.state.preimage().is_some() {
4623
-
value_to_self_msat_offset -= htlc.amount_msat as i64;
4624
+
value_to_remote_claimed_msat += htlc.amount_msat;
4624
4625
}
4625
4626
}
4626
4627
};
4627
4628
4628
4629
// # Panics
4629
4630
//
4630
-
// While we expect `value_to_self_msat_offset` to be negative in some cases, the local
4631
-
// balance MUST remain greater than or equal to 0.
4631
+
// After all HTLC claims have been accounted for, the local balance MUST remain greater than or equal to 0.
4632
4632
4633
-
// TODO: When MSRV >= 1.66.0, use u64::checked_add_signed
4634
-
let value_to_self_with_offset_msat = (funding.value_to_self_msat as i64 + value_to_self_msat_offset).try_into().unwrap();
4633
+
let value_to_self_msat = (funding.value_to_self_msat + value_to_self_claimed_msat).checked_sub(value_to_remote_claimed_msat).unwrap();
4635
4634
4636
4635
let (tx, stats) = SpecTxBuilder {}.build_commitment_transaction(
0 commit comments