feat: update wallet::Balance to use bitcoin::Amount

- update all fields `immature`, ` trusted_pending`, `unstrusted_pending`
  and `confirmed` to use the `bitcoin::Amount` instead of `u64`
- update all `impl Balance` methods to use `bitcoin::Amount`
- update all tests that relies on `keychain::Balance`
This commit is contained in:
Leonardo Lima
2024-04-24 18:12:45 -03:00
parent 08fac47c29
commit 8a33d98db9
15 changed files with 127 additions and 120 deletions

View File

@@ -6,7 +6,7 @@ const PARALLEL_REQUESTS: usize = 1;
use std::{collections::BTreeSet, io::Write, str::FromStr};
use bdk::{
bitcoin::{Address, Network},
bitcoin::{Address, Amount, Network},
KeychainKind, SignOptions, Wallet,
};
use bdk_esplora::{esplora_client, EsploraExt};
@@ -57,7 +57,8 @@ fn main() -> Result<(), anyhow::Error> {
let balance = wallet.get_balance();
println!("Wallet balance after syncing: {} sats", balance.total());
if balance.total() < SEND_AMOUNT {
// TODO: (@leonardo) Should we format here, or update on constant and TxBuilder::add_recipient() instead ?
if balance.total() < Amount::from_sat(SEND_AMOUNT) {
println!(
"Please send at least {} sats to the receiving address",
SEND_AMOUNT