bdk icon indicating copy to clipboard operation
bdk copied to clipboard

feat: add further `bitcoin::Amount` usage on public APIs

Open oleonardolima opened this issue 9 months ago • 5 comments

builds on top of #1411, further improves #823

Description

It further updates and adds the usage of bitcoin::Amount instead of u64.

Notes to the reviewers

Open for comments and discussions.

Changelog notice

  • Updated CreateTxError::FeeTooLow to use bitcoin::Amount.
  • Updated Wallet::calculate_fee(). to use bitcoin::Amount
  • Updated TxBuilder::fee_absolute(). to use bitcoin::Amount.
  • Updated CalculateFeeError::NegativeFee to use bitcoin::SignedAmount.
  • Updated TxGraph::calculate_fee(). to use bitcoin::Amount.
  • Updated PsbUtils::fee_amount() to use bitcoin::Amount.

Checklists

All Submissions:

  • [x] I've signed all my commits
  • [x] I followed the contribution guidelines
  • [x] I ran cargo fmt and cargo clippy before committing

New Features:

  • [x] I've added tests for the new feature
  • [x] I've added docs for the new feature

oleonardolima avatar May 05 '24 21:05 oleonardolima

@ValuedMammal Please let me know what are your thoughts on these changes.

oleonardolima avatar May 06 '24 19:05 oleonardolima

@ValuedMammal Please let me know what are your thoughts on these changes.

I did remove the updates where it's pub(crate) APIs, and kept only the ones for explicitly pub APIs.

oleonardolima avatar May 07 '24 19:05 oleonardolima

Here's how I would approach this PR with fewer lines touched ValuedMammal/bdk@0c72958e388e060a1ad6db46e7f19192938b8f1f

However I think it's worth having a discussion about where we can continue to get benefits from the Amount type so I opened an issue #1432

--

edit: @oleonardolima Just checking, is the plan to go ahead and complete #1432 in this PR?

ValuedMammal avatar May 08 '24 15:05 ValuedMammal

[...]

--

edit: @oleonardolima Just checking, is the plan to go ahead and complete #1432 in this PR?

I think I can continue the work on non-public code (everywhere) on another PR, and keep this one only for the public APIs that remained from #1411. wdyt @ValuedMammal ?

Also, I was waiting if some new discussion would occur on #1432 before working on it :)

oleonardolima avatar May 17 '24 19:05 oleonardolima

Thanks for working on this. There's a small typo in the changelog notice - FeePolicy::fee_absolute should say TxBuilder::fee_absolute.

Oh, thanks! Sorry for the oversight, fixed it.

oleonardolima avatar May 23 '24 02:05 oleonardolima

ACK 5f2d6cb

I made one small suggestion and I think you need to do a rebase. Otherwise looks ready to merge to me.

EDIT: I applied the suggestion and rebased it on top of master at a03949a, should be ready to go now.

oleonardolima avatar Jun 03 '24 14:06 oleonardolima