Struct iota_client::client::Client

source ·
pub struct Client { /* private fields */ }
Expand description

An instance of the client using HORNET or Bee URI

Implementations§

source§

impl Client

source

pub fn builder() -> ClientBuilder

Create the builder to instntiate the IOTA Client.

source

pub async fn get_node(&self) -> Result<Node>

Get a node candidate from the synced node pool.

source

pub async fn get_network_id(&self) -> Result<u64>

Gets the network id of the node we’re connecting to.

source

pub async fn get_pow_provider(&self) -> ClientMiner

Gets the miner to use based on the PoW setting

source

pub async fn get_network_info(&self) -> Result<NetworkInfo>

Gets the network related information such as network_id and min_pow_score and if it’s the default one, sync it first.

source

pub async fn get_bech32_hrp(&self) -> Result<String>

returns the bech32_hrp

source

pub async fn get_min_pow_score(&self) -> Result<f64>

returns the min pow score

source

pub async fn get_tips_interval(&self) -> u64

returns the tips interval

source

pub async fn get_local_pow(&self) -> bool

returns the local pow

source

pub async fn get_fallback_to_local_pow(&self) -> bool

returns the fallback_to_local_pow

source

pub async fn unsynced_nodes(&self) -> HashSet<&Node>

returns the unsynced nodes.

source

pub fn generate_mnemonic() -> Result<String>

Generates a new mnemonic.

source

pub fn mnemonic_to_hex_seed(mnemonic: &str) -> Result<String>

Returns a hex encoded seed for a mnemonic.

source

pub async fn find_inputs( &self, addresses: Vec<String>, amount: u64 ) -> Result<Vec<UtxoInput>>

Function to find inputs from addresses for a provided amount (useful for offline signing)

source

pub async fn get_node_health(url: &str) -> Result<bool>

GET /health endpoint

source

pub async fn get_health(&self) -> Result<bool>

GET /health endpoint

source

pub async fn get_node_info( url: &str, jwt: Option<String>, auth_name_pwd: Option<(&str, &str)> ) -> Result<NodeInfo>

GET /api/v1/info endpoint

source

pub async fn get_info(&self) -> Result<NodeInfoWrapper>

GET /api/v1/info endpoint

source

pub async fn get_peers(&self) -> Result<Vec<PeerDto>>

GET /api/v1/peers endpoint

source

pub async fn get_tips(&self) -> Result<Vec<MessageId>>

GET /api/v1/tips endpoint

source

pub async fn post_message(&self, message: &Message) -> Result<MessageId>

POST /api/v1/messages endpoint

source

pub async fn post_message_json(&self, message: &Message) -> Result<MessageId>

POST JSON to /api/v1/messages endpoint

source

pub fn get_message(&self) -> GetMessageBuilder<'_>

GET /api/v1/messages/{messageId} endpoint

source

pub async fn get_output(&self, output_id: &UtxoInput) -> Result<OutputResponse>

GET /api/v1/outputs/{outputId} endpoint Find an output by its transaction_id and corresponding output_index.

source

pub async fn find_outputs( &self, outputs: &[UtxoInput], addresses: &[String] ) -> Result<Vec<OutputResponse>>

Find all outputs based on the requests criteria. This method will try to query multiple nodes if the request amount exceeds individual node limit.

source

pub fn get_address(&self) -> GetAddressBuilder<'_>

GET /api/v1/addresses/{address} endpoint

source

pub async fn get_milestone(&self, index: u32) -> Result<MilestoneResponse>

GET /api/v1/milestones/{index} endpoint Get the milestone by the given index.

source

pub async fn get_milestone_utxo_changes( &self, index: u32 ) -> Result<MilestoneUTXOChanges>

GET /api/v1/milestones/{index}/utxo-changes endpoint Get the milestone by the given index.

source

pub async fn get_receipts(&self) -> Result<Vec<ReceiptDto>>

GET /api/v1/receipts endpoint Get all receipts.

source

pub async fn get_receipts_migrated_at( &self, milestone_index: u32 ) -> Result<Vec<ReceiptDto>>

