Struct iota_client::client::Client
source · [−]pub struct Client { /* private fields */ }
Expand description
An instance of the client using HORNET or Bee URI
Implementations
sourceimpl Client
impl Client
sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Create the builder to instntiate the IOTA Client.
sourcepub async fn get_network_id(&self) -> Result<u64>
pub async fn get_network_id(&self) -> Result<u64>
Gets the network id of the node we’re connecting to.
sourcepub async fn get_pow_provider(&self) -> ClientMiner
pub async fn get_pow_provider(&self) -> ClientMiner
Gets the miner to use based on the PoW setting
sourcepub async fn get_network_info(&self) -> Result<NetworkInfo>
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.
sourcepub async fn get_bech32_hrp(&self) -> Result<String>
pub async fn get_bech32_hrp(&self) -> Result<String>
returns the bech32_hrp
sourcepub async fn get_min_pow_score(&self) -> Result<f64>
pub async fn get_min_pow_score(&self) -> Result<f64>
returns the min pow score
sourcepub async fn get_tips_interval(&self) -> u64
pub async fn get_tips_interval(&self) -> u64
returns the tips interval
sourcepub async fn get_local_pow(&self) -> bool
pub async fn get_local_pow(&self) -> bool
returns the local pow
sourcepub async fn get_fallback_to_local_pow(&self) -> bool
pub async fn get_fallback_to_local_pow(&self) -> bool
returns the fallback_to_local_pow
sourcepub async fn unsynced_nodes(&self) -> HashSet<&Node>
pub async fn unsynced_nodes(&self) -> HashSet<&Node>
returns the unsynced nodes.
sourcepub fn generate_mnemonic() -> Result<String>
pub fn generate_mnemonic() -> Result<String>
Generates a new mnemonic.
sourcepub fn mnemonic_to_hex_seed(mnemonic: &str) -> Result<String>
pub fn mnemonic_to_hex_seed(mnemonic: &str) -> Result<String>
Returns a hex encoded seed for a mnemonic.
sourcepub async fn find_inputs(
&self,
addresses: Vec<String>,
amount: u64
) -> Result<Vec<UtxoInput>>
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)
sourcepub async fn get_node_health(url: &str) -> Result<bool>
pub async fn get_node_health(url: &str) -> Result<bool>
GET /health endpoint
sourcepub async fn get_health(&self) -> Result<bool>
pub async fn get_health(&self) -> Result<bool>
GET /health endpoint
sourcepub async fn get_node_info(
url: &str,
jwt: Option<String>,
auth_name_pwd: Option<(&str, &str)>
) -> Result<NodeInfo>
pub async fn get_node_info(
url: &str,
jwt: Option<String>,
auth_name_pwd: Option<(&str, &str)>
) -> Result<NodeInfo>
GET /api/v1/info endpoint
sourcepub async fn get_info(&self) -> Result<NodeInfoWrapper>
pub async fn get_info(&self) -> Result<NodeInfoWrapper>
GET /api/v1/info endpoint
sourcepub async fn post_message(&self, message: &Message) -> Result<MessageId>
pub async fn post_message(&self, message: &Message) -> Result<MessageId>
POST /api/v1/messages endpoint
sourcepub async fn post_message_json(&self, message: &Message) -> Result<MessageId>
pub async fn post_message_json(&self, message: &Message) -> Result<MessageId>
POST JSON to /api/v1/messages endpoint
sourcepub fn get_message(&self) -> GetMessageBuilder<'_>
pub fn get_message(&self) -> GetMessageBuilder<'_>
GET /api/v1/messages/{messageId} endpoint
sourcepub async fn get_output(&self, output_id: &UtxoInput) -> Result<OutputResponse>
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.
sourcepub async fn find_outputs(
&self,
outputs: &[UtxoInput],
addresses: &[String]
) -> Result<Vec<OutputResponse>>
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.
sourcepub fn get_address(&self) -> GetAddressBuilder<'_>
pub fn get_address(&self) -> GetAddressBuilder<'_>
GET /api/v1/addresses/{address} endpoint
sourcepub async fn get_milestone(&self, index: u32) -> Result<MilestoneResponse>
pub async fn get_milestone(&self, index: u32) -> Result<MilestoneResponse>
GET /api/v1/milestones/{index} endpoint Get the milestone by the given index.
sourcepub async fn get_milestone_utxo_changes(
&self,
index: u32
) -> Result<MilestoneUTXOChanges>
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.
sourcepub async fn get_receipts(&self) -> Result<Vec<ReceiptDto>>
pub async fn get_receipts(&self) -> Result<Vec<ReceiptDto>>
GET /api/v1/receipts endpoint Get all receipts.
sourcepub async fn get_receipts_migrated_at(
&self,
milestone_index: u32
) -> Result<Vec<ReceiptDto>>
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.
sourcepub async fn get_treasury(&self) -> Result<TreasuryResponse>
pub async fn get_treasury(&self) -> Result<TreasuryResponse>
GET /api/v1/treasury endpoint Get the treasury output.
sourcepub async fn get_included_message(
&self,
transaction_id: &TransactionId
) -> Result<Message>
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.
sourcepub async fn reattach(
&self,
message_id: &MessageId
) -> Result<(MessageId, Message)>
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.
sourcepub async fn reattach_unchecked(
&self,
message_id: &MessageId
) -> Result<(MessageId, Message)>
pub async fn reattach_unchecked(
&self,
message_id: &MessageId
) -> Result<(MessageId, Message)>
Reattach a message without checking if it should be reattached
sourcepub async fn promote(
&self,
message_id: &MessageId
) -> Result<(MessageId, Message)>
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.
sourcepub async fn promote_unchecked(
&self,
message_id: &MessageId
) -> Result<(MessageId, Message)>
pub async fn promote_unchecked(
&self,
message_id: &MessageId
) -> Result<(MessageId, Message)>
Promote a message without checking if it should be promoted
sourcepub fn message(&self) -> ClientMessageBuilder<'_>
pub fn message(&self) -> ClientMessageBuilder<'_>
A generic send function for easily sending transaction or indexation messages.
sourcepub fn get_unspent_address<'a>(
&'a self,
seed: &'a Seed
) -> GetUnspentAddressBuilder<'a>
pub fn get_unspent_address<'a>(
&'a self,
seed: &'a Seed
) -> GetUnspentAddressBuilder<'a>
Return a valid unspent address.
sourcepub fn get_addresses<'a>(&'a self, seed: &'a Seed) -> GetAddressesBuilder<'a>
pub fn get_addresses<'a>(&'a self, seed: &'a Seed) -> GetAddressesBuilder<'a>
Return a list of addresses from the seed regardless of their validity.
sourcepub async fn find_messages<I: AsRef<[u8]>>(
&self,
indexation_keys: &[I],
message_ids: &[MessageId]
) -> Result<Vec<Message>>
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.
sourcepub fn get_balance<'a>(&'a self, seed: &'a Seed) -> GetBalanceBuilder<'a>
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.
sourcepub async fn get_address_balances(
&self,
addresses: &[String]
) -> Result<Vec<BalanceAddressResponse>>
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.
sourcepub fn bech32_to_hex(bech32: &str) -> Result<String>
pub fn bech32_to_hex(bech32: &str) -> Result<String>
Transforms bech32 to hex
sourcepub async fn hex_to_bech32(
&self,
hex: &str,
bech32_hrp: Option<&str>
) -> Result<String>
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
sourcepub async fn hex_public_key_to_bech32_address(
&self,
hex: &str,
bech32_hrp: Option<&str>
) -> Result<String>
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
sourcepub fn parse_bech32_address(address: &str) -> Result<Address>
pub fn parse_bech32_address(address: &str) -> Result<Address>
Returns a valid Address parsed from a String.
sourcepub fn is_address_valid(address: &str) -> bool
pub fn is_address_valid(address: &str) -> bool
Checks if a String is a valid bech32 encoded address.
sourcepub async fn retry(&self, message_id: &MessageId) -> Result<(MessageId, Message)>
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.
sourcepub async fn retry_until_included(
&self,
message_id: &MessageId,
interval: Option<u64>,
max_attempts: Option<u64>
) -> Result<Vec<(MessageId, Message)>>
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
sourcepub async fn consolidate_funds(
&self,
seed: &Seed,
account_index: usize,
address_range: Range<usize>
) -> Result<String>
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
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more