From: merge-script Date: Mon, 19 Oct 2026 23:53:34 +0000 (+1100) Subject: Merge bitcoindevkit/bdk#2367: feat(chain): derive Copy and implement AddAssign, Sum... X-Git-Url: http://internal-gitweb-vhost/-client-interface/%22https:/super::Subscriber?a=commitdiff_plain;p=bdk Merge bitcoindevkit/bdk#2367: feat(chain): derive Copy and implement AddAssign, Sum for Balance 55aba974b4399516f3ad05ffdb92fcea029ec826 feat(chain): derive Copy and implement AddAssign, Sum for Balance (bhuvan-somisetty) Pull request description: ### Description `bdk_chain::Balance` contains four `bitcoin::Amount` fields (`immature`, `trusted_pending`, `untrusted_pending`, `confirmed`). Since `Amount` is `Copy`, `Balance` can also derive `Copy`. This PR adds: - `Copy` derive for `Balance`. - `core::ops::AddAssign` for `Balance`. - `core::iter::Sum` for `Balance`. - Unit test covering `+=` and `sum`. Closes #2366. ### Notes to the reviewers - Non-breaking ergonomic addition. ### Changelog notice ### Added - `bdk_chain`: `Balance` now derives `Copy` and implements `AddAssign` and `Sum`. #2367 ### Checklists #### All Submissions: * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) #### New Features: * [x] I've added tests for the new feature * [ ] I've added docs for the new feature #### Bugfixes: * [ ] This pull request breaks the existing API * [ ] I've added tests to reproduce the issue which are now passing * [x] I'm linking the issue being fixed by this PR Signed-off-by: bhuvan-somisetty ACKs for top commit: evanlinjin: ACK 55aba974b4399516f3ad05ffdb92fcea029ec826 Tree-SHA512: 3a3fc3662a2ba79770de98877108e2c042db6966b509729972b61109ae548d971f481c59f0857da6c7ea2ef1973747643e393b97005e202a404b602ba52620da --- 63196f1449f4b8add57e9d9a303e6e1a030f68f2 diff --cc crates/chain/src/balance.rs index d062b93a,dc4db823..b0170538 --- a/crates/chain/src/balance.rs +++ b/crates/chain/src/balance.rs @@@ -1,11 -1,10 +1,11 @@@ use bitcoin::Amount; /// Balance, differentiated into various categories. - #[derive(Debug, PartialEq, Eq, Clone, Default)] + #[derive(Debug, PartialEq, Eq, Clone, Copy, Default)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Balance { - /// All coinbase outputs not yet matured + /// Outputs not yet spendable by consensus (immature coinbase or unmet timelock), confirmed or + /// not. pub immature: Amount, /// Unconfirmed UTXOs generated by a wallet tx pub trusted_pending: Amount,