Skip to main content

ElementsRpc

Struct ElementsRpc 

Source
pub struct ElementsRpc {
    pub inner: Client,
    pub auth: Auth,
    pub url: String,
}
Expand description

A lightweight wrapper around the standard bitcoincore_rpc Client providing Elements-specific functionality.

Fields§

§inner: Client

The underlying JSON-RPC client connected to the Elements node.

§auth: Auth

The authentication credentials used.

§url: String

The URL endpoint of the node.

Implementations§

Source§

impl ElementsRpc

Source

pub fn new(url: String, auth: Auth) -> Result<ElementsRpc, RpcError>

Creates a new ElementsRpc client.

§Errors

Returns an RpcError if it fails to initialize the connection or if a liveness ping fails.

Source

pub fn get_new_address(&self, label: &str) -> Result<Address, RpcError>

Requests a new wallet address from the node, mapped to the provided label.

§Errors

Returns an RpcError if the node fails to generate an address or yields an invalid string payload.

§Panics

Panics if the returned JSON value is not a string, or if the string cannot be parsed into a valid Address.

Source

pub fn send_to_address( &self, address: &Address, satoshi: u64, asset: Option<AssetId>, ) -> Result<Txid, RpcError>

Instructs the node to transfer funds directly to the target address.

§Errors

Returns an RpcError if the node returns an error or returns an invalid Txid payload.

§Panics

Panics if the satoshi amount cannot be converted to a valid BTC amount, if the returned JSON value is not a string, or if the string cannot be parsed into a valid Txid.

Source

pub fn rescan_blockchain( &self, start: Option<u64>, stop: Option<u64>, ) -> Result<(), RpcError>

Instructs the node to rescan the block chain for missed wallet transactions.

§Errors

Returns an RpcError if the node fails the RPC call.

Source

pub fn generate_blocks(&self, block_num: u64) -> Result<(), RpcError>

Mines a specified number of new blocks mapping generated rewards to a newly generated wallet address.

§Errors

Returns an RpcError if generating the address or calling the generatetoaddress RPC command fails.

Source

pub fn sweep_initialfreecoins(&self) -> Result<(), RpcError>

Instructs the node to sweep the initialfreecoins balance generated by standard regtest genesis blocks.

§Errors

Returns an RpcError if the getnewaddress or sendtoaddress RPC commands fail.

Source

pub fn height(&self) -> Result<u64, RpcError>

Retrieves the current block chain tip height.

§Errors

Returns an RpcError if the node call fails or yields a JSON structure that does not map successfully to a u64.

Trait Implementations§

Source§

impl Debug for ElementsRpc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V