Documentation ¶
Index ¶
- Variables
- func GetPubKeyHashFromAddress(address []byte) []byte
- func HashPublicKey(pubKey []byte) []byte
- func ValidateAddress(address string) bool
- type Wallet
- type WalletSet
- func (ws *WalletSet) CreateWallet() *Wallet
- func (ws *WalletSet) GetAddresses() []string
- func (ws *WalletSet) GetMinerAddress() string
- func (ws *WalletSet) GetWallet(address string) *Wallet
- func (ws *WalletSet) LoadFromFile(nodeID string) error
- func (ws *WalletSet) SaveToFile()
- func (ws *WalletSet) SetMinerAddress(addr string) error
Constants ¶
This section is empty.
Variables ¶
var (
ErrorNotExistsWalletFile = errors.New("not exists wallet file!")
)
Functions ¶
func GetPubKeyHashFromAddress ¶
GetPubKeyHashFromAddress get PublicKeyHash from address 1.base58 decode 2.remove version & checksum
func HashPublicKey ¶
HashPublicKey hashes public key 1.sha256 publick key 2.ripemd160(sha256(public key)) 疑惑: RIPEMD160已被sha-256和SHA 512和它们的派生算法取代。 SHA256和SHA512提供更好的安全和性能比RIPEMD160。 使用RIPEMD160仅为与旧的应用程序和数据的兼容性。 一种看法:在SAH256基础上进行RIPEMD160,一方面双重hash保护,一方面将生成的散列码由256位缩短为160位
func ValidateAddress ¶
ValidateAddress check if address if valid 1.base58 decode 2.get checksum(4 byte) 3.get version 4.get pubKeyHash 5.get checksum,use first 4 bytes
Types ¶
type Wallet ¶
type Wallet struct { PrivateKey ecdsa.PrivateKey PublicKey []byte }
Wallet stores private and public keys
func (Wallet) GetAddress ¶
GetAddress returns wallet address 1.hashes public key - ripemd160(sha256(public key)) 2.connect version to the PubKeyHash header. 3.get checksum,use first 4 bytes 4.connect checksum to the end of the hash data 5.base58 data
func (Wallet) GetStringAddress ¶
GetStringAddress returns wallet address string format
type WalletSet ¶
type WalletSet struct { NodeID string MinerAddress string Wallets map[string]*Wallet // contains filtered or unexported fields }
WalletMap stores a collection of wallets
func LoadWallets ¶
LoadWallets load Wallets and fills it from a file if not exists file, auto create it
func (*WalletSet) CreateWallet ¶
CreateWallet adds a Wallet to Wallets
func (*WalletSet) GetAddresses ¶
GetAddresses returns an array of addresses stored in the wallet file
func (*WalletSet) GetMinerAddress ¶
GetMinerWallet get miner address from current WalletSet
func (*WalletSet) LoadFromFile ¶
LoadFromFile loads wallets from the file
func (*WalletSet) SetMinerAddress ¶
SetMinerWallet set miner address into current WalletSet