Merge bitcoindevkit/bdk#1411: feat: update keychain::Balance to use bitcoin::Amount
22aa534d76feat: use `Amount` on `TxBuilder::add_recipient` (Leonardo Lima)d5c0e7200cfeat: use `Amount` on `spk_txout_index` and related (Leonardo Lima)8a33d98db9feat: update `wallet::Balance` to use `bitcoin::Amount` (Leonardo Lima) Pull request description: fixes #823 <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description It's being used on `Balance`, and throughout the code, an `u64` represents the amount, which relies on the user to infer its sats, not millisats, or any other representation. It updates the usage of `u64` on `Balance`, and other APIs: - `TxParams::add_recipient` - `KeyChainTxOutIndex::sent_and_received`, `KeyChainTxOutIndex::net_value` - `SpkTxOutIndex::sent_and_received`, `SpkTxOutIndex::net_value` <!-- Describe the purpose of this PR, what's being adding and/or fixed --> ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> It updates some of the APIs to expect the `bitcoin::Amount`, but it does not update internal usage of u64, such as `TxParams` still expects and uses `u64`, please see the PR comments for related discussion. ### Changelog notice <!-- Notice the release manager should include in the release tag message changelog --> <!-- See https://keepachangelog.com/en/1.0.0/ for examples --> - Changed the `keychain::Balance` struct fields to use `Amount` instead of `u64`. - Changed the `add_recipient` method on `TxBuilder` implementation to expect `bitcoin::Amount`. - Changed the `sent_and_received`, and `net_value` methods on `KeyChainTxOutIndex` to expect `bitcoin::Amount`. - Changed the `sent_and_received`, and `net_value` methods on `SpkTxOutIndex` to expect `bitcoin::Amount`. ### 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 #### New Features: * [x] I've added tests for the new feature * [x] I've added docs for the new feature #### Bugfixes: * [x] 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 ACKs for top commit: evanlinjin: ACK22aa534d76Tree-SHA512: c4e8198d96c0d66cc3d2e4149e8a56bb7565b9cd49ff42113eaebd24b1d7bfeecd7124db0b06524b78b8891ee1bde1546705b80afad408f48495cf3c02446d02
This commit is contained in:
@@ -76,7 +76,7 @@ fn scan_detects_confirmed_tx() -> Result<()> {
|
||||
assert_eq!(
|
||||
get_balance(&recv_chain, &recv_graph)?,
|
||||
Balance {
|
||||
confirmed: SEND_AMOUNT.to_sat(),
|
||||
confirmed: SEND_AMOUNT,
|
||||
..Balance::default()
|
||||
},
|
||||
);
|
||||
@@ -145,7 +145,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> Result<()> {
|
||||
assert_eq!(
|
||||
get_balance(&recv_chain, &recv_graph)?,
|
||||
Balance {
|
||||
confirmed: SEND_AMOUNT.to_sat() * REORG_COUNT as u64,
|
||||
confirmed: SEND_AMOUNT * REORG_COUNT as u64,
|
||||
..Balance::default()
|
||||
},
|
||||
"initial balance must be correct",
|
||||
@@ -176,8 +176,8 @@ fn tx_can_become_unconfirmed_after_reorg() -> Result<()> {
|
||||
assert_eq!(
|
||||
get_balance(&recv_chain, &recv_graph)?,
|
||||
Balance {
|
||||
confirmed: SEND_AMOUNT.to_sat() * (REORG_COUNT - depth) as u64,
|
||||
trusted_pending: SEND_AMOUNT.to_sat() * depth as u64,
|
||||
confirmed: SEND_AMOUNT * (REORG_COUNT - depth) as u64,
|
||||
trusted_pending: SEND_AMOUNT * depth as u64,
|
||||
..Balance::default()
|
||||
},
|
||||
"reorg_count: {}",
|
||||
|
||||
Reference in New Issue
Block a user