]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Fix non-HTLC-inclusion balance calculation (mark II) 2018-07-htlc-balance-calc
authorMatt Corallo <git@bluematt.me>
Mon, 30 Jul 2018 22:05:50 +0000 (18:05 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 30 Jul 2018 22:29:03 +0000 (18:29 -0400)
src/ln/channel.rs

index acee06409c3f8479137b1561ac1b2d636cf6c9e2..188af477dded2049771aa6d800ffe3cc3421407e 100644 (file)
@@ -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;
                                        },
                                        _ => {},