From: Matt Corallo Date: Mon, 30 Jul 2018 22:05:50 +0000 (-0400) Subject: Fix non-HTLC-inclusion balance calculation (mark II) X-Git-Tag: v0.0.12~355^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=b17211ffe42d029280fc45df42dd1d6152eadd13;p=rust-lightning Fix non-HTLC-inclusion balance calculation (mark II) --- diff --git a/src/ln/channel.rs b/src/ln/channel.rs index acee06409..188af477d 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -136,7 +136,7 @@ enum HTLCState { /// anyway). LocalRemoved, /// Removed by us, sent a new commitment_signed and got a revoke_and_ack. Just waiting on an - /// updated local commitment transaction. + /// updated local commitment transaction. Implies local_removed_fulfilled. LocalRemovedAwaitingCommitment, } @@ -663,7 +663,7 @@ impl Channel { } else { match htlc.state { HTLCState::AwaitingRemoteRevokeToRemove|HTLCState::AwaitingRemovedRemoteRevoke => { - if generated_by_local && htlc.fail_reason.is_none() { + if htlc.fail_reason.is_none() { value_to_self_msat_offset -= htlc.amount_msat as i64; } }, @@ -678,6 +678,7 @@ impl Channel { } }, HTLCState::LocalRemovedAwaitingCommitment => { + assert!(htlc.local_removed_fulfilled); value_to_self_msat_offset += htlc.amount_msat as i64; }, _ => {},