utils

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooLong         = errors.New("base58 address too long")
	ErrInvalidChecksum = errors.New("invalid checksum")
)

Functions

This section is empty.

Types

type A25

type A25 [25]byte

A25 is a type for a 25 byte (not base58 encoded) bitcoin address.

func ParseBTCAddress

func ParseBTCAddress(address string) (btc *A25, err error)

ParseBTCAddress decodes a base58 encoded bitcoin address and returns an error if the checksum is invalid. See https://rosettacode.org/wiki/Bitcoin/address_validation#Go

func (*A25) ComputeChecksum

func (a *A25) ComputeChecksum() (c [4]byte)

ComputeChecksum returns a four byte checksum computed from the first 21 bytes of the address. The embedded checksum is not updated.

func (*A25) Decode

func (a *A25) Decode(s []byte) error

Decode takes a base58 encoded address and decodes it into the receiver. Errors are returned if the argument is not valid base58 or if the decoded value does not fit in the 25 byte address. The address is not otherwise checked for validity.

func (*A25) EmbeddedChecksum

func (a *A25) EmbeddedChecksum() (c [4]byte)

func (*A25) HasValidChecksum

func (a *A25) HasValidChecksum() bool

Validate an A25 checksum.

func (*A25) IsMainnet

func (a *A25) IsMainnet() bool

Mainnet addresses are assumed to start with '1' or '3'.

func (*A25) IsTestnet

func (a *A25) IsTestnet() bool

Testnet addresses are assumed to start with 'm' or 'n'.

func (*A25) Version

func (a *A25) Version() byte

Version is the first byte of the address.

Jump to

Keyboard shortcuts

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