From 89d1e9c143f7acfd51b4172dabf2b0900aee4e32 Mon Sep 17 00:00:00 2001 From: Roei Erez Date: Wed, 5 Jun 2024 11:45:39 +0300 Subject: [PATCH] Add some doc commenets --- lib/core/src/wallet.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/core/src/wallet.rs b/lib/core/src/wallet.rs index 49aed22..87f7074 100644 --- a/lib/core/src/wallet.rs +++ b/lib/core/src/wallet.rs @@ -20,7 +20,10 @@ use crate::{ #[async_trait] pub trait OnchainWallet: Send + Sync { + /// List all transactions in the wallet async fn transactions(&self) -> Result, PaymentError>; + + /// Build a transaction to send funds to a recipient async fn build_tx( &self, fee_rate: Option, @@ -28,12 +31,16 @@ pub trait OnchainWallet: Send + Sync { amount_sat: u64, ) -> Result; + /// Get the next unused address in the wallet async fn next_unused_address(&self) -> Result; + /// Get the current tip of the blockchain the wallet is aware of async fn tip(&self) -> Tip; + /// Get the public key of the wallet async fn pubkey(&self) -> String; + /// Perform a full scan of the wallet async fn full_scan(&self) -> Result<(), PaymentError>; } @@ -78,6 +85,7 @@ impl LiquidOnchainWallet { #[async_trait] impl OnchainWallet for LiquidOnchainWallet { + /// List all transactions in the wallet async fn transactions(&self) -> Result, PaymentError> { let wallet = self.wallet.lock().await; wallet.transactions().map_err(|e| PaymentError::Generic { @@ -85,6 +93,7 @@ impl OnchainWallet for LiquidOnchainWallet { }) } + /// Build a transaction to send funds to a recipient async fn build_tx( &self, fee_rate: Option, @@ -110,18 +119,22 @@ impl OnchainWallet for LiquidOnchainWallet { Ok(lwk_wollet.finalize(&mut pset)?) } + /// Get the next unused address in the wallet async fn next_unused_address(&self) -> Result { Ok(self.wallet.lock().await.address(None)?.address().clone()) } + /// Get the current tip of the blockchain the wallet is aware of async fn tip(&self) -> Tip { self.wallet.lock().await.tip() } + /// Get the public key of the wallet async fn pubkey(&self) -> String { self.lwk_signer.xpub().to_string() } + /// Perform a full scan of the wallet async fn full_scan(&self) -> Result<(), PaymentError> { let mut wallet = self.wallet.lock().await; let mut electrum_client =