Documentation ¶
Overview ¶
Package common 实现钱包基础功能包
Index ¶
- Variables
- func CBCDecrypterPrivkey(password []byte, privkey []byte) []byte
- func CBCEncrypterPrivkey(password []byte, privkey []byte) []byte
- func CalcAccountKey(timestamp string, addr string) []byte
- func CalcAddrKey(addr string) []byte
- func CalcAirDropIndex() []byte
- func CalcEncryptionFlag() []byte
- func CalcLabelKey(label string) []byte
- func CalcPasswordHash() []byte
- func CalcTxKey(key string) []byte
- func CalcWalletSeed() []byte
- func CalckeyEncryptionCompFlag() []byte
- func Init(wallet WalletOperate, sub map[string][]byte)
- func RegisterPolicy(key string, policy WalletBizPolicy)
- type AddrInfo
- type MineStatusReport
- type Store
- func (store *Store) Close()
- func (store *Store) DelAccountByLabel(label string)
- func (store *Store) FreeBlockBatch()
- func (store *Store) Get(key []byte) ([]byte, error)
- func (store *Store) GetAccountByAddr(addr string) (*types.WalletAccountStore, error)
- func (store *Store) GetAccountByLabel(label string) (*types.WalletAccountStore, error)
- func (store *Store) GetAccountByPrefix(addr string) ([]*types.WalletAccountStore, error)
- func (store *Store) GetAccountByte(update bool, addr string, account *types.WalletAccountStore) ([]byte, error)
- func (store *Store) GetAirDropIndex() (string, error)
- func (store *Store) GetBlockBatch(sync bool) db.Batch
- func (store *Store) GetDB() db.DB
- func (store *Store) GetEncryptionFlag() int64
- func (store *Store) GetTxDetailByIter(TxList *types.ReqWalletTransactionList) (*types.WalletTxDetails, error)
- func (store *Store) GetWalletVersion() int64
- func (store *Store) HasSeed() (bool, error)
- func (store *Store) NewBatch(sync bool) db.Batch
- func (store *Store) NewListHelper() *db.ListHelper
- func (store *Store) Set(key []byte, value []byte) (err error)
- func (store *Store) SetAirDropIndex(airDropIndex *AddrInfo) error
- func (store *Store) SetEncryptionFlag(batch db.Batch) error
- func (store *Store) SetPasswordHash(password string, batch db.Batch) error
- func (store *Store) SetWalletAccount(update bool, addr string, account *types.WalletAccountStore) error
- func (store *Store) SetWalletAccountInBatch(update bool, addr string, account *types.WalletAccountStore, newbatch db.Batch) error
- func (store *Store) SetWalletVersion(ver int64) error
- func (store *Store) VerifyPasswordHash(password string) bool
- type WalletBizPolicy
- type WalletOperate
Constants ¶
This section is empty.
Variables ¶
var ( // QueryData 查询接口数据全局对象 QueryData = types.NewQueryData("On_") // PolicyContainer 钱包业务容器 PolicyContainer = make(map[string]WalletBizPolicy) )
Functions ¶
func CBCDecrypterPrivkey ¶
CBCDecrypterPrivkey 使用钱包的password对私钥进行aes cbc解密,返回解密后的privkey
func CBCEncrypterPrivkey ¶
CBCEncrypterPrivkey 使用钱包的password对私钥进行aes cbc加密,返回加密后的privkey
func CalcAccountKey ¶
CalcAccountKey 用于所有Account账户的输出list,需要安装时间排序
func CalckeyEncryptionCompFlag ¶
func CalckeyEncryptionCompFlag() []byte
CalckeyEncryptionCompFlag 加密比较标志Key
func RegisterPolicy ¶
func RegisterPolicy(key string, policy WalletBizPolicy)
RegisterPolicy 注册钱包业务策略接口
Types ¶
type AddrInfo ¶
type AddrInfo struct { Index uint32 `json:"index,omitempty"` Addr string `json:"addr,omitempty"` Pubkey string `json:"pubkey,omitempty"` }
AddrInfo 通过seed指定index创建的账户信息,目前主要用于空投地址
type MineStatusReport ¶
type MineStatusReport interface { IsAutoMining() bool // 返回挖矿买票锁的状态 IsTicketLocked() bool PolicyName() string }
MineStatusReport 挖矿操作状态
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store 钱包通用数据库存储类,实现对钱包账户数据库操作的基本实现
func (*Store) DelAccountByLabel ¶
DelAccountByLabel 根据标签名称,删除对应的账号信息
func (*Store) FreeBlockBatch ¶ added in v1.65.0
func (store *Store) FreeBlockBatch()
FreeBlockBatch free
func (*Store) GetAccountByAddr ¶
func (store *Store) GetAccountByAddr(addr string) (*types.WalletAccountStore, error)
GetAccountByAddr 根据地址获取账号信息
func (*Store) GetAccountByLabel ¶
func (store *Store) GetAccountByLabel(label string) (*types.WalletAccountStore, error)
GetAccountByLabel 根据标签获取账号信息
func (*Store) GetAccountByPrefix ¶
func (store *Store) GetAccountByPrefix(addr string) ([]*types.WalletAccountStore, error)
GetAccountByPrefix 根据前缀获取账号信息列表
func (*Store) GetAccountByte ¶
func (store *Store) GetAccountByte(update bool, addr string, account *types.WalletAccountStore) ([]byte, error)
GetAccountByte 获取账号byte类型
func (*Store) GetAirDropIndex ¶
GetAirDropIndex 获取指定index的空投地址
func (*Store) GetBlockBatch ¶ added in v1.65.0
GetBlockBatch 新建批处理操作对象接口
func (*Store) GetEncryptionFlag ¶
GetEncryptionFlag 获取加密方式
func (*Store) GetTxDetailByIter ¶
func (store *Store) GetTxDetailByIter(TxList *types.ReqWalletTransactionList) (*types.WalletTxDetails, error)
GetTxDetailByIter 迭代获取从指定key:height*100000+index 开始向前或者向后查找指定count的交易
func (*Store) GetWalletVersion ¶
GetWalletVersion 获取wallet数据库的版本号
func (*Store) NewListHelper ¶
func (store *Store) NewListHelper() *db.ListHelper
NewListHelper 新建列表复制操作对象
func (*Store) SetAirDropIndex ¶
SetAirDropIndex 存储指定index的空投地址信息
func (*Store) SetEncryptionFlag ¶
SetEncryptionFlag 设置加密方式标志
func (*Store) SetPasswordHash ¶
SetPasswordHash 保存密码哈希
func (*Store) SetWalletAccount ¶
func (store *Store) SetWalletAccount(update bool, addr string, account *types.WalletAccountStore) error
SetWalletAccount 保存钱包账户信息
func (*Store) SetWalletAccountInBatch ¶
func (store *Store) SetWalletAccountInBatch(update bool, addr string, account *types.WalletAccountStore, newbatch db.Batch) error
SetWalletAccountInBatch 保存钱包账号信息
func (*Store) SetWalletVersion ¶
SetWalletVersion 升级数据库的版本号
func (*Store) VerifyPasswordHash ¶
VerifyPasswordHash 检查密码有效性
type WalletBizPolicy ¶
type WalletBizPolicy interface { // Init 初始化钱包业务策略,在使用前调用 Init(walletBiz WalletOperate, sub []byte) // OnAddBlockTx 当区块被增加确认时调用本函数 // block: 被增加的区块详细信息 // tx: 区块增加的交易信息 // index: 交易信息在区块上的索引为止,从0开始计数 // dbbatch: 数据库批量操作接口 // 返回值为提供给外部快速检索的钱包详细信息,如果内部已经处理,不需要外部处理的情况下,可以返回nil OnAddBlockTx(block *types.BlockDetail, tx *types.Transaction, index int32, dbbatch db.Batch) *types.WalletTxDetail // OnDeleteBlockTx 当区块被回退删除时调用本函数 // block: 被回退的区块详细信息 // tx: 区块回退的交易信息 // index: 交易信息在区块上的索引为止,从0开始计数 // dbbatch: 数据库批量操作接口 // 返回值为提供给外部快速检索的钱包详细信息,如果内部已经处理,不需要外部处理的情况下,可以返回nil OnDeleteBlockTx(block *types.BlockDetail, tx *types.Transaction, index int32, dbbatch db.Batch) *types.WalletTxDetail // SignTransaction 针对特殊的交易,按照新的签名方式签名 // key 签名的私钥信息 // req 需要签名交易流信息 // needSysSign 表示是否需要继续走系统流程的签名,true表示继续,false表示已经完成签名,不需要系统处理 // signtx 签名成功后,保存签名成功的交易字符串 // err 错误信息 SignTransaction(key crypto.PrivKey, req *types.ReqSignRawTx) (needSysSign bool, signtx string, err error) // OnCreateNewAccount 当用户在钱包中新建账户时,将调用本接口函数 OnCreateNewAccount(acc *types.Account) // OnImportPrivateKey 当用户导入私钥时,将调用本函数 OnImportPrivateKey(acc *types.Account) OnWalletLocked() OnWalletUnlocked(WalletUnLock *types.WalletUnLock) OnAddBlockFinish(block *types.BlockDetail) OnDeleteBlockFinish(block *types.BlockDetail) OnClose() OnSetQueueClient() Call(funName string, in types.Message) (ret types.Message, err error) }
WalletBizPolicy 细分钱包业务逻辑的街口
type WalletOperate ¶
type WalletOperate interface { RegisterMineStatusReporter(reporter MineStatusReport) error GetAPI() client.QueueProtocolAPI GetDBStore() db.DB GetSignType() int GetCoinType() uint32 GetPassword() string GetBlockHeight() int64 GetRandom() *rand.Rand GetWalletDone() chan struct{} GetLastHeader() *types.Header GetTxDetailByHashs(ReqHashes *types.ReqHashes) GetWaitGroup() *sync.WaitGroup GetAllPrivKeys() ([]crypto.PrivKey, error) GetWalletAccounts() ([]*types.WalletAccountStore, error) GetPrivKeyByAddr(addr string) (crypto.PrivKey, error) GetConfig() *types.Wallet GetBalance(addr string, execer string) (*types.Account, error) IsWalletLocked() bool IsClose() bool IsCaughtUp() bool AddrInWallet(addr string) bool CheckWalletStatus() (bool, error) Nonce() int64 WaitTx(hash []byte) *types.TransactionDetail WaitTxs(hashes [][]byte) (ret []*types.TransactionDetail) SendTransaction(payload types.Message, execer []byte, priv crypto.PrivKey, to string) (hash []byte, err error) SendToAddress(priv crypto.PrivKey, addrto string, amount int64, note string, Istoken bool, tokenSymbol string) (*types.ReplyHash, error) }
WalletOperate 钱包对业务插件提供服务的操作接口