Documentation
¶
Index ¶
- Constants
- Variables
- func NewAddressDecoder(wm *WalletManager) *addressDecoder
- func ParseHeader(b *eos.BlockResp) *openwallet.BlockHeader
- type Block
- type CacheManager
- func (cm *CacheManager) Add(key string, value interface{}, duration time.Duration) error
- func (cm *CacheManager) Clear()
- func (cm *CacheManager) Contains(key string) bool
- func (cm *CacheManager) Get(key string) (interface{}, bool)
- func (cm *CacheManager) GetCacheEntry(key string) (*openwallet.CacheEntry, bool)
- func (cm *CacheManager) Remove(key string) (interface{}, bool)
- type Client
- type ContractDecoder
- func (decoder *ContractDecoder) GetABIInfo(address string) (*openwallet.ABIInfo, error)
- func (decoder *ContractDecoder) GetTokenBalanceByAddress(contract openwallet.SmartContract, address ...string) ([]*openwallet.TokenBalance, error)
- func (decoder *ContractDecoder) SetABIInfo(address string, abi openwallet.ABIInfo) error
- type EOSBlockScanner
- func (bs *EOSBlockScanner) BatchExtractTransactions(blockHeight uint64, blockHash string, blockTime int64, ...) error
- func (bs *EOSBlockScanner) DeleteUnscanRecord(height uint32) error
- func (bs *EOSBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, ...) ExtractResult
- func (bs *EOSBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
- func (bs *EOSBlockScanner) GetChainInfo() (infoResp *eos.InfoResp, err error)
- func (bs *EOSBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *EOSBlockScanner) GetGlobalHeadBlock() (block *eos.BlockResp, err error)
- func (bs *EOSBlockScanner) GetGlobalMaxBlockHeight() uint64
- func (bs *EOSBlockScanner) GetLocalBlock(height uint32) (*Block, error)
- func (bs *EOSBlockScanner) GetLocalBlockHead() (uint32, string, error)
- func (bs *EOSBlockScanner) GetScannedBlockHeight() uint64
- func (bs *EOSBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
- func (bs *EOSBlockScanner) InitExtractResult(sourceKey string, action TransferAction, result *ExtractResult, optType int64)
- func (bs *EOSBlockScanner) RescanFailedRecord()
- func (bs *EOSBlockScanner) SaveLocalBlock(blockHeader *Block) error
- func (bs *EOSBlockScanner) SaveLocalBlockHead(blockHeight uint32, blockHash string) error
- func (bs *EOSBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
- func (bs *EOSBlockScanner) ScanBlock(height uint64) error
- func (bs *EOSBlockScanner) ScanBlockTask()
- func (bs *EOSBlockScanner) SetRescanBlockHeight(height uint64) error
- func (bs *EOSBlockScanner) SupportBlockchainDAI() bool
- type ExtractResult
- type SaveResult
- type TransactionDecoder
- func (decoder *TransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
- func (decoder *TransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (decoder *TransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)
- func (decoder *TransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
- func (decoder *TransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- type TransferAction
- type TransferData
- type WalletConfig
- type WalletManager
- func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
- func (wm *WalletManager) CurveType() uint32
- func (wm *WalletManager) Decimal() int32
- func (wm *WalletManager) FullName() string
- func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
- func (wm *WalletManager) GetAddressDecoderV2() openwallet.AddressDecoderV2
- func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
- func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
- func (wm *WalletManager) GetJsonRPCEndpoint() openwallet.JsonRPCEndpoint
- func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
- func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
- func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
- func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
- func (wm *WalletManager) Symbol() string
Constants ¶
const (
CurveType = owcrypt.ECC_CURVE_SECP256K1
)
Variables ¶
var (
//币种
Symbol = "EOS"
)
Functions ¶
func NewAddressDecoder ¶
func NewAddressDecoder(wm *WalletManager) *addressDecoder
NewAddressDecoder 地址解析器
Types ¶
type Block ¶
type Block struct {
/*
{
"timestamp": "2019-01-24T19:32:05.500",
"producer": "blkproducer1",
"confirmed": 0,
"previous": "0137c066283ef586d4e1dba4711b2ddf0248628595855361d9b0920e7f64ea92",
"transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000",
"action_mroot": "60c9f06aef01b1b4b2088785c9239c960bca8fc23cedd6b8104c69c0335a6d39",
"schedule_version": 2,
"new_producers": null,
"header_extensions": [],
"producer_signature": "SIG_K1_K11ScNfXdat71utYJtkd8E6dFtvA7qQ3ww9K74xEpFvVCyeZhXTarwvGa7QqQTRw3CLFbsXCsWJFNCHFHLKWrnBNZ66c2m",
"transactions": [],
"block_extensions": [],
"id": "0137c067c65e9db8f8ee467c856fb6d1779dfeb0332a971754156d075c9a37ca",
"block_num": 20430951,
"ref_block_prefix": 2085023480
}
*/
openwallet.BlockHeader
Height uint32 `storm:"id"`
Fork bool
// contains filtered or unexported fields
}
Block model
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
func NewCacheManager ¶
func NewCacheManager() CacheManager
func (*CacheManager) Add ¶
func (cm *CacheManager) Add(key string, value interface{}, duration time.Duration) error
func (*CacheManager) Clear ¶
func (cm *CacheManager) Clear()
func (*CacheManager) Contains ¶
func (cm *CacheManager) Contains(key string) bool
func (*CacheManager) Get ¶
func (cm *CacheManager) Get(key string) (interface{}, bool)
func (*CacheManager) GetCacheEntry ¶
func (cm *CacheManager) GetCacheEntry(key string) (*openwallet.CacheEntry, bool)
func (*CacheManager) Remove ¶
func (cm *CacheManager) Remove(key string) (interface{}, bool)
type Client ¶ added in v1.2.0
func (*Client) SendRPCRequest ¶ added in v1.2.0
SendRPCRequest 发起JSON-RPC请求 @optional
func (*Client) SupportJsonRPCEndpoint ¶ added in v1.2.0
SupportJsonRPCEndpoint 是否开放客户端直接调用全节点的JSON-RPC方法 @optional
type ContractDecoder ¶
type ContractDecoder struct {
openwallet.SmartContractDecoderBase
// contains filtered or unexported fields
}
func NewContractDecoder ¶
func NewContractDecoder(wm *WalletManager) *ContractDecoder
NewContractDecoder 智能合约解析器
func (*ContractDecoder) GetABIInfo ¶
func (decoder *ContractDecoder) GetABIInfo(address string) (*openwallet.ABIInfo, error)
GetABIInfo get abi
func (*ContractDecoder) GetTokenBalanceByAddress ¶
func (decoder *ContractDecoder) GetTokenBalanceByAddress(contract openwallet.SmartContract, address ...string) ([]*openwallet.TokenBalance, error)
func (*ContractDecoder) SetABIInfo ¶
func (decoder *ContractDecoder) SetABIInfo(address string, abi openwallet.ABIInfo) error
SetABIInfo set abi
type EOSBlockScanner ¶
type EOSBlockScanner struct {
*openwallet.BlockScannerBase
CurrentBlockHeight uint64 //当前区块高度
IsScanMemPool bool //是否扫描交易池
RescanLastBlockCount uint64 //重扫上N个区块数量
MonitorActions map[string]bool //监控的操作
// contains filtered or unexported fields
}
EOSBlockScanner EOS block scanner
func NewEOSBlockScanner ¶
func NewEOSBlockScanner(wm *WalletManager) *EOSBlockScanner
NewEOSBlockScanner create a block scanner
func (*EOSBlockScanner) BatchExtractTransactions ¶
func (bs *EOSBlockScanner) BatchExtractTransactions(blockHeight uint64, blockHash string, blockTime int64, transactions []eos.TransactionReceipt) error
BatchExtractTransactions 批量提取交易单
func (*EOSBlockScanner) DeleteUnscanRecord ¶
func (bs *EOSBlockScanner) DeleteUnscanRecord(height uint32) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*EOSBlockScanner) ExtractTransaction ¶
func (bs *EOSBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, transaction eos.TransactionReceipt, scanTargetFunc openwallet.BlockScanTargetFunc) ExtractResult
ExtractTransaction 提取交易单
func (*EOSBlockScanner) GetBalanceByAddress ¶
func (bs *EOSBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
GetBalanceByAddress 查询地址余额
func (*EOSBlockScanner) GetChainInfo ¶
func (bs *EOSBlockScanner) GetChainInfo() (infoResp *eos.InfoResp, err error)
GetChainInfo GetChainInfo
func (*EOSBlockScanner) GetCurrentBlockHeader ¶ added in v1.0.9
func (bs *EOSBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
func (*EOSBlockScanner) GetGlobalHeadBlock ¶
func (bs *EOSBlockScanner) GetGlobalHeadBlock() (block *eos.BlockResp, err error)
GetGlobalHeadBlock GetGlobalHeadBlock
func (*EOSBlockScanner) GetGlobalMaxBlockHeight ¶
func (bs *EOSBlockScanner) GetGlobalMaxBlockHeight() uint64
GetGlobalMaxBlockHeight GetGlobalMaxBlockHeight
func (*EOSBlockScanner) GetLocalBlock ¶
func (bs *EOSBlockScanner) GetLocalBlock(height uint32) (*Block, error)
GetLocalBlock 获取本地区块数据
func (*EOSBlockScanner) GetLocalBlockHead ¶
func (bs *EOSBlockScanner) GetLocalBlockHead() (uint32, string, error)
GetLocalBlockHead 获取本地记录的区块高度和hash
func (*EOSBlockScanner) GetScannedBlockHeight ¶
func (bs *EOSBlockScanner) GetScannedBlockHeight() uint64
GetScannedBlockHeight 获取已扫区块高度
func (*EOSBlockScanner) GetUnscanRecords ¶ added in v1.1.0
func (bs *EOSBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
func (*EOSBlockScanner) InitExtractResult ¶
func (bs *EOSBlockScanner) InitExtractResult(sourceKey string, action TransferAction, result *ExtractResult, optType int64)
InitExtractResult optType = 0: 输入输出提取,1: 输入提取,2:输出提取
func (*EOSBlockScanner) RescanFailedRecord ¶ added in v1.1.0
func (bs *EOSBlockScanner) RescanFailedRecord()
rescanFailedRecord 重扫失败记录
func (*EOSBlockScanner) SaveLocalBlock ¶
func (bs *EOSBlockScanner) SaveLocalBlock(blockHeader *Block) error
SaveLocalBlock 记录本地新区块
func (*EOSBlockScanner) SaveLocalBlockHead ¶
func (bs *EOSBlockScanner) SaveLocalBlockHead(blockHeight uint32, blockHash string) error
SaveLocalBlockHead 记录区块高度和hash到本地
func (*EOSBlockScanner) SaveUnscanRecord ¶
func (bs *EOSBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
SaveUnscanRecord 保存交易记录到钱包数据库
func (*EOSBlockScanner) ScanBlock ¶
func (bs *EOSBlockScanner) ScanBlock(height uint64) error
ScanBlock 扫描指定高度区块
func (*EOSBlockScanner) ScanBlockTask ¶
func (bs *EOSBlockScanner) ScanBlockTask()
ScanBlockTask scan block task
func (*EOSBlockScanner) SetRescanBlockHeight ¶
func (bs *EOSBlockScanner) SetRescanBlockHeight(height uint64) error
SetRescanBlockHeight 重置区块链扫描高度
func (*EOSBlockScanner) SupportBlockchainDAI ¶ added in v1.1.0
func (bs *EOSBlockScanner) SupportBlockchainDAI() bool
SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional
type ExtractResult ¶
type ExtractResult struct {
TxID string
BlockHash string
BlockHeight uint64
BlockTime int64
Success bool
// contains filtered or unexported fields
}
ExtractResult extract result
type SaveResult ¶
SaveResult result
type TransactionDecoder ¶
type TransactionDecoder struct {
openwallet.TransactionDecoderBase
// contains filtered or unexported fields
}
TransactionDecoder 交易单解析器
func NewTransactionDecoder ¶
func NewTransactionDecoder(wm *WalletManager) *TransactionDecoder
NewTransactionDecoder 交易单解析器
func (*TransactionDecoder) CreateRawTransaction ¶
func (decoder *TransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
CreateRawTransaction 创建交易单
func (*TransactionDecoder) CreateSummaryRawTransaction ¶
func (decoder *TransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
CreateSummaryRawTransaction 创建汇总交易
func (*TransactionDecoder) CreateSummaryRawTransactionWithError ¶
func (decoder *TransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateSummaryRawTransactionWithError 创建汇总交易
func (*TransactionDecoder) GetRawTransactionFeeRate ¶
func (decoder *TransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)
GetRawTransactionFeeRate 获取交易单的费率
func (*TransactionDecoder) SignRawTransaction ¶
func (decoder *TransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
SignRawTransaction 签名交易单
func (*TransactionDecoder) SubmitRawTransaction ¶
func (decoder *TransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
SubmitRawTransaction 广播交易单
func (*TransactionDecoder) VerifyRawTransaction ¶
func (decoder *TransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单
type TransferAction ¶
type TransferAction struct {
*eos.Action
TransferData
}
TransferAction transfer action
type TransferData ¶
type TransferData struct {
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Quantity eos.Asset `json:"quantity,omitempty"`
Memo string `json:"memo,omitempty"`
}
TransferData token contract transfer action data
type WalletConfig ¶
type WalletConfig struct {
//币种
Symbol string
//区块链数据文件
BlockchainFile string
//本地数据库文件路径
DBPath string
//钱包服务API
ServerAPI string
//默认配置内容
DefaultConfig string
//曲线类型
CurveType uint32
//链ID
//ChainID uint64
//数据目录
DataDir string
//broadcast tx api url
BroadcastAPI string
// contains filtered or unexported fields
}
func NewConfig ¶
func NewConfig(symbol string) *WalletConfig
type WalletManager ¶
type WalletManager struct {
openwallet.AssetsAdapterBase
Api *eos.API // 节点客户端
BroadcastAPI *eos.API //广播交易节点
Config *WalletConfig // 节点配置
Decoder openwallet.AddressDecoder //地址编码器
DecoderV2 openwallet.AddressDecoderV2 //地址编码器2
TxDecoder openwallet.TransactionDecoder //交易单编码器
Log *log.OWLogger //日志工具
ContractDecoder openwallet.SmartContractDecoder //智能合约解析器
Blockscanner *EOSBlockScanner //区块扫描器
CacheManager openwallet.ICacheManager //缓存管理器
// contains filtered or unexported fields
}
func NewWalletManager ¶
func NewWalletManager(cacheManager openwallet.ICacheManager) *WalletManager
func (*WalletManager) BalanceModelType ¶
func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
BalanceModelType 余额模型类型
func (*WalletManager) GetAddressDecode ¶
func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
GetAddressDecode 地址解析器
func (*WalletManager) GetAddressDecoderV2 ¶ added in v1.4.0
func (wm *WalletManager) GetAddressDecoderV2() openwallet.AddressDecoderV2
GetAddressDecode 地址解析器 如果实现了AddressDecoderV2,就无需实现AddressDecoder
func (*WalletManager) GetAssetsLogger ¶
func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
GetAssetsLogger 获取资产账户日志工具
func (*WalletManager) GetBlockScanner ¶
func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
GetBlockScanner 获取区块链
func (*WalletManager) GetJsonRPCEndpoint ¶ added in v1.2.0
func (wm *WalletManager) GetJsonRPCEndpoint() openwallet.JsonRPCEndpoint
GetJsonRPCEndpoint 获取全节点服务的JSON-RPC客户端 @optional
func (*WalletManager) GetSmartContractDecoder ¶
func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
GetSmartContractDecoder 获取智能合约解析器
func (*WalletManager) GetTransactionDecoder ¶
func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
GetTransactionDecoder 交易单解析器
func (*WalletManager) InitAssetsConfig ¶
func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
InitAssetsConfig 初始化默认配置
func (*WalletManager) LoadAssetsConfig ¶
func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
LoadAssetsConfig 加载外部配置