validate

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BtcAddrRegex        = `^(bc1|[13]|tb1|[2mn])[a-zA-HJ-NP-Z0-9]{25,64}$`
	BtcTestnetAddrRegex = `^(tb1|[2mn])[a-zA-HJ-NP-Z0-9]{25,64}$`
	BtcMainnetRegex     = `^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,64}$`
)
View Source
const (
	EthAddrRegex = `^0x[0-9|a-f|A-F]{40}$`
)

Variables

View Source
var (
	ErrInvalidEthAddr = errors.New("invalid ethereum address")
)

Functions

func CheckValidSecp256k1PubKey

func CheckValidSecp256k1PubKey(pubKey string) error

CheckValidSecp256k1PubKey checks if a given public key hex is a valid secp256k1 public key

func GetValidBtcAddr

func GetValidBtcAddr(addr string) (string, error)

GetValidBtcAddr returns a valid Bitcoin address or an error if the address is invalid.

func GetValidEthAddr

func GetValidEthAddr(addr string) (string, error)

GetValidEthAddr returns a valid Ethereum address or an error if the address is invalid. will add the 0x prefix if it's missing, and lowercase the input.

func IsBitcoinMainnet

func IsBitcoinMainnet(address string) bool

IsBitcoinMainnet checks if a BTC address is a mainnet address

func IsBitcoinTestnet

func IsBitcoinTestnet(address string) bool

IsBitcoinTestnet checks if a BTC address is a testnet address

func IsTapRoot

func IsTapRoot(address string) bool

IsTapRoot checks if a BTC address is a taproot address

Types

This section is empty.

Jump to

Keyboard shortcuts

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