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: ClientThe underlying JSON-RPC client connected to the Elements node.
auth: AuthThe authentication credentials used.
url: StringThe URL endpoint of the node.
Implementations§
Source§impl ElementsRpc
impl ElementsRpc
Sourcepub fn new(url: String, auth: Auth) -> Result<ElementsRpc, RpcError>
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.
Sourcepub fn send_to_address(
&self,
address: &Address,
satoshi: u64,
asset: Option<AssetId>,
) -> Result<Txid, RpcError>
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.
Sourcepub fn rescan_blockchain(
&self,
start: Option<u64>,
stop: Option<u64>,
) -> Result<(), RpcError>
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.
Sourcepub fn generate_blocks(&self, block_num: u64) -> Result<(), RpcError>
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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ElementsRpc
impl !RefUnwindSafe for ElementsRpc
impl Send for ElementsRpc
impl Sync for ElementsRpc
impl Unpin for ElementsRpc
impl UnsafeUnpin for ElementsRpc
impl !UnwindSafe for ElementsRpc
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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