pub struct RawClient<S>{ /* private fields */ }Expand description
Instance of an Electrum client
A Client maintains a constant connection with an Electrum server and exposes methods to
interact with it. It can also subscribe and receive notifictations from the server about new
blocks or activity on a specific scriptPubKey.
The Client is modeled in such a way that allows the external caller to have full control over
its functionality: no threads or tasks are spawned internally to monitor the state of the
connection.
More transport methods can be used by manually creating an instance of this struct with an
arbitray S type.
Implementations§
Source§impl RawClient<ElectrumSslStream>
impl RawClient<ElectrumSslStream>
Sourcepub fn new_ssl<A: ToSocketAddrsDomain + Clone>(
socket_addrs: A,
validate_domain: bool,
timeout: Option<Duration>,
) -> Result<Self, Error>
pub fn new_ssl<A: ToSocketAddrsDomain + Clone>( socket_addrs: A, validate_domain: bool, timeout: Option<Duration>, ) -> Result<Self, Error>
Creates a new SSL client and tries to connect to socket_addr. Optionally, if
validate_domain is true, validate the server’s certificate.
Sourcepub fn new_ssl_from_stream<A: ToSocketAddrsDomain>(
socket_addr: A,
validate_domain: bool,
tcp_stream: TcpStream,
) -> Result<Self, Error>
pub fn new_ssl_from_stream<A: ToSocketAddrsDomain>( socket_addr: A, validate_domain: bool, tcp_stream: TcpStream, ) -> Result<Self, Error>
Create a new SSL client using an existing TcpStream
Source§impl RawClient<ElectrumProxyStream>
impl RawClient<ElectrumProxyStream>
Sourcepub fn new_proxy<T: ToTargetAddr>(
target_addr: T,
proxy: &Socks5Config,
timeout: Option<Duration>,
) -> Result<Self, Error>
pub fn new_proxy<T: ToTargetAddr>( target_addr: T, proxy: &Socks5Config, timeout: Option<Duration>, ) -> Result<Self, Error>
Creates a new socks client and tries to connect to target_addr using proxy_addr as a
socks proxy server. The DNS resolution of target_addr, if required, is done
through the proxy. This allows to specify, for instance, .onion addresses.
Sourcepub fn new_proxy_ssl<T: ToTargetAddr>(
target_addr: T,
validate_domain: bool,
proxy: &Socks5Config,
timeout: Option<Duration>,
) -> Result<RawClient<ElectrumSslStream>, Error>
pub fn new_proxy_ssl<T: ToTargetAddr>( target_addr: T, validate_domain: bool, proxy: &Socks5Config, timeout: Option<Duration>, ) -> Result<RawClient<ElectrumSslStream>, Error>
Creates a new TLS client that connects to target_addr using proxy_addr as a socks proxy
server. The DNS resolution of target_addr, if required, is done through the proxy. This
allows to specify, for instance, .onion addresses.
Trait Implementations§
Source§impl<T: Read + Write> ElectrumApi for RawClient<T>
impl<T: Read + Write> ElectrumApi for RawClient<T>
Source§fn raw_call(
&self,
method_name: &str,
params: impl IntoIterator<Item = Param>,
) -> Result<Value, Error>
fn raw_call( &self, method_name: &str, params: impl IntoIterator<Item = Param>, ) -> Result<Value, Error>
Source§fn batch_call(&self, batch: &Batch) -> Result<Vec<Value>, Error>
fn batch_call(&self, batch: &Batch) -> Result<Vec<Value>, Error>
Batch struct. Returns
Ok() only if all of the calls are successful. The order of the JSON Values returned
reflects the order in which the calls were made on the Batch struct.Source§fn block_headers_subscribe_raw(&self) -> Result<RawHeaderNotification, Error>
fn block_headers_subscribe_raw(&self) -> Result<RawHeaderNotification, Error>
blockchain.headers.subscribe call and
returns the current tip as raw bytes instead of deserializing them.Source§fn block_headers_pop_raw(&self) -> Result<Option<RawHeaderNotification>, Error>
fn block_headers_pop_raw(&self) -> Result<Option<RawHeaderNotification>, Error>
Source§fn block_header_raw(&self, height: usize) -> Result<Vec<u8>, Error>
fn block_header_raw(&self, height: usize) -> Result<Vec<u8>, Error>
height.Source§fn block_headers(
&self,
start_height: usize,
count: usize,
) -> Result<GetHeadersRes, Error>
fn block_headers( &self, start_height: usize, count: usize, ) -> Result<GetHeadersRes, Error>
count block headers starting from start_height.Source§fn estimate_fee(&self, number: usize) -> Result<f64, Error>
fn estimate_fee(&self, number: usize) -> Result<f64, Error>
number blocks.Source§fn relay_fee(&self) -> Result<f64, Error>
fn relay_fee(&self) -> Result<f64, Error>
Source§fn script_subscribe(
&self,
script: &Script,
) -> Result<Option<ScriptStatus>, Error>
fn script_subscribe( &self, script: &Script, ) -> Result<Option<ScriptStatus>, Error>
Source§fn batch_script_subscribe<'s, I>(
&self,
scripts: I,
) -> Result<Vec<Option<ScriptStatus>>, Error>
fn batch_script_subscribe<'s, I>( &self, scripts: I, ) -> Result<Vec<Option<ScriptStatus>>, Error>
script_subscribe. Read moreSource§fn script_unsubscribe(&self, script: &Script) -> Result<bool, Error>
fn script_unsubscribe(&self, script: &Script) -> Result<bool, Error>
Source§fn script_pop(&self, script: &Script) -> Result<Option<ScriptStatus>, Error>
fn script_pop(&self, script: &Script) -> Result<Option<ScriptStatus>, Error>
None if there are no items in the queue.Source§fn script_get_balance(&self, script: &Script) -> Result<GetBalanceRes, Error>
fn script_get_balance(&self, script: &Script) -> Result<GetBalanceRes, Error>
Source§fn batch_script_get_balance<'s, I>(
&self,
scripts: I,
) -> Result<Vec<GetBalanceRes>, Error>
fn batch_script_get_balance<'s, I>( &self, scripts: I, ) -> Result<Vec<GetBalanceRes>, Error>
script_get_balance. Read moreSource§fn script_get_history(
&self,
script: &Script,
) -> Result<Vec<GetHistoryRes>, Error>
fn script_get_history( &self, script: &Script, ) -> Result<Vec<GetHistoryRes>, Error>
Source§fn batch_script_get_history<'s, I>(
&self,
scripts: I,
) -> Result<Vec<Vec<GetHistoryRes>>, Error>
fn batch_script_get_history<'s, I>( &self, scripts: I, ) -> Result<Vec<Vec<GetHistoryRes>>, Error>
script_get_history. Read moreSource§fn script_list_unspent(
&self,
script: &Script,
) -> Result<Vec<ListUnspentRes>, Error>
fn script_list_unspent( &self, script: &Script, ) -> Result<Vec<ListUnspentRes>, Error>
Source§fn batch_script_list_unspent<'s, I>(
&self,
scripts: I,
) -> Result<Vec<Vec<ListUnspentRes>>, Error>
fn batch_script_list_unspent<'s, I>( &self, scripts: I, ) -> Result<Vec<Vec<ListUnspentRes>>, Error>
script_list_unspent. Read moreSource§fn transaction_get_raw(&self, txid: &Txid) -> Result<Vec<u8>, Error>
fn transaction_get_raw(&self, txid: &Txid) -> Result<Vec<u8>, Error>
txid. Returns an error if not found.Source§fn batch_transaction_get_raw<'t, I>(
&self,
txids: I,
) -> Result<Vec<Vec<u8>>, Error>
fn batch_transaction_get_raw<'t, I>( &self, txids: I, ) -> Result<Vec<Vec<u8>>, Error>
transaction_get_raw. Read moreSource§fn batch_block_header_raw<'s, I>(
&self,
heights: I,
) -> Result<Vec<Vec<u8>>, Error>
fn batch_block_header_raw<'s, I>( &self, heights: I, ) -> Result<Vec<Vec<u8>>, Error>
block_header_raw. Read moreSource§fn batch_estimate_fee<'s, I>(&self, numbers: I) -> Result<Vec<f64>, Error>
fn batch_estimate_fee<'s, I>(&self, numbers: I) -> Result<Vec<f64>, Error>
estimate_fee. Read moreSource§fn transaction_broadcast_raw(&self, raw_tx: &[u8]) -> Result<Txid, Error>
fn transaction_broadcast_raw(&self, raw_tx: &[u8]) -> Result<Txid, Error>
Source§fn transaction_get_merkle(
&self,
txid: &Txid,
height: usize,
) -> Result<GetMerkleRes, Error>
fn transaction_get_merkle( &self, txid: &Txid, height: usize, ) -> Result<GetMerkleRes, Error>
txid confirmed in the block at height.Source§fn batch_transaction_get_merkle<I>(
&self,
txids_and_heights: I,
) -> Result<Vec<GetMerkleRes>, Error>
fn batch_transaction_get_merkle<I>( &self, txids_and_heights: I, ) -> Result<Vec<GetMerkleRes>, Error>
transaction_get_merkle. Read moreSource§fn txid_from_pos(&self, height: usize, tx_pos: usize) -> Result<Txid, Error>
fn txid_from_pos(&self, height: usize, tx_pos: usize) -> Result<Txid, Error>
height and a tx_pos in the block.Source§fn txid_from_pos_with_merkle(
&self,
height: usize,
tx_pos: usize,
) -> Result<TxidFromPosRes, Error>
fn txid_from_pos_with_merkle( &self, height: usize, tx_pos: usize, ) -> Result<TxidFromPosRes, Error>
height and a tx_pos in the
block.Source§fn server_features(&self) -> Result<ServerFeaturesRes, Error>
fn server_features(&self) -> Result<ServerFeaturesRes, Error>
Source§fn ping(&self) -> Result<(), Error>
fn ping(&self) -> Result<(), Error>
Source§fn block_header(&self, height: usize) -> Result<Header, Error>
fn block_header(&self, height: usize) -> Result<Header, Error>
height.Source§fn block_headers_subscribe(&self) -> Result<HeaderNotification, Error>
fn block_headers_subscribe(&self) -> Result<HeaderNotification, Error>
blockchain.headers.subscribe call.Source§fn block_headers_pop(&self) -> Result<Option<HeaderNotification>, Error>
fn block_headers_pop(&self) -> Result<Option<HeaderNotification>, Error>
None if there are no items in the queue.Source§fn transaction_get(&self, txid: &Txid) -> Result<Transaction, Error>
fn transaction_get(&self, txid: &Txid) -> Result<Transaction, Error>
txid. Returns an error if not found.Source§fn batch_transaction_get<'t, I>(
&self,
txids: I,
) -> Result<Vec<Transaction>, Error>
fn batch_transaction_get<'t, I>( &self, txids: I, ) -> Result<Vec<Transaction>, Error>
transaction_get. Read moreSource§fn batch_block_header<I>(&self, heights: I) -> Result<Vec<Header>, Error>
fn batch_block_header<I>(&self, heights: I) -> Result<Vec<Header>, Error>
block_header. Read more