From b17211ffe42d029280fc45df42dd1d6152eadd13 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 30 Jul 2018 18:05:50 -0400 Subject: [PATCH] Fix non-HTLC-inclusion balance calculation (mark II) --- src/ln/channel.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; }, _ => {}, -- 2.39.5