Documentation ¶
Overview ¶
description: keybox
@author: xwc1125 @date: 2020/8/18 0018
description: keybox
@author: xwc1125 @date: 2020/8/6 0006
description: keybox
@author: xwc1125 @date: 2020/8/18 0018
Index ¶
- Constants
- Variables
- func SetBip39MnemonicType(mnemonicType MnemonicType)
- func SetIsLog(b bool)
- type ChainAPI
- type ChainInfo
- type ChildKeyPropertyInfo
- type ExtendedKey
- type MnemonicType
- type Wallet
- func (w *Wallet) CreateAccount(purpose, coinType, org, _account, change, addressIndex uint32, api ChainAPI) (addr string, keyPath string, err error)
- func (w *Wallet) DelMnemonic() error
- func (w *Wallet) ExportExtendedKey(address, keyPath string, api ChainAPI) (extendedKey string, err error)
- func (w *Wallet) ExportKeyStore(address, keyPath string, keystorePwd string, api ChainAPI) (keyStore string, err error)
- func (w *Wallet) ExportMasterExtendedKey() string
- func (w *Wallet) ExportMasterMnemonic() string
- func (w *Wallet) ExportMasterRawKey() string
- func (w *Wallet) ExportRawKey(address, keyPath string, api ChainAPI) (key string, err error)
- func (w *Wallet) GetPriKeyFromAddress(address, keyPath string, api ChainAPI) ([]byte, error)
- func (w *Wallet) ImportKeyStore(key []byte, password string) (address string, err error)
- func (w *Wallet) ImportRawKey(key string, password string) (address string, err error)
- func (w *Wallet) ListAccount() ([]string, error)
- func (w *Wallet) SetIsSaveExtendedKey(b bool)
- func (w *Wallet) SetIsSaveSubKey(b bool)
- func (w *Wallet) Sign(address, keyPath string, hash []byte, api ChainAPI) (string, error)
Constants ¶
const ( TypeBTC uint32 = 0x80000000 TypeETH uint32 = 0x8000003c TypeOMNI uint32 = 0x800000c8 )
https://github.com/satoshilabs/slips/blob/master/slip-0044.md
const (
Purpose45 uint32 = 0x8000002d
)
Variables ¶
var ( ChainInfoBTC = &ChainInfo{ ChainName: "BTC", ChainType: bip44.CoinTypeBTC, AlgorithmName: "S256", Algorithm: 0x80000200, } ChainInfoETH = &ChainInfo{ ChainName: "ETH", ChainType: TypeETH, AlgorithmName: "S256", Algorithm: 0x80000200, } )
Functions ¶
func SetBip39MnemonicType ¶
func SetBip39MnemonicType(mnemonicType MnemonicType)
==========================主账户============================ 设置助记词的类型【默认是使用English助记词,如果更换,需要在最前面初始化】
Types ¶
type ChildKeyPropertyInfo ¶
type ExtendedKey ¶
type MnemonicType ¶
type MnemonicType string
const ( MnemonicType_Chinese_Simplified MnemonicType = "chinese_simplified" MnemonicType_Chinese_Traditional MnemonicType = "chinese_traditional" MnemonicType_English MnemonicType = "english" MnemonicType_French MnemonicType = "french" MnemonicType_Italian MnemonicType = "italian" MnemonicType_Japanese MnemonicType = "japanese" MnemonicType_Korean MnemonicType = "korean" MnemonicType_Spanish MnemonicType = "spanish" )
func ParseMnemonicType ¶
func ParseMnemonicType(t string) MnemonicType
type Wallet ¶
type Wallet struct { Path string `json:"path"` Mnemonic string `json:"mnemonic"` Password string `json:"password"` Key *bip32.Key `json:"key"` Time uint32 `json:"time"` AddrLinkPubkey map[string]string `json:"addrLinkPubkey"` // 地址和公钥的配置 ChildKeyInfo map[string]*ChildKeyPropertyInfo `json:"childKeyInfo"` // 公钥对应的子私钥内容 IsSaveSubKey bool `json:"isSaveSubKey"` // 是否保存子私钥 IsSaveExtendedKey bool `json:"isSaveExtendedKey"` // 是否保存扩展私钥 // contains filtered or unexported fields }
Wallet 管理钱包文件
func LoadWalletFromMnemonic ¶
func LoadWalletFromMnemonic(path string, password string, mnemonic string, isUsePwdBlur bool) (*Wallet, error)
从助记词中恢复主钱包 isUsePwdBlur 是否使用Password进行混淆
func LoadWalletFromPrvKey ¶
从私钥中恢复钱包
func (*Wallet) CreateAccount ¶
func (w *Wallet) CreateAccount(purpose, coinType, org, _account, change, addressIndex uint32, api ChainAPI) (addr string, keyPath string, err error)
创建账户[同一机构下,同一中签名算法,的同一用户只会保留一个私钥] purpose purpose=44时,不使用org org:组织 coinType:币种 _account:将密钥空间划分为独立的用户身份[每一个用户对应一个地址空间] change:0用于外部接收地址 1用于找零地址 addressIndex:地址索引[官方推荐不超过20]
func (*Wallet) ExportExtendedKey ¶
func (w *Wallet) ExportExtendedKey(address, keyPath string, api ChainAPI) (extendedKey string, err error)
导出扩展私钥
func (*Wallet) ExportKeyStore ¶
func (w *Wallet) ExportKeyStore(address, keyPath string, keystorePwd string, api ChainAPI) (keyStore string, err error)
将地址对应的私钥转换成keystore
func (*Wallet) ExportMasterExtendedKey ¶
导出主账户的扩展私钥
func (*Wallet) ExportMasterMnemonic ¶
==========================主账户============================ 导出主账户的助记词
func (*Wallet) ExportRawKey ¶
将地址对应的私钥直接输出
func (*Wallet) GetPriKeyFromAddress ¶
GetPriKeyFromAddress 获取某个地址的私钥
func (*Wallet) ImportKeyStore ¶
导入keystore
func (*Wallet) ImportRawKey ¶
导入私钥
func (*Wallet) ListAccount ¶
ListAccount list all account
Directories ¶
Path | Synopsis |
---|---|
description: keybox
|
description: keybox |
https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
|
https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki |
description: keybox
|
description: keybox |
btc
description: keybox
|
description: keybox |
btc/helpers
Package helpers provides convenience functions to simplify wallet code.
|
Package helpers provides convenience functions to simplify wallet code. |
btc/txauthor
Package txauthor provides transaction creation code for wallets.
|
Package txauthor provides transaction creation code for wallets. |
btc/txrules
Package txrules provides transaction rules that should be followed by transaction authors for wide mempool acceptance and quick mining.
|
Package txrules provides transaction rules that should be followed by transaction authors for wide mempool acceptance and quick mining. |
crypto
|
|
address
description: keybox
|
description: keybox |
scrypt
description: subchain-sdk-go
|
description: subchain-sdk-go |
util
|
|
convutil
description: xblog
|
description: xblog |
dateutil
description: keybox
|
description: keybox |
description: keybox
|
description: keybox |