enr

package
v0.0.0-...-be891b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: MIT Imports: 7 Imported by: 3

Documentation

Overview

Package enr provides utilities for parsing and extracting data from Ethereum Node Records (ENR). It supports parsing ENR strings and extracting various fields including network information, cryptographic keys, and Ethereum 2.0 specific metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ENR

type ENR struct {
	// Enr is the enr of the node record.
	Enr string
	// Signature is the cryptographic signature of record contents
	Signature *[]byte
	// Seq is the sequence number, a 64-bit unsigned integer.
	// Nodes should increase the number whenever the record changes and republish the record
	Seq *uint64
	// ID is the name of identity scheme, e.g. “v4”
	ID *string
	// NodeID is the node ID of the node record.
	NodeID *string
	// PeerID is the peer ID of the node record.
	PeerID *string
	// Secp256k1 is the secp256k1 public key of the node record.
	Secp256k1 *[]byte
	// IP4 is the IPv4 address of the node record.
	IP4 *string
	// IP6 is the IPv6 address of the node record.
	IP6 *string
	// TCP4 is the TCP port of the node record.
	TCP4 *uint32
	// TCP6 is the TCP port of the node record.
	TCP6 *uint32
	// UDP4 is the UDP port of the node record.
	UDP4 *uint32
	// UDP6 is the UDP port of the node record.
	UDP6 *uint32
	// QUIC4 is the QUIC port for IPv4 of the node record.
	QUIC4 *uint32
	// QUIC6 is the QUIC port for IPv6 of the node record.
	QUIC6 *uint32
	// Eth2 is the eth2 public key of the node record.
	ETH2 *[]byte
	// Attnets is the attestation subnet bitfield of the node record.
	Attnets *[]byte
	// Syncnets is the sync subnet bitfield of the node record.
	Syncnets *[]byte
	// CGC is the custody group count of the node record.
	CGC *[]byte
	// NFD is the next fork digest of the next scheduled fork.
	NFD *[]byte
}

func Parse

func Parse(record string) (*ENR, error)

Parse parses an ENR record string and extracts all available fields. It returns a populated ENR struct with all parsed values or an error if parsing fails.

func (*ENR) GetAttnets

func (e *ENR) GetAttnets() *[]byte

GetAttnets returns the attestation subnet bitfield from the ENR record. Returns nil if the ENR is nil or the bitfield is not present.

func (*ENR) GetCGC

func (e *ENR) GetCGC() *[]byte

GetCGC returns the custody group count field from the ENR record. Returns nil if the ENR is nil or the CGC field is not present.

func (*ENR) GetETH2

func (e *ENR) GetETH2() *[]byte

GetETH2 returns the Ethereum 2.0 public key from the ENR record. Returns nil if the ENR is nil or the key is not present.

func (*ENR) GetEnr

func (e *ENR) GetEnr() string

GetEnr returns the raw ENR string.

func (*ENR) GetID

func (e *ENR) GetID() *string

GetID returns the identity scheme of the ENR record. Returns nil if the ENR is nil or the ID is not present.

func (*ENR) GetIP4

func (e *ENR) GetIP4() *string

GetIP4 returns the IPv4 address from the ENR record. Returns nil if the ENR is nil or the IP4 address is not present.

func (*ENR) GetIP6

func (e *ENR) GetIP6() *string

GetIP6 returns the IPv6 address from the ENR record. Returns nil if the ENR is nil or the IP6 address is not present.

func (*ENR) GetNFD

func (e *ENR) GetNFD() *[]byte

GetNFD returns the next fork digest field from the ENR record. Returns nil if the ENR is nil or the NFD field is not present.

func (*ENR) GetNodeID

func (e *ENR) GetNodeID() *string

GetNodeID returns the node ID of the ENR record. Returns nil if the ENR is nil or the node ID is not present.

func (*ENR) GetPeerID

func (e *ENR) GetPeerID() *string

GetPeerID returns the libp2p peer ID derived from the ENR record. Returns nil if the ENR is nil or the peer ID is not present.

func (*ENR) GetQUIC4

func (e *ENR) GetQUIC4() *uint32

GetQUIC4 returns the QUIC port for IPv4 from the ENR record. Returns nil if the ENR is nil or the port is not present.

func (*ENR) GetQUIC6

func (e *ENR) GetQUIC6() *uint32

GetQUIC6 returns the QUIC port for IPv6 from the ENR record. Returns nil if the ENR is nil or the port is not present.

func (*ENR) GetSecp256k1

func (e *ENR) GetSecp256k1() *[]byte

GetSecp256k1 returns the secp256k1 public key from the ENR record. Returns nil if the ENR is nil or the key is not present.

func (*ENR) GetSeq

func (e *ENR) GetSeq() *uint64

GetSeq returns the sequence number of the ENR record. Returns nil if the ENR is nil or the sequence number is not present.

func (*ENR) GetSignature

func (e *ENR) GetSignature() *[]byte

GetSignature returns the cryptographic signature of the ENR record. Returns nil if the ENR is nil or the signature is not present.

func (*ENR) GetSyncnets

func (e *ENR) GetSyncnets() *[]byte

GetSyncnets returns the sync subnet bitfield from the ENR record. Returns nil if the ENR is nil or the bitfield is not present.

func (*ENR) GetTCP4

func (e *ENR) GetTCP4() *uint32

GetTCP4 returns the TCP port for IPv4 from the ENR record. Returns nil if the ENR is nil or the port is not present.

func (*ENR) GetTCP6

func (e *ENR) GetTCP6() *uint32

GetTCP6 returns the TCP port for IPv6 from the ENR record. Returns nil if the ENR is nil or the port is not present.

func (*ENR) GetUDP4

func (e *ENR) GetUDP4() *uint32

GetUDP4 returns the UDP port for IPv4 from the ENR record. Returns nil if the ENR is nil or the port is not present.

func (*ENR) GetUDP6

func (e *ENR) GetUDP6() *uint32

GetUDP6 returns the UDP port for IPv6 from the ENR record. Returns nil if the ENR is nil or the port is not present.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL