pub struct ElectrumClient { /* private fields */ }Expand description
Electrum protocol client.
Provides async methods for querying Bitcoin blockchain data via Electrum protocol.
§Example
use rustywallet_electrum::{ElectrumClient, ClientConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to server
let client = ElectrumClient::new("electrum.blockstream.info").await?;
// Check balance
let balance = client.get_balance("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa").await?;
println!("Balance: {} satoshis", balance.confirmed);
Ok(())
}Implementations§
Source§impl ElectrumClient
impl ElectrumClient
Sourcepub async fn new(server: &str) -> Result<Self>
pub async fn new(server: &str) -> Result<Self>
Create a new client with SSL connection to the specified server.
Uses default port 50002 for SSL.
Sourcepub async fn with_config(config: ClientConfig) -> Result<Self>
pub async fn with_config(config: ClientConfig) -> Result<Self>
Create a new client with custom configuration.
Sourcepub async fn get_balance(&self, address: &str) -> Result<Balance>
pub async fn get_balance(&self, address: &str) -> Result<Balance>
Sourcepub async fn get_balance_scripthash(&self, scripthash: &str) -> Result<Balance>
pub async fn get_balance_scripthash(&self, scripthash: &str) -> Result<Balance>
Get balance using scripthash directly.
Sourcepub async fn get_balances_scripthash(
&self,
scripthashes: &[String],
) -> Result<Vec<Balance>>
pub async fn get_balances_scripthash( &self, scripthashes: &[String], ) -> Result<Vec<Balance>>
Get balances using scripthashes directly (batch).
Sourcepub async fn list_unspent_scripthash(
&self,
scripthash: &str,
) -> Result<Vec<Utxo>>
pub async fn list_unspent_scripthash( &self, scripthash: &str, ) -> Result<Vec<Utxo>>
List unspent outputs using scripthash directly.
Sourcepub async fn get_transaction(&self, txid: &str) -> Result<String>
pub async fn get_transaction(&self, txid: &str) -> Result<String>
Sourcepub async fn get_history_scripthash(
&self,
scripthash: &str,
) -> Result<Vec<TxHistory>>
pub async fn get_history_scripthash( &self, scripthash: &str, ) -> Result<Vec<TxHistory>>
Get transaction history using scripthash directly.
Sourcepub async fn server_version(&self) -> Result<ServerVersion>
pub async fn server_version(&self) -> Result<ServerVersion>
Get server version information.
Also performs protocol version negotiation.
Sourcepub async fn get_block_height(&self) -> Result<u64>
pub async fn get_block_height(&self) -> Result<u64>
Get the current block height.
Auto Trait Implementations§
impl !Freeze for ElectrumClient
impl !RefUnwindSafe for ElectrumClient
impl Send for ElectrumClient
impl Sync for ElectrumClient
impl Unpin for ElectrumClient
impl !UnwindSafe for ElectrumClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more