Skip to content

Conversation

LagginTimes
Copy link
Contributor

Implements bdk#1942.

Description

This PR adds a new convenience method to bdk_wallet::Wallet for computing balances with a configurable minimum confirmation threshold. This allows applications to easily query wallet balances that only include transactions with a specified number of confirmations.

See: bitcoindevkit/bdk#2007 (review)

Changelog notice

  • Added balance_with_confirmation_depth() method to compute balance with a user-defined minimum number of confirmations.

Checklists

All Submissions:

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

@coveralls
Copy link

Pull Request Test Coverage Report for Build 17173539231

Details

  • 18 of 18 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 84.947%

Totals Coverage Status
Change from base Build 17132535147: 0.04%
Covered Lines: 6687
Relevant Lines: 7872

💛 - Coveralls

Copy link
Collaborator

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should tackle #273 before going ahead with this.

Comment on lines +1248 to +1252
let target_tip = self
.chain
.range(..=target_height)
.next()
.expect("local chain must contain genesis");
Copy link
Collaborator

@ValuedMammal ValuedMammal Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 This relies on there being a checkpoint in the local chain at the target_height. If there's not, then the next "tip" might be significantly lower. A better way IMO would be to pass the target height as input to FullTxOut::is_confirmed_and_spendable.

Then again, if a UTXO originally confirmed at height $h$, then we can probably assume that it's also the height of the floor checkpoint.

@LagginTimes LagginTimes marked this pull request as draft September 1, 2025 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants