]> Untitled Git - bdk/commit
Merge bitcoindevkit/bdk#1763: Change coin_selection and DescriptorExt::dust_value...
authorSteve Myers <steve@notmandatory.org>
Wed, 11 Dec 2024 21:21:29 +0000 (15:21 -0600)
committerSteve Myers <steve@notmandatory.org>
Wed, 11 Dec 2024 21:22:53 +0000 (15:22 -0600)
commit49d64771a6564786931f522493d339bccb5741b4
treeae547a091dba69306321df8e311610020c063694
parent955593c358cd77c7da967d7c829361a1ec0cfdf9
parent2a9eeed302a3c7faaa7e2d26ff3d806f2317a850
Merge bitcoindevkit/bdk#1763: Change coin_selection and DescriptorExt::dust_value to use Amount type

2a9eeed302a3c7faaa7e2d26ff3d806f2317a850 ci: pin msrv dep version for rustls (Steve Myers)
20789ec9e833ad8d24608201960789614dfae52b refactor(chain)!: use Amount for DescriptorExt::dust_value() (Steve Myers)
58a8435759ed06cb6841c5582abd97707e99706b refactor(coin_selection)!: use Amount and SignedAmount for API and internally (Steve Myers)

Pull request description:

  ### Description

  refactor(coin_selection)!: use Amount and SignedAmount for API and internally
  refactor(chain)!: use Amount for DescriptorExt::dust_value()

  Using named types make the API and internal code easier to read and reason about since it makes it clear that the values are bitcoin amounts. Also to create these types the units (ie .from_sat()) must be specified.

  ### Notes to the reviewers

  For coin_selection using Amount and SignedAmount makes internal code safer against overflow errors. In particular because these types will panic if an amount overflow occurs. Using u64/i64 on the other hand can silently rollover. See: https://doc.rust-lang.org/book/ch03-02-data-types.html#integer-overflow

  This is a continuation of the work done in #1595.  Since this is an API breaking change I would like to include it in the 1.0.0-beta milestone if possible.

  ### Changelog notice

  - Change coin_selection to use Amount instead of u64 for all bitcoin amounts.
  - Change DescriptorExt::dust_value() to return an Amount instead of u64.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### Bugfixes:

  * [x] This pull request breaks the existing API
  * [ ] I've added tests to reproduce the issue which are now passing
  * [ ] I'm linking the issue being fixed by this PR

ACKs for top commit:
  ValuedMammal:
    ACK 2a9eeed302a3c7faaa7e2d26ff3d806f2317a850

Tree-SHA512: 9dd1b31d0f8d3d8c383c7aae7ec0fffb55bfcfe49c804e273faa740d30efde7efb7c9504e87cceb56798ea14a3e34fc8a7b65a8ad5e52ea38b8523150c9b6bc2