Skip to content

aea.helpers.multiaddr.base

This module contains multiaddress class.

MultiAddr Objects

class MultiAddr()

Protocol Labs' Multiaddress representation of a network address.

__init__

 | __init__(host: str, port: int, public_key: Optional[str] = None, multihash_id: Optional[str] = None)

Initialize a multiaddress.

Arguments:

  • host: ip host of the address
  • port: port number of the address
  • public_key: hex encoded public key. Must conform to Bitcoin EC encoding standard for Secp256k1
  • multihash_id: a multihash of the public key

compute_peerid

 | @staticmethod
 | compute_peerid(public_key: str) -> str

Compute the peer id from a public key.

In particular, compute the base58 representation of libp2p PeerID from Bitcoin EC encoded Secp256k1 public key.

Arguments:

  • public_key: the public key.

Returns:

the peer id.

from_string

 | @classmethod
 | from_string(cls, maddr: str) -> "MultiAddr"

Construct a MultiAddr object from its string format

Arguments:

  • maddr: multiaddress string

public_key

 | @property
 | public_key() -> str

Get the public key.

peer_id

 | @property
 | peer_id() -> str

Get the peer id.

host

 | @property
 | host() -> str

Get the peer host.

port

 | @property
 | port() -> int

Get the peer port.

format

 | format() -> str

Canonical representation of a multiaddress.

__str__

 | __str__() -> str

Default string representation of a mutliaddress.