Skip to content

Commit

Permalink
Change get_balance to return in categories.
Browse files Browse the repository at this point in the history
Add type balance with add, display traits. Change affected tests.
Update `CHANGELOG.md`
  • Loading branch information
wszdexdrf committed Jun 30, 2022
1 parent ab2397a commit 4f052fe
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 69 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- New MSRV set to `1.56.1`
- Fee sniping discouraging through nLockTime - if the user specifies a `current_height`, we use that as a nlocktime, otherwise we use the last sync height (or 0 if we never synced)
- Return balance in separate categories, namely `available`, `trusted_pending`, `untrusted_pending` & `immature`.

## [v0.19.0] - [v0.18.0]

Expand Down
2 changes: 1 addition & 1 deletion src/blockchain/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,6 @@ mod test {
.sync_wallet(&wallet, None, Default::default())
.unwrap();

assert_eq!(wallet.get_balance().unwrap(), 50_000);
assert_eq!(wallet.get_balance().unwrap().untrusted_pending, 50_000);
}
}
2 changes: 1 addition & 1 deletion src/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ This example shows how to sync multiple walles and return the sum of their balan
# use bdk::database::*;
# use bdk::wallet::*;
# use bdk::*;
fn sum_of_balances<B: BlockchainFactory>(blockchain_factory: B, wallets: &[Wallet<MemoryDatabase>]) -> Result<u64, Error> {
fn sum_of_balances<B: BlockchainFactory>(blockchain_factory: B, wallets: &[Wallet<MemoryDatabase>]) -> Result<Balance, Error> {
Ok(wallets
.iter()
.map(|w| -> Result<_, Error> {
Expand Down
Loading

0 comments on commit 4f052fe

Please sign in to comment.