]> Untitled Git - bdk/commitdiff
refactor(wallet): rename get_balance() to balance()
authorSteve Myers <steve@notmandatory.org>
Sat, 1 Jun 2024 22:46:24 +0000 (17:46 -0500)
committerSteve Myers <steve@notmandatory.org>
Sat, 1 Jun 2024 22:46:24 +0000 (17:46 -0500)
crates/wallet/README.md
crates/wallet/src/wallet/mod.rs
crates/wallet/tests/psbt.rs
crates/wallet/tests/wallet.rs
example-crates/wallet_electrum/src/main.rs
example-crates/wallet_esplora_async/src/main.rs
example-crates/wallet_esplora_blocking/src/main.rs
example-crates/wallet_rpc/src/main.rs

index 37e16186a898be9284432cececca2486bf71acec..37afee3873b460fca568370a633eb5093ab0ac37 100644 (file)
@@ -101,7 +101,7 @@ fn main() {
 
 <!--     wallet.sync(&blockchain, SyncOptions::default())?; -->
 
-<!--     println!("Descriptor balance: {} SAT", wallet.get_balance()?); -->
+<!--     println!("Descriptor balance: {} SAT", wallet.balance()?); -->
 
 <!--     Ok(()) -->
 <!-- } -->
index e80584dc31064f3728e9b6f3fcc4ec006786f28e..c6bc1698bcde35c75f7d4e13d238625a37598eb8 100644 (file)
@@ -1216,7 +1216,7 @@ impl Wallet {
 
     /// 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(),
index 3652f109e32e4e53d0253ca892608fc2aed41891..a858e8a4aa92759d2027254665e59149f7eeb463 100644 (file)
@@ -171,7 +171,7 @@ fn test_psbt_multiple_internalkey_signers() {
     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();
index 9b27a2795d33d85241fd7620b5740f12db86823b..b09f18f76350bf4d8e4a7bcdb4f4cd0d6f5d2db4 100644 (file)
@@ -292,7 +292,7 @@ fn test_get_funded_wallet_balance() {
     // 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]
@@ -3711,7 +3711,7 @@ fn test_spend_coinbase() {
     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 {
@@ -3762,7 +3762,7 @@ fn test_spend_coinbase() {
             hash: BlockHash::all_zeros(),
         })
         .unwrap();
-    let balance = wallet.get_balance();
+    let balance = wallet.balance();
     assert_eq!(
         balance,
         Balance {
index c411713ffa5319813f68a7f9bb2b4f6e6e25f675..5be79c17595fcb44c327068bb0d35c0a38d52f2b 100644 (file)
@@ -33,7 +33,7 @@ fn main() -> Result<(), anyhow::Error> {
     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...");
@@ -65,7 +65,7 @@ fn main() -> Result<(), anyhow::Error> {
     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 {
index 914bc8903508078702e5f95a65f91c5db3bc92b3..9a9904a54d62d3a9cbd9ee162dee368a668a3970 100644 (file)
@@ -30,7 +30,7 @@ async fn main() -> Result<(), anyhow::Error> {
     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...");
@@ -78,7 +78,7 @@ async fn main() -> Result<(), anyhow::Error> {
     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 {
index f42cb9d82f5fc4a51e841a187d5695523ea5f1e2..5ecb7122383e1c086d32d1f702322fa77b3fc443 100644 (file)
@@ -29,7 +29,7 @@ fn main() -> Result<(), anyhow::Error> {
     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...");
@@ -55,7 +55,7 @@ fn main() -> Result<(), anyhow::Error> {
     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 {
index 3bdd515c31b353213b00caced68d4f9996b736c8..8c709a02564f6d072d79784a592d2423d69b192f 100644 (file)
@@ -100,7 +100,7 @@ fn main() -> anyhow::Result<()> {
         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();
@@ -163,7 +163,7 @@ fn main() -> anyhow::Result<()> {
         }
     }
     let wallet_tip_end = wallet.latest_checkpoint();
-    let balance = wallet.get_balance();
+    let balance = wallet.balance();
     println!(
         "Synced {} blocks in {}s",
         blocks_received,