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:
@@ -506,11 +506,11 @@ where
|
||||
let chain = &*chain.lock().unwrap();
|
||||
fn print_balances<'a>(
|
||||
title_str: &'a str,
|
||||
items: impl IntoIterator<Item = (&'a str, u64)>,
|
||||
items: impl IntoIterator<Item = (&'a str, Amount)>,
|
||||
) {
|
||||
println!("{}:", title_str);
|
||||
for (name, amount) in items.into_iter() {
|
||||
println!(" {:<10} {:>12} sats", name, amount)
|
||||
println!(" {:<10} {:>12} sats", name, amount.to_sat())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ const BATCH_SIZE: usize = 5;
|
||||
use std::io::Write;
|
||||
use std::str::FromStr;
|
||||
|
||||
use bdk::bitcoin::Address;
|
||||
use bdk::bitcoin::{Address, Amount};
|
||||
use bdk::wallet::Update;
|
||||
use bdk::{bitcoin::Network, Wallet};
|
||||
use bdk::{KeychainKind, SignOptions};
|
||||
@@ -81,7 +81,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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{collections::BTreeSet, io::Write, str::FromStr};
|
||||
|
||||
use bdk::{
|
||||
bitcoin::{Address, Network, Script},
|
||||
bitcoin::{Address, Amount, Network, Script},
|
||||
KeychainKind, SignOptions, Wallet,
|
||||
};
|
||||
use bdk_esplora::{esplora_client, EsploraAsyncExt};
|
||||
@@ -81,7 +81,8 @@ async 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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user