Documentation ¶
Index ¶
- Constants
- Variables
- func CheckCreateDir(dir_path string)
- func CreateKeystore(fileAbsPath, addrPre, password string) error
- func CreateKeystoreRand(fileAbsPath, addrPre string, seed []byte, ...) error
- func CreateNetAddr(password, netAddressPassword string) (ed25519.PrivateKey, ed25519.PublicKey, error)
- func ExportMnemonic(pwd string) (string, error)
- func FilePathSplit(path string) []string
- func GetKeyByAddr(addr crypto.AddressCoin, password string) (rand []byte, prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
- func GetKeyByPuk(puk []byte, password string) (rand []byte, prk ed25519.PrivateKey, err error)
- func GetNetAddr(pwd string) (ed25519.PrivateKey, ed25519.PublicKey, error)
- func GetNetAddrKeyByMnemonic(words string, mnemonicLang []string) (prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
- func GetNewAddr(password, newAddressPassword string) (crypto.AddressCoin, error)
- func GetNewAddrByName(name, password, newAddressPassword string) (crypto.AddressCoin, error)
- func GetPukByAddr(addr crypto.AddressCoin) (puk ed25519.PublicKey, ok bool)
- func ImportMnemonic(words, pwd, firstCoinAddressPassword, netAddressAndDHkeyPassword string) error
- func ImportMnemonicCreateMoreCoinAddr(words, pwd, firstCoinAddressPassword, netAddressAndDHkeyPassword string, ...) error
- func Load(fileAbsPath, addrPre string) error
- func Mkdir(path string) error
- func PathExists(path string) (bool, error)
- func Println()
- func RenameTempFile(name string) error
- func SaveFile(name string, bs *[]byte) error
- func SaveJsonFile(name string, o interface{}) error
- func SetCoinbase(index int)
- func Sign(prk ed25519.PrivateKey, content []byte) []byte
- func UpdateAddrName(name, password string, addr crypto.AddressCoin) error
- func UpdateAddrPwd(addr, oldpwd, newpwd string) (ok bool, err error)
- func UpdateDHKeyPwd(oldpwd, newpwd string) (ok bool, err error)
- func UpdateNetAddrPwd(oldpwd, newpwd string) (ok bool, err error)
- func UpdatePwd(oldpwd, newpwd string) (ok bool, err error)
- type AddressInfo
- type DHKeyPair
- type Keystore
- func (this *Keystore) AddrDecrypt(addr crypto.AddressCoin, pwdbs [32]byte) (bool, []byte, error)
- func (this *Keystore) CheckIntact() bool
- func (this *Keystore) CreateNetAddr(password, netAddressPassword string) (prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
- func (this *Keystore) CreateNewKeystore(password string) error
- func (this *Keystore) CreateNewWalletRand(seedSrc []byte, ...) error
- func (this *Keystore) Decrypt(pwdbs [32]byte) (bool, []byte, []byte, error)
- func (this *Keystore) ExportMnemonic(pwd string) (string, error)
- func (this *Keystore) FindAddress(addr crypto.AddressCoin) (addrInfo AddressInfo, ok bool)
- func (this *Keystore) FindPuk(puk []byte) (addrInfo AddressInfo, ok bool)
- func (this *Keystore) GetAddr() (addrs []*AddressInfo)
- func (this *Keystore) GetAddrAll() []*AddressInfo
- func (this *Keystore) GetCoinbase() *AddressInfo
- func (this *Keystore) GetDHKeyPair() DHKeyPair
- func (this *Keystore) GetFilePath() string
- func (this *Keystore) GetKeyByAddr(addr crypto.AddressCoin, password string) (rand []byte, prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
- func (this *Keystore) GetKeyByPuk(puk []byte, password string) (rand []byte, prk ed25519.PrivateKey, err error)
- func (this *Keystore) GetNetAddr(password string) (prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
- func (this *Keystore) GetNetAddrPwd(prk []byte) (string, error)
- func (this *Keystore) GetNewAddr(password, newAddressPassword string) (crypto.AddressCoin, error)
- func (this *Keystore) GetNewAddrByName(name, password, newAddressPassword string) (crypto.AddressCoin, error)
- func (this *Keystore) GetNewDHKey(password string, newDHKeyPassword string) (*dh.KeyPair, error)
- func (this *Keystore) GetPukByAddr(addr crypto.AddressCoin) (puk ed25519.PublicKey, ok bool)
- func (this *Keystore) ImportMnemonic(words, pwd, firstCoinAddressPassword, netAddressAndDHkeyPassword string) error
- func (this *Keystore) ImportMnemonicCreateMoreCoinAddr(words, pwd, firstCoinAddressPassword, netAddressAndDHkeyPassword string, ...) error
- func (this *Keystore) Load() error
- func (this *Keystore) NewWallet(seed *[]byte, pwd *[32]byte) error
- func (this *Keystore) Save() error
- func (this *Keystore) SetCoinbase(index uint64) bool
- func (this *Keystore) SetKeyStore(filepath, addrPre string) error
- func (this *Keystore) SetLang(lan string)
- func (this *Keystore) UpdateAddrName(name, password string, addr crypto.AddressCoin) error
- func (this *Keystore) UpdateAddrPwd(addr, oldpwd, newpwd string) (ok bool, err error)
- func (this *Keystore) UpdateDHKeyPwd(oldpwd, newpwd string) (ok bool, err error)
- func (this *Keystore) UpdateNetAddrPwd(oldpwd, newpwd string) (ok bool, err error)
- func (this *Keystore) UpdatePwd(oldpwd, newpwd string) (ok bool, err error)
- type KeystoreInterface
- type NetAddrInfo
Constants ¶
const ( MnemonicLang_cn = "cn" //简体中文 MnemonicLang_en = "en" //英文 )
Variables ¶
var ERROR_DHKey_password_fail = errors.New("DHKey password fail") //DHKey密码错误
var ERROR_address_empty = errors.New("address empty") //地址为空
var ERROR_get_address_info_errer = errors.New("get address info errer") //获取地址信息错误
var ERROR_get_dhkey_errer = errors.New("get DHKey errer") //获取DHKey错误
var ERROR_get_netaddr_errer = errors.New("get NetAddr errer") //获取网络地址错误
var ERROR_netAddr_password_fail = errors.New("net address password fail") //网络地址密码错误
var ERROR_netaddr_empty = errors.New("get NetAddr empty") //网络地址为空
var ERROR_wallet_address_password_fail = errors.New("wallet address password fail") //钱包地址密码错误
var ERROR_wallet_password_fail = errors.New("wallet password fail") //钱包密码错误
var Salt = []byte{53, 111, 103, 103, 87, 66, 54, 103, 53, 108, 65, 81, 73, 53, 70, 43} //加密盐
var Salt = []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07} //加密盐
Functions ¶
func CreateKeystore ¶
CreateKeystore @Description: 创建一个新的keystore @param fileAbsPath @param addrPre @param password 钱包密码 @return error
func CreateKeystoreRand ¶
func CreateKeystoreRand(fileAbsPath, addrPre string, seed []byte, password, firstCoinAddressPassword, netAddressAndDHkeyPassword string) error
CreateKeystoreRand @Description: 使用随机数创建一个新的keystore @param fileAbsPath @param addrPre @param seed @param rand1 @param rand2 @param password 钱包密码 @param firstCoinAddressPassword 首个钱包地址的密码 @param firstAddressPassword 首个网络地址和DHkey的密码 @return error
func CreateNetAddr ¶
func CreateNetAddr(password, netAddressPassword string) (ed25519.PrivateKey, ed25519.PublicKey, error)
GetNewNetAddr @Description: 新建网络地址 @param pwd 网络地址的密码 @return ed25519.PrivateKey 地址私钥 @return ed25519.PublicKey 地址公钥 @return error
func ExportMnemonic ¶
ExportMnemonic @Description: 导出助记词 @param pwd 钱包密码 @return string 助记词 @return error
func GetKeyByAddr ¶
func GetKeyByAddr(addr crypto.AddressCoin, password string) (rand []byte, prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
GetKeyByAddr @Description: 通过地址获取密钥对 @param addr @param password 地址密码 @return rand @return prk 地址私钥 @return puk 地址公钥 @return err
func GetKeyByPuk ¶
GetKeyByPuk @Description: 通过公钥获取密钥 @param puk 地址公钥 @param password 地址密码 @return rand @return prk 地址私钥 @return err
func GetNetAddr ¶
GetNetAddr @Description: 获取本钱包的网络地址 @param pwd 网络地址的密码 @return ed25519.PrivateKey 地址私钥 @return ed25519.PublicKey 地址公钥 @return error
func GetNetAddrKeyByMnemonic ¶
func GetNetAddrKeyByMnemonic(words string, mnemonicLang []string) (prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
GetNetAddrKeyByMnemonic @Description: 根据助记词获取网络地址公私钥 @param words 助记词 @param mnemonicLang 助记词版本 @return prk @return puk @return err
func GetNewAddr ¶
func GetNewAddr(password, newAddressPassword string) (crypto.AddressCoin, error)
GetNewAddr @Description: 获取一个新的地址 @param password 钱包密码 @param newAddressPassword 新地址密码 @return crypto.AddressCoin @return error
func GetNewAddrByName ¶
func GetNewAddrByName(name, password, newAddressPassword string) (crypto.AddressCoin, error)
GetNewAddrByName @Description: 获取一个新的地址,并且给新地址一个昵称 @param name @param password 钱包密码 @param newAddressPassword 新地址密码 @return crypto.AddressCoin @return error
func GetPukByAddr ¶
func GetPukByAddr(addr crypto.AddressCoin) (puk ed25519.PublicKey, ok bool)
GetPukByAddr @Description: 通过地址获取公钥 @param addr @return puk 地址公钥 @return ok
func ImportMnemonic ¶
ImportMnemonic @Description: 导入助记词 @param words 助记词 @param pwd 钱包密码 @param firstCoinAddressPassword 首个钱包地址的密码 @param firstAddressPassword 首个网络地址和DHkey的密码 @return error
func ImportMnemonicCreateMoreCoinAddr ¶
func ImportMnemonicCreateMoreCoinAddr(words, pwd, firstCoinAddressPassword, netAddressAndDHkeyPassword string, coinAddrNum int) error
ImportMnemonicCreateMoreCoinAddr @Description: 导入助记词生成多个钱包地址 @param words 助记词 @param pwd 钱包密码 @param firstCoinAddressPassword 首个钱包地址的密码 @param firstAddressPassword 首个网络地址和DHkey的密码 @param coinAddrNum 创建多少个钱包地址 @return error
func RenameTempFile ¶
func UpdateAddrName ¶
func UpdateAddrName(name, password string, addr crypto.AddressCoin) error
UpdateAddrName @Description: 修改一个地址的昵称 @param name @param password 地址密码 @param addr @return error
func UpdateAddrPwd ¶
UpdateAddrPwd @Description: 修改钱包地址密码 @param addr @param oldpwd 地址旧密码 @param newpwd 地址新密码 @return ok @return err
func UpdateDHKeyPwd ¶
UpdateDHKeyPwd @Description: 修改DHKey密码 @param oldpwd 旧密码 @param newpwd 新密码 @return ok @return err
func UpdateNetAddrPwd ¶
UpdateAddrPwd @Description: 修改网络地址密码 @param addr @param oldpwd 地址旧密码 @param newpwd 地址新密码 @return ok @return err
Types ¶
type AddressInfo ¶
type AddressInfo struct { Index uint64 `json:"index"` //棘轮数量 Nickname string `json:"nickname"` //地址昵称 Addr crypto.AddressCoin `json:"addr"` //收款地址 Puk ed25519.PublicKey `json:"puk"` //公钥 SubKey []byte `json:"subKey"` //子密钥 AddrStr string `json:"-"` // PukStr string `json:"-"` // CheckHash []byte `json:"checkhash"` //主私钥和链编码加密验证hash值 Version int `json:"version"` //地址版本 }
func FindAddress ¶
func FindAddress(addr crypto.AddressCoin) (addrInfo AddressInfo, ok bool)
钱包中查找地址,判断地址是否属于本钱包
func (*AddressInfo) GetAddrStr ¶
func (this *AddressInfo) GetAddrStr() string
func (*AddressInfo) GetPukStr ¶
func (this *AddressInfo) GetPukStr() string
type DHKeyPair ¶
type Keystore ¶
type Keystore struct { AddrPre string `json:"-"` // Coinbase uint64 `json:"coinbase"` //当前默认使用的收付款地址 DHIndex uint64 `json:"dhindex"` //DH密钥,指向钱包位置 MnemonicLang []string `json:"-"` Seed []byte `json:"seed"` //种子 CheckHash []byte `json:"checkhash"` //主私钥和链编码加密验证hash值 Addrs []*AddressInfo `json:"addrs"` //已经生成的地址列表 DHKey []DHKeyPair `json:"dhkey"` //DH密钥 NetAddr *NetAddrInfo `json:"netaddr"` // contains filtered or unexported fields }
func GetKeyStore ¶
func GetKeyStore() *Keystore
func NewKeyStoreTmpNetAddr ¶
NewKeyStoreTmpNetAddr @Description: 根据NetAddr私钥获取一个Keystore @param prk @return *Keystore
func NewKeystore ¶
func (*Keystore) AddrDecrypt ¶
AddrDecrypt @Description: 使用钱包地址密码解密钱包地址子秘钥 @receiver this @param addr 地址 @param pwdbs 地址密码 @return ok 密码是否正确 @return subKeyBs 子密私钥 @return err
func (*Keystore) CreateNetAddr ¶
func (this *Keystore) CreateNetAddr(password, netAddressPassword string) (prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
CreateNetAddr @Description: 新建网络地址 @receiver this @param password 钱包的密码 @param netAddressPassword 网络地址的密码 @return prk 地址私钥 @return puk 地址公钥 @return err
func (*Keystore) CreateNewKeystore ¶
创建一个新的种子文件
func (*Keystore) CreateNewWalletRand ¶
func (this *Keystore) CreateNewWalletRand(seedSrc []byte, password, firstCoinAddressPassword, netAddressAndDHkeyPassword string, coinAddrNum int) error
使用随机数创建一个新的种子文件
func (*Keystore) Decrypt ¶
Decrypt @Description: 使用钱包密码解密钱包种子,获得钱包私钥和链编码 @receiver this @param pwdbs 钱包密码 @return ok 密码是否正确 @return key 生成私钥的随机数 @return code 链编码 @return err
func (*Keystore) ExportMnemonic ¶
ExportMnemonic @Description: 导出助记词 @receiver this @param pwd 钱包密码 @return string 助词记 @return error
func (*Keystore) FindAddress ¶
func (this *Keystore) FindAddress(addr crypto.AddressCoin) (addrInfo AddressInfo, ok bool)
钱包中查找地址,判断地址是否属于本钱包
func (*Keystore) FindPuk ¶
func (this *Keystore) FindPuk(puk []byte) (addrInfo AddressInfo, ok bool)
钱包中查找公钥是否存在
func (*Keystore) GetCoinbase ¶
func (this *Keystore) GetCoinbase() *AddressInfo
func (*Keystore) GetFilePath ¶
func (*Keystore) GetKeyByAddr ¶
func (this *Keystore) GetKeyByAddr(addr crypto.AddressCoin, password string) (rand []byte, prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
GetKeyByAddr @Description: 通过地址获取密钥对 @receiver this @param addr 地址 @param password 地址密码 @return rand @return prk 地址私钥 @return puk 地址公钥 @return err
func (*Keystore) GetKeyByPuk ¶
func (this *Keystore) GetKeyByPuk(puk []byte, password string) (rand []byte, prk ed25519.PrivateKey, err error)
GetKeyByPuk @Description: 通过公钥获取密钥 @receiver this @param puk 地址公钥 @param password 地址密码 @return rand @return prk 地址私钥 @return err
func (*Keystore) GetNetAddr ¶
func (this *Keystore) GetNetAddr(password string) (prk ed25519.PrivateKey, puk ed25519.PublicKey, err error)
GetNetAddr @Description: 获取网络地址 @receiver this @param password 网络地址的密码 @return prk 地址私钥 @return puk 地址公钥 @return err
func (*Keystore) GetNetAddrPwd ¶
GetNetAddrPwd @Description: 获取密码 @receiver this @param prk @return string @return error
func (*Keystore) GetNewAddr ¶
func (this *Keystore) GetNewAddr(password, newAddressPassword string) (crypto.AddressCoin, error)
GetNewAddr @Description: 获取一个新的地址 @receiver this @param password 钱包密码 @param newAddressPassword 新地址密码 @return crypto.AddressCoin @return error
func (*Keystore) GetNewAddrByName ¶
func (this *Keystore) GetNewAddrByName(name, password, newAddressPassword string) (crypto.AddressCoin, error)
GetNewAddrByName @Description: 获取一个新的地址,并且给新地址一个昵称 @receiver this @param name 昵称 @param password 钱包密码 @param newAddressPassword 新地址密码 @return crypto.AddressCoin @return error
func (*Keystore) GetNewDHKey ¶
GetNewDHKey @Description: 创建DHKey协商秘钥 @receiver this @param password 钱包密码 @param newDHKeyPassword DHKey密码 @return *dh.KeyPair @return error
func (*Keystore) GetPukByAddr ¶
通过地址获取公钥
func (*Keystore) ImportMnemonic ¶
func (this *Keystore) ImportMnemonic(words, pwd, firstCoinAddressPassword, netAddressAndDHkeyPassword string) error
ImportMnemonic @Description: 导入助记词 @receiver this @param words 助记词 @param pwd 钱包密码 @param firstCoinAddressPassword 首个钱包地址的密码 @param firstAddressPassword 首个网络地址和DHkey的密码 @return error
func (*Keystore) ImportMnemonicCreateMoreCoinAddr ¶
func (this *Keystore) ImportMnemonicCreateMoreCoinAddr(words, pwd, firstCoinAddressPassword, netAddressAndDHkeyPassword string, coinAddrNum int) error
ImportMnemonicCreateMoreCoinAddr @Description: 导入助记词生成多个钱包地址 @receiver this @param words 助记词 @param pwd 钱包密码 @param firstCoinAddressPassword 首个钱包地址的密码 @param firstAddressPassword 首个网络地址和DHkey的密码 @param coinAddrNum 创建多少个钱包地址 @return error
func (*Keystore) SetKeyStore ¶
SetKeyStore @Description: 根据keystore文件设置Keystore对象 @receiver this @param filepath 文件路径 @param addrPre 地址前缀 @return error
func (*Keystore) UpdateAddrName ¶
func (this *Keystore) UpdateAddrName(name, password string, addr crypto.AddressCoin) error
UpdateAddrName @Description: 修改地址的昵称 @receiver this @param name 新昵称 @param password 地址密码 @param addr 地址 @return error
func (*Keystore) UpdateAddrPwd ¶
修改钱包子地址密码
func (*Keystore) UpdateDHKeyPwd ¶
UpdateDHKeyPwd @Description: 修改DHKey密碼 @receiver this @param index @param oldpwd 旧密码 @param newpwd 新密码 @return ok @return err
func (*Keystore) UpdateNetAddrPwd ¶
修改网络地址密码
type KeystoreInterface ¶
type KeystoreInterface interface { GetAddr() []*AddressInfo GetDHKeyPair() DHKeyPair CreateNetAddr(password, netAddressPassword string) (ed25519.PrivateKey, ed25519.PublicKey, error) GetNetAddr(pwd string) (ed25519.PrivateKey, ed25519.PublicKey, error) UpdateNetAddrPwd(oldpwd, newpwd string) (ok bool, err error) GetAddrAll() []*AddressInfo GetCoinbase() *AddressInfo FindAddress(addr crypto.AddressCoin) (addrInfo AddressInfo, ok bool) GetNewAddr(password, newAddressPassword string) (crypto.AddressCoin, error) GetKeyByAddr(addr crypto.AddressCoin, password string) (rand []byte, prk ed25519.PrivateKey, puk ed25519.PublicKey, err error) GetKeyByPuk(puk []byte, password string) (rand []byte, prk ed25519.PrivateKey, err error) GetPukByAddr(addr crypto.AddressCoin) (puk ed25519.PublicKey, ok bool) FindPuk(puk []byte) (addrInfo AddressInfo, ok bool) UpdatePwd(oldpwd, newpwd string) (ok bool, err error) UpdateAddrPwd(addr, oldpwd, newpwd string) (ok bool, err error) ImportMnemonic(words, pwd, firstCoinAddressPassword, netAddressAndDHkeyPassword string) error ExportMnemonic(pwd string) (string, error) GetFilePath() string }