Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mempool/estimatefee: Fix negative index bug #1813

Merged
merged 1 commit into from Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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