Class PeerAddress


public class PeerAddress extends ChildMessage

A PeerAddress holds an IP address and port number representing the network location of a peer in the Bitcoin P2P network. It exists primarily for serialization purposes.

This class abuses the protocol version contained in its serializer. It can only contain 0 (format within VersionMessage), 1 (AddressV1Message) or 2 (AddressV2Message).

Instances of this class are not safe for use by multiple threads.

  • Constructor Details

    • PeerAddress

      public PeerAddress(NetworkParameters params, byte[] payload, int offset, Message parent, MessageSerializer serializer) throws ProtocolException
      Construct a peer address from a serialized payload.
      Parameters:
      params - NetworkParameters object.
      payload - Bitcoin protocol formatted byte array containing message content.
      offset - The location of the first payload byte within the array.
      serializer - the serializer to use for this message.
      Throws:
      ProtocolException
    • PeerAddress

      public PeerAddress(NetworkParameters params, InetAddress addr, int port, BigInteger services, MessageSerializer serializer)
      Construct a peer address from a memorized or hardcoded address.
    • PeerAddress

      public PeerAddress(NetworkParameters params, InetAddress addr, int port, BigInteger services)
      Constructs a peer address from the given IP address, port and services. Version number is default for the given parameters.
    • PeerAddress

      public PeerAddress(NetworkParameters params, InetAddress addr, int port)
      Constructs a peer address from the given IP address and port. Version number is default for the given parameters.
    • PeerAddress

      public PeerAddress(NetworkParameters params, InetAddress addr)
      Constructs a peer address from the given IP address. Port and version number are default for the given parameters.
    • PeerAddress

      public PeerAddress(NetworkParameters params, InetSocketAddress addr)
      Constructs a peer address from an InetSocketAddress. An InetSocketAddress can take in as parameters an InetAddress or a String hostname. If you want to connect to a .onion, set the hostname to the .onion address.
    • PeerAddress

      public PeerAddress(NetworkParameters params, String hostname, int port)
      Constructs a peer address from a stringified hostname+port. Use this if you want to connect to a Tor .onion address.
  • Method Details