Documentation ¶
Overview ¶
Package address 计算地址相关的函数
Index ¶
- Constants
- Variables
- func CheckAddress(addr string, blockHeight int64) (e error)
- func CheckBase58Address(ver byte, addr string) (e error)
- func ExecAddress(name string) string
- func ExecPubKey(name string) []byte
- func FormatAddrKey(addr string) []byte
- func GetAddressType(addr string) (int32, error)
- func GetDefaultAddressID() int32
- func GetDriverList() map[int32]Driver
- func GetDriverType(name string) (int32, error)
- func GetExecAddress(execName string, addressType int32) (string, error)
- func Init(config *Config)
- func IsEthAddress(addr string) bool
- func IsValidAddressID(id int32) bool
- func PubKeyToAddr(addressID int32, pubKey []byte) string
- func RegisterDriver(id int32, driver Driver, enableHeight int64)
- func SetNormalAddrVer(ver byte)
- func ToLower(addr string) string
- type Address
- type Config
- type Driver
- type DriverInfo
Constants ¶
const ( // MaxID 最大id值 MaxID = 7 // DefaultID default id flag DefaultID = -1 )
const ForkFormatAddressKey = "ForkFormatAddressKey"
ForkFormatAddressKey 地址key格式化分叉名称,主要针对eth地址
const MaxExecNameLength = 100
MaxExecNameLength 执行器名最大长度
Variables ¶
var ( // ErrDecodeBase58 error decode ErrDecodeBase58 = errors.New("ErrDecodeBase58") // ErrAddressLength error length ErrAddressLength = errors.New("ErrAddressLength") )
var ( //ErrUnknownAddressDriver 未注册驱动 ErrUnknownAddressDriver = errors.New("ErrUnknownAddressDriver") //ErrUnknownAddressType unknown address type ErrUnknownAddressType = errors.New("ErrUnknownAddressType") //ErrAddressDriverNotEnable 驱动未启用 ErrAddressDriverNotEnable = errors.New("ErrAddressDriverNotEnable") )
var ErrAddressChecksum = errors.New("address checksum error")
ErrAddressChecksum :
var ErrCheckChecksum = errors.New("Address Checksum error")
ErrCheckChecksum :
var ErrCheckVersion = errors.New("check version error")
ErrCheckVersion :
var MultiSignVer byte = 5
MultiSignVer 多重签名地址的版本号
var NormalVer byte
NormalVer 普通地址的版本号
Functions ¶
func CheckAddress ¶
CheckAddress check address validity blockHeight is used for enable check, pass -1 if there is no block height context
func CheckBase58Address ¶ added in v1.67.1
CheckBase58Address check base58 format address, usually refers to
func ExecAddress ¶
ExecAddress 计算量有点大,做一次cache contract address
func FormatAddrKey ¶ added in v1.67.3
FormatAddrKey format addr as db key
func GetAddressType ¶ added in v1.67.1
GetAddressType get address type id
func GetDefaultAddressID ¶ added in v1.67.1
func GetDefaultAddressID() int32
GetDefaultAddressID get default id
func GetDriverList ¶ added in v1.67.1
GetDriverList get driver list
func GetDriverType ¶ added in v1.67.3
GetDriverType get type by name
func GetExecAddress ¶
GetExecAddress 获取地址
func IsEthAddress ¶ added in v1.67.3
IsEthAddress verifies whether a string can represent a valid hex-encoded eth address
func IsValidAddressID ¶ added in v1.67.1
IsValidAddressID is valid
func PubKeyToAddr ¶
PubKeyToAddr pubKey to specific address pass DefaultID for default address format
func RegisterDriver ¶ added in v1.67.1
RegisterDriver 注册地址驱动 enableHeight, 设置默认启用高度, 负数表示不启用
func SetNormalAddrVer ¶ added in v1.65.1
func SetNormalAddrVer(ver byte)
SetNormalAddrVer 根据配置设置生成普通地址的version版本号,默认是0
Types ¶
type Address ¶
type Address struct { Version byte Hash160 [20]byte // For a stealth address: it's HASH160 Checksum []byte // Unused for a stealth address Pubkey []byte // Unused for a stealth address Enc58str string }
Address btc address Deprecated
func BytesToBtcAddress ¶ added in v1.67.1
BytesToBtcAddress hash32 to address Deprecated: btc address legacy
func NewBtcAddress ¶ added in v1.67.1
NewBtcAddress new btc address Deprecated: legacy
type Config ¶ added in v1.67.1
type Config struct { // DefaultDriver config default driver DefaultDriver string `json:"defaultDriver,omitempty"` // EnableHeight enable driver at specific block height EnableHeight map[string]int64 `json:"enableHeight,omitempty"` }
Config address driver config address defaultDriver="btc" [address.enableHeight] btc=0 btcMultiSign=0 eth=-1
type Driver ¶ added in v1.67.1
type Driver interface { // PubKeyToAddr public key to address PubKeyToAddr(pubKey []byte) string // ValidateAddr address validation ValidateAddr(addr string) error // GetName get driver name GetName() string // FromString decode from string FromString(addr string) ([]byte, error) // ToString encode to string ToString(addr []byte) string // FormatAddr to unified format FormatAddr(addr string) string }
Driver address driver
func GetDefaultAddressDriver ¶ added in v1.67.3
func GetDefaultAddressDriver() Driver
GetDefaultAddressDriver get default driver
type DriverInfo ¶ added in v1.67.1
type DriverInfo struct {
// contains filtered or unexported fields
}
DriverInfo driver info