Skip to content

Commit

Permalink
Merge pull request #1813 from kcalvinalvin/fix-mempool-estimatefee-bug
Browse files Browse the repository at this point in the history
mempool/estimatefee: Fix negative index bug
  • Loading branch information
Roasbeef committed Feb 25, 2022
2 parents 4dc4ff7 + 2ce1c60 commit 0c6dbfc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mempool/estimatefee.go
Expand Up @@ -275,7 +275,16 @@ func (ef *FeeEstimator) RegisterBlock(block *btcutil.Block) error {

// This shouldn't happen but check just in case to avoid
// an out-of-bounds array index later.
if blocksToConfirm >= estimateFeeDepth {
//
// Also check that blocksToConfirm is not negative as this causes
// the node to crash on reorgs. A tx that was observed at height X
// might be included in heights less than X because of chain reorgs.
// Refer to github.com/btcsuite/btcd/issues/1660 for more information.
//
// TODO(kcalvinalvin) a better design that doesn't just skip over the
// transaction would result in a more accurate fee estimator. Properly
// implement this later.
if blocksToConfirm >= estimateFeeDepth || blocksToConfirm < 0 {
continue
}

Expand Down

0 comments on commit 0c6dbfc

Please sign in to comment.