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_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 and set the NetworkInfo.
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_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 if local pow should be used or not
sourcepub async fn get_rent_structure(&self) -> Result<RentStructure>
pub async fn get_rent_structure(&self) -> Result<RentStructure>
returns the rent structure
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 async fn get_node_info(url: &str, auth: Option<NodeAuth>) -> Result<NodeInfo>
pub async fn get_node_info(url: &str, auth: Option<NodeAuth>) -> Result<NodeInfo>
GET /api/core/v2/info endpoint
sourcepub fn get_address(&self) -> GetAddressBuilder<'_>
pub fn get_address(&self) -> GetAddressBuilder<'_>
GET /api/indexer/v1/outputs/basic{query} endpoint
sourcepub async fn inputs_from_transaction_id(
&self,
transaction_id: &TransactionId
) -> Result<Vec<OutputResponse>>
pub async fn inputs_from_transaction_id(
&self,
transaction_id: &TransactionId
) -> Result<Vec<OutputResponse>>
Get the inputs of a transaction for the given transaction id.
sourcepub fn block(&self) -> ClientBlockBuilder<'_>
pub fn block(&self) -> ClientBlockBuilder<'_>
A generic send function for easily sending transaction or tagged data blocks.
sourcepub fn get_addresses<'a>(
&'a self,
secret_manager: &'a SecretManager
) -> GetAddressesBuilder<'a>
pub fn get_addresses<'a>(
&'a self,
secret_manager: &'a SecretManager
) -> GetAddressesBuilder<'a>
Return a list of addresses from a secret manager regardless of their validity.
sourcepub async fn find_blocks(&self, block_ids: &[BlockId]) -> Result<Vec<Block>>
pub async fn find_blocks(&self, block_ids: &[BlockId]) -> Result<Vec<Block>>
Find all blocks by provided block IDs.
sourcepub async fn retry(&self, block_id: &BlockId) -> Result<(BlockId, Block)>
pub async fn retry(&self, block_id: &BlockId) -> Result<(BlockId, Block)>
Retries (promotes or reattaches) a block for provided block id. Block should only be retried only if they are valid and haven’t been confirmed for a while.
sourcepub async fn retry_until_included(
&self,
block_id: &BlockId,
interval: Option<u64>,
max_attempts: Option<u64>
) -> Result<Vec<(BlockId, Block)>>
pub async fn retry_until_included(
&self,
block_id: &BlockId,
interval: Option<u64>,
max_attempts: Option<u64>
) -> Result<Vec<(BlockId, Block)>>
Retries (promotes or reattaches) a block for provided block id until it’s included (referenced by a milestone). Default interval is 5 seconds and max attempts is 40. Returns the included block at first position and additional reattached blocks
sourcepub async fn consolidate_funds(
&self,
secret_manager: &SecretManager,
account_index: u32,
address_range: Range<u32>
) -> Result<String>
pub async fn consolidate_funds(
&self,
secret_manager: &SecretManager,
account_index: u32,
address_range: Range<u32>
) -> 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
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), ignoring outputs with additional unlock conditions
sourcepub async fn find_outputs(
&self,
output_ids: &[OutputId],
addresses: &[String]
) -> Result<Vec<OutputResponse>>
pub async fn find_outputs(
&self,
output_ids: &[OutputId],
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 async fn reattach(&self, block_id: &BlockId) -> Result<(BlockId, Block)>
pub async fn reattach(&self, block_id: &BlockId) -> Result<(BlockId, Block)>
Reattaches blocks for provided block id. Blocks can be reattached only if they are valid and haven’t been confirmed for a while.
sourcepub async fn reattach_unchecked(
&self,
block_id: &BlockId
) -> Result<(BlockId, Block)>
pub async fn reattach_unchecked(
&self,
block_id: &BlockId
) -> Result<(BlockId, Block)>
Reattach a block without checking if it should be reattached
sourcepub async fn promote(&self, block_id: &BlockId) -> Result<(BlockId, Block)>
pub async fn promote(&self, block_id: &BlockId) -> Result<(BlockId, Block)>
Promotes a block. The method should validate if a promotion is necessary through get_block. If not, the method should error out and should not allow unnecessary promotions.
sourcepub async fn promote_unchecked(
&self,
block_id: &BlockId
) -> Result<(BlockId, Block)>
pub async fn promote_unchecked(
&self,
block_id: &BlockId
) -> Result<(BlockId, Block)>
Promote a block without checking if it should be promoted
sourcepub async fn get_time_checked(&self) -> Result<u32>
pub async fn get_time_checked(&self) -> Result<u32>
Returns the local time checked with the timestamp of the latest milestone, if the difference is larger than 5 minutes an error is returned to prevent locking outputs by accident for a wrong time.
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 fn generate_mnemonic() -> Result<String>
pub fn generate_mnemonic() -> Result<String>
Generates a new mnemonic.
sourcepub fn mnemonic_to_seed(mnemonic: &str) -> Result<Seed>
pub fn mnemonic_to_seed(mnemonic: &str) -> Result<Seed>
Returns a seed for a 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 fn tag_to_utf8(payload: &TaggedDataPayload) -> Result<String>
pub fn tag_to_utf8(payload: &TaggedDataPayload) -> Result<String>
UTF-8 encodes the tag
of a given TaggedDataPayload.
sourcepub fn data_to_utf8(payload: &TaggedDataPayload) -> Result<String>
pub fn data_to_utf8(payload: &TaggedDataPayload) -> Result<String>
UTF-8 encodes the data
of a given TaggedDataPayload.
sourcepub fn tagged_data_to_utf8(
payload: &TaggedDataPayload
) -> Result<(String, String)>
pub fn tagged_data_to_utf8(
payload: &TaggedDataPayload
) -> Result<(String, String)>
UTF-8 encodes both the tag
and data
of a given TaggedDataPayload.
sourceimpl Client
impl Client
sourcepub async fn get_health(&self, url: &str) -> Result<bool>
pub async fn get_health(&self, url: &str) -> Result<bool>
Returns the health of the node. GET /health
sourcepub async fn get_routes(&self) -> Result<RoutesResponse>
pub async fn get_routes(&self) -> Result<RoutesResponse>
Returns the available API route groups of the node. GET /api/routes
sourcepub async fn get_info(&self) -> Result<NodeInfoWrapper>
pub async fn get_info(&self) -> Result<NodeInfoWrapper>
Returns general information about the node. GET /api/core/v2/info
sourcepub async fn get_tips(&self) -> Result<Vec<BlockId>>
pub async fn get_tips(&self) -> Result<Vec<BlockId>>
Returns tips that are ideal for attaching a block. GET /api/core/v2/tips
sourcepub async fn post_block(&self, block: &Block) -> Result<BlockId>
pub async fn post_block(&self, block: &Block) -> Result<BlockId>
Returns the BlockId of the submitted block. POST JSON to /api/core/v2/blocks
sourcepub async fn post_block_raw(&self, block: &Block) -> Result<BlockId>
pub async fn post_block_raw(&self, block: &Block) -> Result<BlockId>
Returns the BlockId of the submitted block. POST /api/core/v2/blocks
sourcepub async fn get_block(&self, block_id: &BlockId) -> Result<Block>
pub async fn get_block(&self, block_id: &BlockId) -> Result<Block>
Finds a block by its BlockId. This method returns the given block object. GET /api/core/v2/blocks/{BlockId}
sourcepub async fn get_block_raw(&self, block_id: &BlockId) -> Result<Vec<u8>>
pub async fn get_block_raw(&self, block_id: &BlockId) -> Result<Vec<u8>>
Finds a block by its BlockId. This method returns the given block raw data. GET /api/core/v2/blocks/{BlockId}
sourcepub async fn get_block_metadata(
&self,
block_id: &BlockId
) -> Result<BlockMetadataResponse>
pub async fn get_block_metadata(
&self,
block_id: &BlockId
) -> Result<BlockMetadataResponse>
Returns the metadata of a block. GET /api/core/v2/blocks/{BlockId}/metadata
sourcepub async fn get_output(&self, output_id: &OutputId) -> Result<OutputResponse>
pub async fn get_output(&self, output_id: &OutputId) -> Result<OutputResponse>
Finds an output, as JSON, by its OutputId (TransactionId + output_index). GET /api/core/v2/outputs/{outputId}
sourcepub async fn get_output_raw(&self, output_id: &OutputId) -> Result<Vec<u8>>
pub async fn get_output_raw(&self, output_id: &OutputId) -> Result<Vec<u8>>
Finds an output, as raw bytes, by its OutputId (TransactionId + output_index). GET /api/core/v2/outputs/{outputId}
sourcepub async fn get_output_metadata(
&self,
output_id: &OutputId
) -> Result<OutputMetadataResponse>
pub async fn get_output_metadata(
&self,
output_id: &OutputId
) -> Result<OutputMetadataResponse>
Get the metadata for a given OutputId
(TransactionId + output_index).
GET /api/core/v2/outputs/{outputId}/metadata
sourcepub async fn get_receipts(&self) -> Result<Vec<ReceiptDto>>
pub async fn get_receipts(&self) -> Result<Vec<ReceiptDto>>
Gets all stored receipts. GET /api/core/v2/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>>
Gets the receipts by the given milestone index. GET /api/core/v2/receipts/{migratedAt}
sourcepub async fn get_treasury(&self) -> Result<TreasuryResponse>
pub async fn get_treasury(&self) -> Result<TreasuryResponse>
Gets the current treasury output. The treasury output contains all tokens from the legacy network that have not yet been migrated. GET /api/core/v2/treasury
sourcepub async fn get_included_block(
&self,
transaction_id: &TransactionId
) -> Result<Block>
pub async fn get_included_block(
&self,
transaction_id: &TransactionId
) -> Result<Block>
Returns the block, as object, that was included in the ledger for a given TransactionId. GET /api/core/v2/transactions/{transactionId}/included-block
sourcepub async fn get_included_block_raw(
&self,
transaction_id: &TransactionId
) -> Result<Vec<u8>>
pub async fn get_included_block_raw(
&self,
transaction_id: &TransactionId
) -> Result<Vec<u8>>
Returns the block, as raw bytes, that was included in the ledger for a given TransactionId. GET /api/core/v2/transactions/{transactionId}/included-block
sourcepub async fn get_milestone_by_id(
&self,
milestone_id: &MilestoneId
) -> Result<MilestonePayload>
pub async fn get_milestone_by_id(
&self,
milestone_id: &MilestoneId
) -> Result<MilestonePayload>
Gets the milestone by the given milestone id. GET /api/core/v2/milestones/{milestoneId}
sourcepub async fn get_milestone_by_id_raw(
&self,
milestone_id: &MilestoneId
) -> Result<Vec<u8>>
pub async fn get_milestone_by_id_raw(
&self,
milestone_id: &MilestoneId
) -> Result<Vec<u8>>
Gets the milestone by the given milestone id. GET /api/core/v2/milestones/{milestoneId}
sourcepub async fn get_utxo_changes_by_id(
&self,
milestone_id: &MilestoneId
) -> Result<UtxoChangesResponse>
pub async fn get_utxo_changes_by_id(
&self,
milestone_id: &MilestoneId
) -> Result<UtxoChangesResponse>
Gets all UTXO changes of a milestone by its milestone id. GET /api/core/v2/milestones/{milestoneId}/utxo-changes
sourcepub async fn get_milestone_by_index(
&self,
index: u32
) -> Result<MilestonePayload>
pub async fn get_milestone_by_index(
&self,
index: u32
) -> Result<MilestonePayload>
Gets the milestone by the given milestone index. GET /api/core/v2/milestones/{index}
sourcepub async fn get_milestone_by_index_raw(&self, index: u32) -> Result<Vec<u8>>
pub async fn get_milestone_by_index_raw(&self, index: u32) -> Result<Vec<u8>>
Gets the milestone by the given milestone index. GET /api/core/v2/milestones/{index}
sourcepub async fn get_utxo_changes_by_index(
&self,
index: u32
) -> Result<UtxoChangesResponse>
pub async fn get_utxo_changes_by_index(
&self,
index: u32
) -> Result<UtxoChangesResponse>
Gets all UTXO changes of a milestone by its milestone index. GET /api/core/v2/milestones/by-index/{index}/utxo-changes
sourceimpl Client
impl Client
sourcepub async fn get_outputs(
&self,
output_ids: Vec<OutputId>
) -> Result<Vec<OutputResponse>>
pub async fn get_outputs(
&self,
output_ids: Vec<OutputId>
) -> Result<Vec<OutputResponse>>
Request outputs by their output id in parallel
sourcepub async fn try_get_outputs(
&self,
output_ids: Vec<OutputId>
) -> Result<Vec<OutputResponse>>
pub async fn try_get_outputs(
&self,
output_ids: Vec<OutputId>
) -> Result<Vec<OutputResponse>>
Request outputs by their output id in parallel, ignores failed requests Useful to get data about spent outputs, that might not be pruned yet
sourceimpl Client
impl Client
sourcepub async fn basic_output_ids(
&self,
query_parameters: Vec<QueryParameter>
) -> Result<Vec<OutputId>>
pub async fn basic_output_ids(
&self,
query_parameters: Vec<QueryParameter>
) -> Result<Vec<OutputId>>
Get basic outputs filtered by the given parameters. GET with query parameter returns all outputIDs that fit these filter criteria. Query parameters: “address”, “hasStorageDepositReturn”, “storageDepositReturnAddress”, “hasExpiration”, “expiresBefore”, “expiresAfter”, “hasTimelock”, “timelockedBefore”, “timelockedAfter”, “sender”, “tag”, “createdBefore” and “createdAfter”. Returns an empty Vec if no results are found. api/indexer/v1/outputs/basic
sourcepub async fn alias_output_ids(
&self,
query_parameters: Vec<QueryParameter>
) -> Result<Vec<OutputId>>
pub async fn alias_output_ids(
&self,
query_parameters: Vec<QueryParameter>
) -> Result<Vec<OutputId>>
Get alias outputs filtered by the given parameters. GET with query parameter returns all outputIDs that fit these filter criteria. Query parameters: “stateController”, “governor”, “issuer”, “sender”, “createdBefore”, “createdAfter” Returns an empty list if no results are found. api/indexer/v1/outputs/alias
sourcepub async fn alias_output_id(&self, alias_id: AliasId) -> Result<OutputId>
pub async fn alias_output_id(&self, alias_id: AliasId) -> Result<OutputId>
Get alias output by its aliasID. api/indexer/v1/outputs/alias/:{AliasId}
sourcepub async fn foundry_output_ids(
&self,
query_parameters: Vec<QueryParameter>
) -> Result<Vec<OutputId>>
pub async fn foundry_output_ids(
&self,
query_parameters: Vec<QueryParameter>
) -> Result<Vec<OutputId>>
Get foundry outputs filtered by the given parameters. GET with query parameter returns all outputIDs that fit these filter criteria. Query parameters: “address”, “createdBefore”, “createdAfter” Returns an empty list if no results are found. api/indexer/v1/outputs/foundry
sourcepub async fn foundry_output_id(&self, foundry_id: FoundryId) -> Result<OutputId>
pub async fn foundry_output_id(&self, foundry_id: FoundryId) -> Result<OutputId>
Get foundry output by its foundryID. api/indexer/v1/outputs/foundry/:{FoundryID}
sourcepub async fn nft_output_ids(
&self,
query_parameters: Vec<QueryParameter>
) -> Result<Vec<OutputId>>
pub async fn nft_output_ids(
&self,
query_parameters: Vec<QueryParameter>
) -> Result<Vec<OutputId>>
Get NFT outputs filtered by the given parameters. Query parameters: “address”, “hasStorageDepositReturn”, “storageDepositReturnAddress”, “hasExpiration”, “expiresBefore”, “expiresAfter”, “hasTimelock”, “timelockedBefore”, “timelockedAfter”, “issuer”, “sender”, “tag”, “createdBefore”, “createdAfter” Returns an empty list if no results are found. api/indexer/v1/outputs/nft
sourcepub async fn nft_output_id(&self, nft_id: NftId) -> Result<OutputId>
pub async fn nft_output_id(&self, nft_id: NftId) -> Result<OutputId>
Get NFT output by its nftID. api/indexer/v1/outputs/nft/:{NftId}
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