Skip to main content

iota_sdk.client._high_level_api

Range Objects

class Range()

Represents a range of address indexes.

Attributes:

  • start - The start index of the address range.
  • end - The end index of the address range.

GenerateAddressOptions Objects

class GenerateAddressOptions()

Options for generating an address.

Attributes:

  • internal - Whether to generate an internal address.
  • ledgerNanoPrompt - Whether to display the generated address on Ledger Nano devices.

__init__

def __init__(internal: bool, ledgerNanoPrompt: bool)

Initialize GenerateAddressOptions.

GenerateAddressesOptions Objects

class GenerateAddressesOptions()

Options for generating addresses.

Attributes:

  • coinType - The type of coin.
  • range - The range of addresses to generate.
  • bech32Hrp - The bech32 HRP (human readable part) to use.
  • accountIndex - An account index.
  • options - An instance of GenerateAddressOptions.

__init__

def __init__(coinType: CoinType,
range: range,
bech32Hrp: str,
accountIndex: Optional[int] = None,
options: Optional[GenerateAddressOptions] = None)

Initialize GenerateAddressesOptions.

Arguments:

  • coinType - The type of coin.
  • range - The range of addresses to generate.
  • bech32Hrp - The bech32 HRP (human readable part) to use.
  • accountIndex - An account index.
  • options - An instance of GenerateAddressOptions.

HighLevelAPI Objects

class HighLevelAPI()

High level API.

get_outputs

def get_outputs(output_ids: List[OutputId]) -> List[OutputWithMetadata]

Fetch OutputWithMetadata from provided OutputIds (requests are sent in parallel).

Arguments:

  • output_ids - A list of output ids.

Returns:

A list of corresponding OutputWithMetadata objects.

get_outputs_ignore_errors

def get_outputs_ignore_errors(
output_ids: List[OutputId]) -> List[OutputWithMetadata]

Try to get OutputWithMetadata from provided OutputIds. Requests are sent in parallel and errors are ignored, can be useful for spent outputs.

Arguments:

  • output_ids - A list of output ids.

Returns:

A list of corresponding OutputWithMetadata objects.

find_blocks

def find_blocks(block_ids: List[HexStr]) -> List[Block]

Find all blocks by provided block IDs.

Arguments:

  • block_ids - A list of block ids.

Returns:

A list of corresponding Blocks.

retry

def retry(block_id: HexStr) -> List[Union[HexStr, 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.

Arguments:

  • block_id - A block id.

Returns:

A list where the first element is the block id and the second one the block.

retry_until_included

def retry_until_included(
block_id: HexStr,
interval: Optional[int] = None,
max_attempts: Optional[int] = None
) -> List[List[Union[HexStr, 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.

Arguments:

  • block_id - A block id.
  • interval - A retry interval in seconds. Defaults to 5.
  • max_attempts - A maximum number of retries. Defaults to 40.

Returns:

A list of lists where the first element is the block id and the second one the block.

consolidate_funds

def consolidate_funds(
secret_manager: Union[LedgerNanoSecretManager, MnemonicSecretManager,
SeedSecretManager, StrongholdSecretManager],
generate_addresses_options: GenerateAddressesOptions) -> str

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.

Arguments:

  • secret_manager - A supported secret manager.
  • generate_addresses_options - Options to generate addresses.

Returns:

An address to which the funds got consolidated.

find_inputs

def find_inputs(addresses: List[str], amount: int)

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

Arguments:

  • addresses - A list of included addresses.
  • amount - The amount to find inputs for.

reattach

def reattach(block_id: HexStr) -> List[Union[HexStr, Block]]

Reattaches blocks for a provided block id. Blocks can be reattached only if they are valid and haven't been confirmed for a while .

Arguments:

  • block_id - A block id of a block that should be reattached.

Returns:

The reattached block id and block.

reattach_unchecked

def reattach_unchecked(block_id: HexStr) -> List[Union[HexStr, Block]]

Reattach a block without checking if it should be reattached.

Arguments:

  • block_id - A block id of a block that should be reattached.

Returns:

The reattached block id and block.

promote

def promote(block_id: HexStr) -> List[Union[HexStr, 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.

Arguments:

  • block_id - A block id of a block that should be promoted.

Returns:

The block id and block that promoted the provided block.

promote_unchecked

def promote_unchecked(block_id: HexStr) -> List[Union[HexStr, Block]]

Promote a block without checking if it should be promoted.

Arguments:

  • block_id - A block id of a block that should be promoted.

Returns:

The block id and block that promoted the provided block.