network

package
v0.0.0-...-c4ab804 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMagic = errors.New("invalid network magic")
)

Functions

func GetNetworkParams

func GetNetworkParams(magic Network) (*chaincfg.Params, error)

Types

type Network

type Network uint32

/ Network represents the byte sequences used to identify different networks.

const (
	// Mainnet identifies mainnet
	Mainnet Network = 0xd9b4bef9
	// Testnet identifies testnet
	Testnet Network = 0x0709110b
	// Regtest identifies regtest
	Regtest Network = 0xdab5bffa
)

func Decode

func Decode(data []byte) (Network, error)

Decode parses a valid network identifier from a byte slice. It returns the identifier on success, zero and an error on failure.

func (Network) Marshal

func (m Network) Marshal(dst []byte) (out []byte)

Marshal appends the 4-byte, little endian encoding of a network identifier to the dst slice and returns the resulting slice. If there is sufficient room in the dst slice, Marshal does not allocate.

Jump to

Keyboard shortcuts

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