pub struct Client { /* private fields */ }Implementations§
Source§impl Client
impl Client
Sourcepub fn new(address: &str, port: u16) -> Result<Self, Error>
pub fn new(address: &str, port: u16) -> Result<Self, Error>
Create a new electrum client.
§Arguments
address- url/ip of the electrum server as Stringport- port of the electrum server
Sourcepub fn new_local(address: &str, port: u16) -> Result<Self, Error>
pub fn new_local(address: &str, port: u16) -> Result<Self, Error>
Create a new local electrum client: SSL certificate validation id disabled in order to be used with self-signed certificates.
§Arguments
address- url/ip of the electrum server as Stringport- port of the electrum server
pub fn listen<RQ, RS>(self) -> (Sender<RQ>, Receiver<RS>)where
RQ: Into<CoinRequest> + Debug + Send + 'static,
RS: From<CoinResponse> + Debug + Send + 'static,
Sourcepub fn get_tx(&mut self, txid: Txid) -> Result<Transaction, Error>
pub fn get_tx(&mut self, txid: Txid) -> Result<Transaction, Error>
Try to get a transaction by its txid
§Errors
This function will return an error if:
- fail to send the request
- parsing response fails
- the response is not of expected type
- the transaction does not exists
Sourcepub fn get_coins_at(
&mut self,
script: &Script,
) -> Result<(Vec<(TxOut, OutPoint)>, HashMap<Txid, Transaction>), Error>
pub fn get_coins_at( &mut self, script: &Script, ) -> Result<(Vec<(TxOut, OutPoint)>, HashMap<Txid, Transaction>), Error>
Get coins that pay to the given spk and their related transaction. This method will make several calls to the electrum server:
- it will first request a list of all transactions txid that have an output paying to the spk.
- it will then fetch all txs, store them and extract all the coins that pay to the given spk.
- it will return a list of (TxOut, OutPoint) and a map of transactions.
§Errors
This function will return an error if:
- a call to the electrum server fail
Sourcepub fn get_coins_tx_at(&mut self, script: &Script) -> Result<Vec<Txid>, Error>
pub fn get_coins_tx_at(&mut self, script: &Script) -> Result<Vec<Txid>, Error>
Get a list of txid of all transaction that have an output paying to the given spk
§Errors
This function will return an error if:
- fail sending the request
- receive a wrong response
Sourcepub fn broadcast(&mut self, tx: &Transaction) -> Result<(), Error>
pub fn broadcast(&mut self, tx: &Transaction) -> Result<(), Error>
Broadcast the given transaction.
§Errors
This function will return an error if:
- fail to send the request
- get a wrong response
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
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