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 ¶
CheckBase58Address check base58 format address, usually refers to
func ExecAddress ¶
ExecAddress 计算量有点大,做一次cache contract address
func GetAddressType ¶
GetAddressType get address type id
func GetExecAddress ¶
GetExecAddress 获取地址
func IsEthAddress ¶
IsEthAddress verifies whether a string can represent a valid hex-encoded eth address
func PubKeyToAddr ¶
PubKeyToAddr pubKey to specific address pass DefaultID for default address format
func RegisterDriver ¶
RegisterDriver 注册地址驱动 enableHeight, 设置默认启用高度, 负数表示不启用
func SetNormalAddrVer ¶
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 ¶
BytesToBtcAddress hash32 to address Deprecated: btc address legacy
func NewBtcAddress ¶
NewBtcAddress new btc address Deprecated: legacy
type Config ¶
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 ¶
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 ¶
func GetDefaultAddressDriver() Driver
GetDefaultAddressDriver get default driver
func LoadDriver ¶
LoadDriver 根据ID加载插件, 根据区块高度判定是否已启动 不关心启用状态, blockHeight传-1
type DriverInfo ¶
type DriverInfo struct {
// contains filtered or unexported fields
}
DriverInfo driver info