<!-- wallet.sync(&blockchain, SyncOptions::default())?; -->
-<!-- println!("Descriptor balance: {} SAT", wallet.get_balance()?); -->
+<!-- println!("Descriptor balance: {} SAT", wallet.balance()?); -->
<!-- Ok(()) -->
<!-- } -->
/// Return the balance, separated into available, trusted-pending, untrusted-pending and immature
/// values.
- pub fn get_balance(&self) -> Balance {
+ pub fn balance(&self) -> Balance {
self.indexed_graph.graph().balance(
&self.chain,
self.chain.tip().block_id(),
let keypair = Keypair::from_secret_key(&secp, &prv.inner);
let (mut wallet, _) = get_funded_wallet(&desc);
- let to_spend = wallet.get_balance().total();
+ let to_spend = wallet.balance().total();
let send_to = wallet.peek_address(KeychainKind::External, 0);
let mut builder = wallet.build_tx();
builder.drain_to(send_to.script_pubkey()).drain_wallet();
// The funded wallet contains a tx with a 76_000 sats input and two outputs, one spending 25_000
// to a foreign address and one returning 50_000 back to the wallet as change. The remaining 1000
// sats are the transaction fee.
- assert_eq!(wallet.get_balance().confirmed, Amount::from_sat(50_000));
+ assert_eq!(wallet.balance().confirmed, Amount::from_sat(50_000));
}
#[test]
let not_yet_mature_time = confirmation_height + COINBASE_MATURITY - 1;
let maturity_time = confirmation_height + COINBASE_MATURITY;
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
assert_eq!(
balance,
Balance {
hash: BlockHash::all_zeros(),
})
.unwrap();
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
assert_eq!(
balance,
Balance {
let address = wallet.next_unused_address(KeychainKind::External)?;
println!("Generated Address: {}", address);
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
println!("Wallet balance before syncing: {} sats", balance.total());
print!("Syncing...");
wallet.apply_update(update)?;
wallet.commit()?;
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
println!("Wallet balance after syncing: {} sats", balance.total());
if balance.total() < SEND_AMOUNT {
let address = wallet.next_unused_address(KeychainKind::External)?;
println!("Generated Address: {}", address);
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
println!("Wallet balance before syncing: {} sats", balance.total());
print!("Syncing...");
wallet.commit()?;
println!();
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
println!("Wallet balance after syncing: {} sats", balance.total());
if balance.total() < SEND_AMOUNT {
let address = wallet.next_unused_address(KeychainKind::External)?;
println!("Generated Address: {}", address);
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
println!("Wallet balance before syncing: {} sats", balance.total());
print!("Syncing...");
wallet.commit()?;
println!();
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
println!("Wallet balance after syncing: {} sats", balance.total());
if balance.total() < SEND_AMOUNT {
start_load_wallet.elapsed().as_secs_f32()
);
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
println!("Wallet balance before syncing: {} sats", balance.total());
let wallet_tip = wallet.latest_checkpoint();
}
}
let wallet_tip_end = wallet.latest_checkpoint();
- let balance = wallet.get_balance();
+ let balance = wallet.balance();
println!(
"Synced {} blocks in {}s",
blocks_received,