Skip to main content

Crate mx_core

Crate mx_core 

Source
Expand description

Core utilities for MultiversX Rust services.

This crate provides shared functionality used across mx-relayer, mx-stress, and mx-notifier:

  • Protocol constants (shard IDs, transaction options)
  • Mnemonic normalization
  • Shard computation (matching mx-chain-go algorithm)
  • Bech32 address encoding/decoding
  • Go BigIntCaster encode/decode helpers and unsigned amount parsing
  • Base64/hex encoding utilities
  • Wallet derivation (Ed25519 signing keys and addresses from BIP39 mnemonics)

Re-exports§

pub use leader::ConsensusMsgType;
pub use leader::ConsensusSignal;
pub use leader::EligibleValidator;
pub use leader::decode_consensus_signal;
pub use leader::epoch_shuffle;
pub use leader::select_consensus_group;
pub use leader::select_leader;

Modules§

leader
resilience
Resilience patterns: circuit breaker, backoff, and retry.
ws_protocol
Shared WebSocket wire-format types for relayer ↔ stress communication.

Structs§

TopicInfo
Parsed information for a concrete gossip topic.

Enums§

BaseTopic
Enumeration of all gossip topic families used by MultiversX nodes.
CoreError
Errors returned by mx-core public functions.
TopicRouting
Represents how a topic is routed across shards.
TopicShard
A shard token extracted from a topic suffix.

Constants§

ALL_SHARD_ID
Shard ID representing all shards in P2P topics.
METACHAIN_SHARD_ID
Alias for metachain shard ID used in P2P topics.
META_SHARD_IDDeprecated
Special shard ID for metachain (0xFFFFFFFF).
TRANSACTIONS_BASE_TOPIC
Base topic used when broadcasting regular transactions.
TX_OPTION_GUARDED
Transaction option flag for guarded transactions.
TX_OPTION_HASH_SIGN
Transaction option flag for hash signing (keccak256 hash instead of raw JSON).

Functions§

all_topics_for_shards
Generates every known topic (including control channels) for the provided shard set.
broadcast_topic
Builds a gossipsub topic name for a shard pair (e.g., “transactions_0_1”). Shards are automatically sorted to ensure canonical ordering per MultiversX protocol.
communication_identifier_between_shards
Mirrors Go’s CommunicationIdentifierBetweenShards.
decode_base64
Decodes a base64-encoded string, trying standard encoding first.
decode_base64_bytes
Decodes a base64-encoded string to Bytes.
decode_base64_or_hex
Decodes data that may be either base64 or hex encoded. Tries base64 first, then falls back to hex.
decode_bech32
Decodes a bech32-encoded address into raw bytes.
decode_big_int_caster
Decodes bytes encoded with Go’s BigIntCaster format.
decode_embedded_receiver
Extracts the embedded receiver address from ESDT/NFT transfer data payloads.
decode_hex
Decodes a hex-encoded string.
decode_optional_base64
Decodes an optional base64-encoded string.
decode_optional_bech32
Decodes an optional bech32 address, returning empty Bytes if None or empty.
decode_optional_hex
Decodes an optional hex-encoded string.
derive_address
Derives a bech32-encoded address from a BIP39 mnemonic at the given account and index.
derive_signing_key
Derives an Ed25519 signing key from a BIP39 mnemonic at the given account and index.
encode_bech32
Encodes raw bytes as a bech32 address with the given HRP.
encode_big_int_caster
Encodes a BigInt using Go’s BigIntCaster format.
filter_username
Filters and trims a username field.
normalize_mnemonic
Normalizes a mnemonic string by replacing commas or multiple whitespace with single spaces.
parse_big_uint
Parses an unsigned integer string into the Go BigIntCaster wire format.
select_shard
Computes the shard ID from the last byte of an address.
shard_of
Determines the shard ID for a given bech32 address.
shard_of_address_bytes
Determines shard ID from raw public key bytes (no bech32 decoding).
shard_of_bytes
Determines the shard ID from raw address bytes (simpler version).
transaction_topics_from_shards
Convenience wrapper generating all transaction topics for the provided shard set.