Merge pull request #450 from ariard/2020-01-fix-fst-blk-disconnection
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Fri, 17 Jan 2020 20:13:46 +0000 (20:13 +0000)
committerGitHub <noreply@github.com>
Fri, 17 Jan 2020 20:13:46 +0000 (20:13 +0000)
Fix full_stack_target block disconnection

fuzz/src/full_stack.rs
lightning/src/ln/channelmonitor.rs

index 7e6135b5c658aeba7ee179af755c4ef80234677f..e6496125ac656ded582209d631ae74db71ba728a 100644 (file)
@@ -196,10 +196,10 @@ impl<'a> MoneyLossDetector<'a> {
 
        fn disconnect_block(&mut self) {
                if self.height > 0 && (self.max_height < 6 || self.height >= self.max_height - 6) {
-                       self.height -= 1;
                        let header = BlockHeader { version: 0x20000000, prev_blockhash: self.header_hashes[self.height], merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                        self.manager.block_disconnected(&header, self.height as u32);
                        self.monitor.block_disconnected(&header, self.height as u32);
+                       self.height -= 1;
                        let removal_height = self.height;
                        self.txids_confirmed.retain(|_, height| {
                                removal_height != *height
index b9527f599b246552056cd5b98a6866c0fb4514f8..1753e16dcc7351a1b0f50a7245086bf08a58c295 100644 (file)
@@ -2556,6 +2556,7 @@ impl ChannelMonitor {
        }
 
        fn block_disconnected(&mut self, height: u32, block_hash: &Sha256dHash, broadcaster: &BroadcasterInterface, fee_estimator: &FeeEstimator) {
+               log_trace!(self, "Block {} at height {} disconnected", block_hash, height);
                let mut bump_candidates = HashMap::new();
                if let Some(events) = self.onchain_events_waiting_threshold_conf.remove(&(height + ANTI_REORG_DELAY - 1)) {
                        //We may discard: