Skip to content

Commit

Permalink
enable debug assertion for tlcs amount
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Jun 20, 2024
1 parent 5b09c5a commit dfd194f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/ckb/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3466,6 +3466,14 @@ impl ChannelActorState {
&self,
local: bool,
) -> (Vec<CellOutput>, Vec<Bytes>, Vec<u8>) {
#[cfg(debug_assertions)]
{
debug_assert_eq!(
self.total_amount,
self.to_local_amount + self.to_remote_amount
);
}

// The time_locked_value is amount of assets locked by commitment-lock.
// Our value is always time-locked. Additionally, we need to add the value of
// all the TLCs that we have received from the counterparty.
Expand All @@ -3491,13 +3499,6 @@ impl ChannelActorState {
time_locked_value, received_tlc_value, immediately_spendable_value);
let time_locked_value = time_locked_value + received_tlc_value;
let immediately_spendable_value = immediately_spendable_value - received_tlc_value;
// #[cfg(debug_assertions)]
// {
// debug_assert_eq!(
// self.total_amount,
// time_locked_value + immediately_spendable_value
// );
// }

eprintln!("Building commitment transaction with time_locked_value: {}, immediately_spendable_value: {}", time_locked_value, immediately_spendable_value);
let immediate_payment_key = {
Expand Down

0 comments on commit dfd194f

Please sign in to comment.