Struct electrum_jsonrpc::Electrum[][src]

pub struct Electrum { /* fields omitted */ }
Expand description

Electrum JSON-RPC client.

Client represents methods for making json-rpc calls to Electrum daemon.

Examples


#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Electrum::new(
        "dummy_login".to_string(),
        "dummy_password".to_string(),
        "http://127.0.0.1:7000".to_string(),
    )?;

    let resp = client.get_help().await?;

    Ok(())
}

Implementations

impl Electrum[src]

pub fn new(login: String, password: String, address: String) -> Result<Self>[src]

Create new ElectrumRpc instance

pub async fn get_help(&self) -> Result<Response<Body>>[src]

List all available JSON-RPC calls

pub async fn get_info(&self) -> Result<Response<Body>>[src]

Fetch the blockchain network info

pub async fn get_balance(&self) -> Result<Response<Body>>[src]

Return the balance of your wallet.

pub async fn get_address_history<'a>(
    &self,
    address: &BtcAddress<'a>
) -> Result<Response<Body>>
[src]

Return the transaction history of any address. Note: This is a walletless server query, results are not checked by SPV.

pub async fn get_address_balance<'a>(
    &self,
    address: &BtcAddress<'a>
) -> Result<Response<Body>>
[src]

Return the balance of any address. Note: This is a walletless server query, results are not checked by SPV.

pub async fn list_wallets(&self) -> Result<Response<Body>>[src]

List wallets opened in daemon

pub async fn load_wallet(
    &self,
    wallet_path: Option<PathBuf>,
    password: Option<&str>
) -> Result<Response<Body>>
[src]

Open wallet in daemon

pub async fn create_wallet(&self) -> Result<Response<Body>>[src]

Create a new wallet

pub async fn list_addresses(&self) -> Result<Response<Body>>[src]

List wallet addresses. Returns the list of all addresses in your wallet. Use optional arguments to filter the results

pub async fn notify<'a>(
    &self,
    address: &BtcAddress<'a>,
    url: Option<Uri>
) -> Result<Response<Body>>
[src]

Watch an address. Every time the address changes, a http POST is sent to the URL. Call with an None URL to stop watching an address.

pub async fn restore_wallet(&self, text: &str) -> Result<Response<Body>>[src]

Restore a wallet from text. text can be a seed phrase, a master public key, a master private key, a list of bitcoin addresses or bitcoin private keys.

pub async fn sign_transaction(&self, tx: &str) -> Result<Response<Body>>[src]

Sign a transaction. The wallet keys will be used unless a private key is provided.

pub async fn broadcast(&self, tx: &str) -> Result<Response<Body>>[src]

Broadcast a transaction to the network.

pub async fn pay_to<'a>(
    &self,
    destination: &BtcAddress<'a>,
    amount: Decimal,
    fee: Option<Decimal>
) -> Result<Response<Body>>
[src]

Create a transaction.

pub async fn pay_to_many(
    &self,
    fee: Decimal,
    outputs: Vec<(String, Decimal)>
) -> Result<Response<Body>>
[src]

Create a multi-output transaction.

pub async fn close_wallet(&self) -> Result<Response<Body>>[src]

Close opened wallet.

pub async fn add_request(
    &self,
    amount: Decimal,
    memo: Option<&str>
) -> Result<Response<Body>>
[src]

Create a payment request, using the first unused address of the wallet. The address will be considered as used after this operation. If no payment is received, the address will be considered as unused if the payment request is deleted from the wallet.

pub async fn list_requests(
    &self,
    pending: bool,
    expired: bool,
    paid: bool
) -> Result<Response<Body>>
[src]

List the payment requests you made. You can combine pending, expired and paid flags for filtering.

pub async fn remove_request<'a>(
    &self,
    address: &BtcAddress<'a>
) -> Result<Response<Body>>
[src]

pub async fn get_fee_rate(&self) -> Result<Response<Body>>[src]

Return current suggested fee rate (in sat/kvByte), according to config settings of electrum.

Auto Trait Implementations

impl !RefUnwindSafe for Electrum

impl Send for Electrum

impl Sync for Electrum

impl Unpin for Electrum

impl !UnwindSafe for Electrum

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.