Struct electrum_client::raw_client::RawClient
source · [−]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
sourceimpl 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
sourceimpl 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
sourceimpl<T: Read + Write> ElectrumApi for RawClient<T>
impl<T: Read + Write> ElectrumApi for RawClient<T>
sourcefn 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>
Executes the requested API call returning the raw answer.
sourcefn block_headers_subscribe_raw(&self) -> Result<RawHeaderNotification, Error>
fn block_headers_subscribe_raw(&self) -> Result<RawHeaderNotification, Error>
Subscribes to notifications for new block headers, by sending a blockchain.headers.subscribe
call and
returns the current tip as raw bytes instead of deserializing them. Read more
sourcefn block_headers_pop_raw(&self) -> Result<Option<RawHeaderNotification>, Error>
fn block_headers_pop_raw(&self) -> Result<Option<RawHeaderNotification>, Error>
Tries to pop one queued notification for a new block header that we might have received. Returns a the header in raw bytes if a notification is found in the queue, None otherwise. Read more
sourcefn block_header_raw(&self, height: usize) -> Result<Vec<u8>, Error>
fn block_header_raw(&self, height: usize) -> Result<Vec<u8>, Error>
Gets the raw bytes of block header for height height
.
sourcefn block_headers(
&self,
start_height: usize,
count: usize
) -> Result<GetHeadersRes, Error>
fn block_headers(
&self,
start_height: usize,
count: usize
) -> Result<GetHeadersRes, Error>
Tries to fetch count
block headers starting from start_height
.
sourcefn estimate_fee(&self, number: usize) -> Result<f64, Error>
fn estimate_fee(&self, number: usize) -> Result<f64, Error>
Estimates the fee required in Bitcoin per kilobyte to confirm a transaction in number
blocks.
sourcefn relay_fee(&self) -> Result<f64, Error>
fn relay_fee(&self) -> Result<f64, Error>
Returns the minimum accepted fee by the server’s node in Bitcoin, not Satoshi.
sourcefn script_subscribe(
&self,
script: &Script
) -> Result<Option<ScriptStatus>, Error>
fn script_subscribe(
&self,
script: &Script
) -> Result<Option<ScriptStatus>, Error>
Subscribes to notifications for activity on a specific scriptPubKey. Read more
sourcefn script_unsubscribe(&self, script: &Script) -> Result<bool, Error>
fn script_unsubscribe(&self, script: &Script) -> Result<bool, Error>
Subscribes to notifications for activity on a specific scriptPubKey. Read more
sourcefn script_pop(&self, script: &Script) -> Result<Option<ScriptStatus>, Error>
fn script_pop(&self, script: &Script) -> Result<Option<ScriptStatus>, Error>
Tries to pop one queued notification for a the requested script. Returns None
if there are no items in the queue.
sourcefn script_get_balance(&self, script: &Script) -> Result<GetBalanceRes, Error>
fn script_get_balance(&self, script: &Script) -> Result<GetBalanceRes, Error>
Returns the balance for a scriptPubKey.
sourcefn batch_script_get_balance<'s, I>(
&self,
scripts: I
) -> Result<Vec<GetBalanceRes>, Error>where
I: IntoIterator<Item = &'s Script> + Clone,
fn batch_script_get_balance<'s, I>(
&self,
scripts: I
) -> Result<Vec<GetBalanceRes>, Error>where
I: IntoIterator<Item = &'s Script> + Clone,
Batch version of script_get_balance
. Read more
sourcefn script_get_history(
&self,
script: &Script
) -> Result<Vec<GetHistoryRes>, Error>
fn script_get_history(
&self,
script: &Script
) -> Result<Vec<GetHistoryRes>, Error>
Returns the history for a scriptPubKey
sourcefn batch_script_get_history<'s, I>(
&self,
scripts: I
) -> Result<Vec<Vec<GetHistoryRes>>, Error>where
I: IntoIterator<Item = &'s Script> + Clone,
fn batch_script_get_history<'s, I>(
&self,
scripts: I
) -> Result<Vec<Vec<GetHistoryRes>>, Error>where
I: IntoIterator<Item = &'s Script> + Clone,
Batch version of script_get_history
. Read more
sourcefn script_list_unspent(
&self,
script: &Script
) -> Result<Vec<ListUnspentRes>, Error>
fn script_list_unspent(
&self,
script: &Script
) -> Result<Vec<ListUnspentRes>, Error>
Returns the list of unspent outputs for a scriptPubKey
sourcefn batch_script_list_unspent<'s, I>(
&self,
scripts: I
) -> Result<Vec<Vec<ListUnspentRes>>, Error>where
I: IntoIterator<Item = &'s Script> + Clone,
fn batch_script_list_unspent<'s, I>(
&self,
scripts: I
) -> Result<Vec<Vec<ListUnspentRes>>, Error>where
I: IntoIterator<Item = &'s Script> + Clone,
Batch version of script_list_unspent
. Read more
sourcefn transaction_get_raw(&self, txid: &Txid) -> Result<Vec<u8>, Error>
fn transaction_get_raw(&self, txid: &Txid) -> Result<Vec<u8>, Error>
Gets the raw bytes of a transaction with txid
. Returns an error if not found.
sourcefn batch_transaction_get_raw<'t, I>(
&self,
txids: I
) -> Result<Vec<Vec<u8>>, Error>where
I: IntoIterator<Item = &'t Txid> + Clone,
fn batch_transaction_get_raw<'t, I>(
&self,
txids: I
) -> Result<Vec<Vec<u8>>, Error>where
I: IntoIterator<Item = &'t Txid> + Clone,
Batch version of transaction_get_raw
. Read more
sourcefn batch_block_header_raw<'s, I>(
&self,
heights: I
) -> Result<Vec<Vec<u8>>, Error>where
I: IntoIterator<Item = u32> + Clone,
fn batch_block_header_raw<'s, I>(
&self,
heights: I
) -> Result<Vec<Vec<u8>>, Error>where
I: IntoIterator<Item = u32> + Clone,
Batch version of block_header_raw
. Read more
sourcefn batch_estimate_fee<'s, I>(&self, numbers: I) -> Result<Vec<f64>, Error>where
I: IntoIterator<Item = usize> + Clone,
fn batch_estimate_fee<'s, I>(&self, numbers: I) -> Result<Vec<f64>, Error>where
I: IntoIterator<Item = usize> + Clone,
Batch version of estimate_fee
. Read more
sourcefn transaction_broadcast_raw(&self, raw_tx: &[u8]) -> Result<Txid, Error>
fn transaction_broadcast_raw(&self, raw_tx: &[u8]) -> Result<Txid, Error>
Broadcasts the raw bytes of a transaction to the network.
sourcefn transaction_get_merkle(
&self,
txid: &Txid,
height: usize
) -> Result<GetMerkleRes, Error>
fn transaction_get_merkle(
&self,
txid: &Txid,
height: usize
) -> Result<GetMerkleRes, Error>
Returns the merkle path for the transaction txid
confirmed in the block at height
.
sourcefn server_features(&self) -> Result<ServerFeaturesRes, Error>
fn server_features(&self) -> Result<ServerFeaturesRes, Error>
Returns the capabilities of the server.
sourcefn ping(&self) -> Result<(), Error>
fn ping(&self) -> Result<(), Error>
Pings the server. This method can also be used as a “dummy” call to trigger the processing of incoming block header or script notifications. Read more
sourcefn block_header(&self, height: usize) -> Result<BlockHeader, Error>
fn block_header(&self, height: usize) -> Result<BlockHeader, Error>
Gets the block header for height height
.
sourcefn block_headers_subscribe(&self) -> Result<HeaderNotification, Error>
fn block_headers_subscribe(&self) -> Result<HeaderNotification, Error>
Subscribes to notifications for new block headers, by sending a blockchain.headers.subscribe
call.
sourcefn block_headers_pop(&self) -> Result<Option<HeaderNotification>, Error>
fn block_headers_pop(&self) -> Result<Option<HeaderNotification>, Error>
Tries to pop one queued notification for a new block header that we might have received.
Returns None
if there are no items in the queue. Read more
sourcefn transaction_get(&self, txid: &Txid) -> Result<Transaction, Error>
fn transaction_get(&self, txid: &Txid) -> Result<Transaction, Error>
Gets the transaction with txid
. Returns an error if not found.
sourcefn batch_transaction_get<'t, I>(
&self,
txids: I
) -> Result<Vec<Transaction>, Error>where
I: IntoIterator<Item = &'t Txid> + Clone,
fn batch_transaction_get<'t, I>(
&self,
txids: I
) -> Result<Vec<Transaction>, Error>where
I: IntoIterator<Item = &'t Txid> + Clone,
Batch version of transaction_get
. Read more
sourcefn batch_block_header<I>(&self, heights: I) -> Result<Vec<BlockHeader>, Error>where
I: IntoIterator<Item = u32> + Clone,
fn batch_block_header<I>(&self, heights: I) -> Result<Vec<BlockHeader>, Error>where
I: IntoIterator<Item = u32> + Clone,
Batch version of block_header
. Read more
sourcefn transaction_broadcast(&self, tx: &Transaction) -> Result<Txid, Error>
fn transaction_broadcast(&self, tx: &Transaction) -> Result<Txid, Error>
Broadcasts a transaction to the network.
Auto Trait Implementations
impl<S> RefUnwindSafe for RawClient<S>
impl<S> Send for RawClient<S>where
S: Send,
impl<S> Sync for RawClient<S>where
S: Send,
impl<S> Unpin for RawClient<S>
impl<S> UnwindSafe for RawClient<S>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more