pub struct Address { /* private fields */ }Expand description
A TON account address: a workchain id and a 256-bit account id.
Parses both the raw workchain:hex form and the user-friendly base64 form. The
address carries no balance or state.
Two addresses are equal when they name the same account. The user-friendly form also carries a bounceable and a test-only flag, which say how a message to the account should be sent and which network it belongs to rather than which account it is, so they are readable but do not enter into equality. The raw form carries neither, and an address parsed from it reports the defaults: bounceable, and not test-only.
Implementations§
Source§impl Address
impl Address
Sourcepub fn parse(s: &str) -> Result<Self, Error>
pub fn parse(s: &str) -> Result<Self, Error>
Parses an address from a string.
Accepts the raw form, for example -1:3333...3333, and the user-friendly base64
form, for example Ef8z.... A raw address is a workchain, a colon, and 64 hex
digits. A user-friendly address is 36 base64 bytes whose CRC16 checksum is
verified.
§Errors
Returns Error::Address if the string is not a valid address in either form, or
if a user-friendly address fails its checksum.
§Examples
use ton_net::Address;
let a = Address::parse(
"-1:3333333333333333333333333333333333333333333333333333333333333333",
)?;
assert_eq!(a.workchain(), -1);Sourcepub fn account_id(&self) -> &[u8; 32]
pub fn account_id(&self) -> &[u8; 32]
Returns the 32-byte account id.
Sourcepub fn is_bounceable(&self) -> bool
pub fn is_bounceable(&self) -> bool
Whether a failed message to this address should be returned to its sender.
A hint about sending, not part of the account’s identity. True for an address parsed from the raw form, which does not carry the flag.
Sourcepub fn is_test_only(&self) -> bool
pub fn is_test_only(&self) -> bool
Whether the address was written for a test network.
Which network a client is on is decided by its Config, not by
an address, so this is not enforced anywhere: a test-only address read against
mainnet gets a correct answer about a mainnet account, which is almost certainly
not the account the caller meant. A caller that cares checks this.