GET /api/v1/receipts/{migratedAt} endpoint Get the receipts by the given milestone index.

source

pub async fn get_treasury(&self) -> Result<TreasuryResponse>

GET /api/v1/treasury endpoint Get the treasury output.

source

pub async fn get_included_message( &self, transaction_id: &TransactionId ) -> Result<Message>

GET /api/v1/transactions/{transactionId}/included-message Returns the included message of the transaction.

source

pub async fn reattach( &self, message_id: &MessageId ) -> Result<(MessageId, Message)>

Reattaches messages for provided message id. Messages can be reattached only if they are valid and haven’t been confirmed for a while.

source

pub async fn reattach_unchecked( &self, message_id: &MessageId ) -> Result<(MessageId, Message)>

Reattach a message without checking if it should be reattached

source

pub async fn promote( &self, message_id: &MessageId ) -> Result<(MessageId, Message)>

Promotes a message. The method should validate if a promotion is necessary through get_message. If not, the method should error out and should not allow unnecessary promotions.

source

pub async fn promote_unchecked( &self, message_id: &MessageId ) -> Result<(MessageId, Message)>

Promote a message without checking if it should be promoted

source

pub fn message(&self) -> ClientMessageBuilder<'_>

A generic send function for easily sending transaction or indexation messages.

source

pub fn get_unspent_address<'a>( &'a self, seed: &'a Seed ) -> GetUnspentAddressBuilder<'a>

Return a valid unspent address.

source

pub fn get_addresses<'a>(&'a self, seed: &'a Seed) -> GetAddressesBuilder<'a>

Return a list of addresses from the seed regardless of their validity.

source

pub async fn find_messages<I: AsRef<[u8]>>( &self, indexation_keys: &[I], message_ids: &[MessageId] ) -> Result<Vec<Message>>

Find all messages by provided message IDs and/or indexation_keys.

source

pub fn get_balance<'a>(&'a self, seed: &'a Seed) -> GetBalanceBuilder<'a>

Return the balance for a provided seed Addresses with balance must be consecutive, so this method will return once it encounters a zero balance address.

source

pub async fn get_address_balances( &self, addresses: &[String] ) -> Result<Vec<BalanceAddressResponse>>

Return the balance in iota for the given addresses; No seed needed to do this since we are only checking and already know the addresses.

source

pub fn bech32_to_hex(bech32: &str) -> Result<String>

Transforms bech32 to hex

source

pub async fn hex_to_bech32( &self, hex: &str, bech32_hrp: Option<&str> ) -> Result<String>

Transforms a hex encoded address to a bech32 encoded address

source

pub async fn hex_public_key_to_bech32_address( &self, hex: &str, bech32_hrp: Option<&str> ) -> Result<String>

Transforms a hex encoded public key to a bech32 encoded address

source

pub fn parse_bech32_address(address: &str) -> Result<Address>

Returns a valid Address parsed from a String.

source

pub fn is_address_valid(address: &str) -> bool

Checks if a String is a valid bech32 encoded address.

source

pub async fn retry( &self, message_id: &MessageId ) -> Result<(MessageId, Message)>

Retries (promotes or reattaches) a message for provided message id. Message should only be retried only if they are valid and haven’t been confirmed for a while.

source

pub async fn retry_until_included( &self, message_id: &MessageId, interval: Option<u64>, max_attempts: Option<u64> ) -> Result<Vec<(MessageId, Message)>>

Retries (promotes or reattaches) a message for provided message id until it’s included (referenced by a milestone). Default interval is 5 seconds and max attempts is 40. Returns the included message at first position and additional reattached messages

source

pub async fn consolidate_funds( &self, seed: &Seed, account_index: usize, address_range: Range<usize> ) -> Result<String>

Function to consolidate all funds from a range of addresses to the address with the lowest index in that range Returns the address to which the funds got consolidated, if any were available

Trait Implementations§

source§

impl Debug for Client

source§

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

Formats the value using the given formatter. Read more
source§

impl Drop for Client

source§

fn drop(&mut self)

Gracefully shutdown the Client

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more