Trait electrum_client::ElectrumApi
source · [−]pub trait ElectrumApi {
Show 31 methods
fn batch_call(&self, batch: &Batch) -> Result<Vec<Value>, Error>;
fn block_headers_subscribe_raw(
&self
) -> Result<RawHeaderNotification, Error>;
fn block_headers_pop_raw(
&self
) -> Result<Option<RawHeaderNotification>, Error>;
fn block_header_raw(&self, height: usize) -> Result<Vec<u8>, Error>;
fn block_headers(
&self,
start_height: usize,
count: usize
) -> Result<GetHeadersRes, Error>;
fn estimate_fee(&self, number: usize) -> Result<f64, Error>;
fn relay_fee(&self) -> Result<f64, Error>;
fn script_subscribe(
&self,
script: &Script
) -> Result<Option<ScriptStatus>, Error>;
fn script_unsubscribe(&self, script: &Script) -> Result<bool, Error>;
fn script_pop(&self, script: &Script) -> Result<Option<ScriptStatus>, Error>;
fn script_get_balance(
&self,
script: &Script
) -> Result<GetBalanceRes, Error>;
fn batch_script_get_balance<'s, I>(
&self,
scripts: I
) -> Result<Vec<GetBalanceRes>, Error>
where
I: IntoIterator<Item = &'s Script> + Clone;
fn script_get_history(
&self,
script: &Script
) -> Result<Vec<GetHistoryRes>, Error>;
fn batch_script_get_history<'s, I>(
&self,
scripts: I
) -> Result<Vec<Vec<GetHistoryRes>>, Error>
where
I: IntoIterator<Item = &'s Script> + Clone;
fn script_list_unspent(
&self,
script: &Script
) -> Result<Vec<ListUnspentRes>, Error>;
fn batch_script_list_unspent<'s, I>(
&self,
scripts: I
) -> Result<Vec<Vec<ListUnspentRes>>, Error>
where
I: IntoIterator<Item = &'s Script> + Clone;
fn transaction_get_raw(&self, txid: &Txid) -> Result<Vec<u8>, Error>;
fn batch_transaction_get_raw<'t, I>(
&self,
txids: I
) -> Result<Vec<Vec<u8>>, Error>
where
I: IntoIterator<Item = &'t Txid> + Clone;
fn batch_block_header_raw<I>(
&self,
heights: I
) -> Result<Vec<Vec<u8>>, Error>
where
I: IntoIterator<Item = u32> + Clone;
fn batch_estimate_fee<I>(&self, numbers: I) -> Result<Vec<f64>, Error>
where
I: IntoIterator<Item = usize> + Clone;
fn transaction_broadcast_raw(&self, raw_tx: &[u8]) -> Result<Txid, Error>;
fn transaction_get_merkle(
&self,
txid: &Txid,
height: usize
) -> Result<GetMerkleRes, Error>;
fn server_features(&self) -> Result<ServerFeaturesRes, Error>;
fn ping(&self) -> Result<(), Error>;
fn block_header(&self, height: usize) -> Result<BlockHeader, Error> { ... }
fn block_headers_subscribe(&self) -> Result<HeaderNotification, Error> { ... }
fn block_headers_pop(&self) -> Result<Option<HeaderNotification>, Error> { ... }
fn transaction_get(&self, txid: &Txid) -> Result<Transaction, Error> { ... }
fn batch_transaction_get<'t, I>(
&self,
txids: I
) -> Result<Vec<Transaction>, Error>
where
I: IntoIterator<Item = &'t Txid> + Clone,
{ ... }
fn batch_block_header<I>(
&self,
heights: I
) -> Result<Vec<BlockHeader>, Error>
where
I: IntoIterator<Item = u32> + Clone,
{ ... }
fn transaction_broadcast(&self, tx: &Transaction) -> Result<Txid, Error> { ... }
}
Expand description
API calls exposed by an Electrum client
Required Methods
Execute a queue of calls stored in a Batch
struct. Returns
Ok()
only if all of the calls are successful. The order of the JSON Value
s returned
reflects the order in which the calls were made on the Batch
struct.
fn 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.
fn 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.
Gets the raw bytes of block header for height height
.
fn 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
.
Estimates the fee required in Satoshis per kilobyte to confirm a transaction in number
blocks.
Returns the minimum accepted fee by the server’s node in Bitcoin, not Satoshi.
fn 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.
Returns a ScriptStatus
when successful that represents
the current status for the requested script.
Returns Error::AlreadySubscribed
if
already subscribed to the script.
Subscribes to notifications for activity on a specific scriptPubKey.
Returns a bool
with the server response when successful.
Returns Error::NotSubscribed
if
not subscribed to the script.
fn 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.
fn 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.
fn 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
.
Takes a list of scripts and returns a list of balance responses.
fn 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
fn 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
.
Takes a list of scripts and returns a list of history responses.
fn 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
fn 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
.
Takes a list of scripts and returns a list of a list of utxos.
Gets the raw bytes of a transaction with txid
. Returns an error if not found.
fn 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
.
Takes a list of txids
and returns a list of transactions raw bytes.
fn batch_block_header_raw<I>(&self, heights: I) -> Result<Vec<Vec<u8>>, Error> where
I: IntoIterator<Item = u32> + Clone,
fn batch_block_header_raw<I>(&self, heights: I) -> Result<Vec<Vec<u8>>, Error> where
I: IntoIterator<Item = u32> + Clone,
Batch version of block_header_raw
.
Takes a list of heights
of blocks and returns a list of block header raw bytes.
fn batch_estimate_fee<I>(&self, numbers: I) -> Result<Vec<f64>, Error> where
I: IntoIterator<Item = usize> + Clone,
fn batch_estimate_fee<I>(&self, numbers: I) -> Result<Vec<f64>, Error> where
I: IntoIterator<Item = usize> + Clone,
Batch version of estimate_fee
.
Takes a list of numbers
of blocks and returns a list of fee required in
Satoshis per kilobyte to confirm a transaction in the given number of blocks.
Broadcasts the raw bytes of a transaction to the network.
fn 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
.
fn server_features(&self) -> Result<ServerFeaturesRes, Error>
fn server_features(&self) -> Result<ServerFeaturesRes, Error>
Returns the capabilities of the server.
Provided Methods
fn block_header(&self, height: usize) -> Result<BlockHeader, Error>
fn block_header(&self, height: usize) -> Result<BlockHeader, Error>
Gets the block header for height height
.
fn 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.
fn 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.
fn 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.
fn 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
.
Takes a list of txids
and returns a list of transactions.
fn 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
.
Takes a list of heights
of blocks and returns a list of headers.
fn transaction_broadcast(&self, tx: &Transaction) -> Result<Txid, Error>
fn transaction_broadcast(&self, tx: &Transaction) -> Result<Txid, Error>
Broadcasts a transaction to the network.