[][src]Enum ergo_lib::chain::address::Address

pub enum Address {
    P2PK(ProveDlog),
    P2S(Vec<u8>),
}

An address is a short string corresponding to some script used to protect a box. Unlike (string-encoded) binary representation of a script, an address has some useful characteristics:

  • Integrity of an address could be checked., as it is incorporating a checksum.
  • A prefix of address is showing network and an address type.
  • An address is using an encoding (namely, Base58) which is avoiding similarly l0Oking characters, friendly to double-clicking and line-breaking in emails.

An address is encoding network type, address type, checksum, and enough information to watch for a particular scripts.

Possible network types are: Mainnet - 0x00 Testnet - 0x10

For an address type, we form content bytes as follows:

P2PK - serialized (compressed) public key P2SH - first 192 bits of the Blake2b256 hash of serialized script bytes P2S - serialized script

Address examples for testnet:

3 - P2PK (3WvsT2Gm4EpsM9Pg18PdY6XyhNNMqXDsvJTbbf6ihLvAmSb7u5RN) ? - P2SH (rbcrmKEYduUvADj9Ts3dSVSG27h54pgrq5fPuwB) ? - P2S (Ms7smJwLGbUAjuWQ)

for mainnet:

9 - P2PK (9fRAWhdxEsTcdb8PhGNrZfwqa65zfkuYHAMmkQLcic1gdLSV5vA) ? - P2SH (8UApt8czfFVuTgQmMwtsRBZ4nfWquNiSwCWUjMg) ? - P2S (4MQyML64GnzMxZgm, BxKBaHkvrTvLZrDcZjcsxsF7aSsrN73ijeFZXtbj4CXZHHcvBtqSxQ)

Prefix byte = network type + address type

checksum = blake2b256(prefix byte ++ content bytes)

address = prefix byte ++ content bytes ++ checksum

Variants

P2PK(ProveDlog)

serialized (compressed) public key

P2S(Vec<u8>)

serialized script

Implementations

impl Address[src]

pub fn p2pk_from_pk_bytes(bytes: &[u8]) -> Result<Address, SerializationError>[src]

Create a P2PK address from serialized PK bytes(EcPoint/GroupElement)

pub fn recreate_from_ergo_tree(tree: &ErgoTree) -> Result<Address, AddressError>[src]

Re-create the address from ErgoTree that was built from the address

At some point in the past a user entered an address from which the ErgoTree was built. Re-create the address from this ErgoTree. tree - ErgoTree that was created from an Address

pub fn address_type_prefix(&self) -> AddressTypePrefix[src]

address type prefix (for encoding)

pub fn content_bytes(&self) -> Vec<u8>[src]

byte array

pub fn script(&self) -> Result<ErgoTree, SerializationError>[src]

script encoded in the address

Trait Implementations

impl Clone for Address[src]

impl Debug for Address[src]

impl Eq for Address[src]

impl PartialEq<Address> for Address[src]

impl StructuralEq for Address[src]

impl StructuralPartialEq for Address[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<F> TryExtractInto<F> for F[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,