Documentation ¶
Index ¶
- Constants
- Variables
- func Digest(txHex []byte, chainId string) ([]byte, error)
- func NewAddressDecoder(wm *WalletManager) *addressDecoder
- func NewTransaction(result *gjson.Result, transactionID string) (*types.Transaction, error)
- func ParseHeader(b *Block) *openwallet.BlockHeader
- type Asset
- type Balance
- type Block
- type BlockHeader
- type BlockchainInfo
- type BroadcastResponse
- 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 ContractDecoder
- type ExtractResult
- type SaveResult
- type StmBlockScanner
- func (bs *StmBlockScanner) BatchExtractTransactions(blockHeight uint64, blockHash string, blockTime int64, ...) error
- func (bs *StmBlockScanner) DeleteUnscanRecord(height uint32) error
- func (bs *StmBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, ...) ExtractResult
- func (bs *StmBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
- func (bs *StmBlockScanner) GetChainInfo() (infoResp *BlockchainInfo, err error)
- func (bs *StmBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *StmBlockScanner) GetGlobalHeadBlock() (block *Block, err error)
- func (bs *StmBlockScanner) GetGlobalMaxBlockHeight() uint64
- func (bs *StmBlockScanner) GetLocalBlock(height uint32) (*Block, error)
- func (bs *StmBlockScanner) GetLocalBlockHead() (uint32, string, error)
- func (bs *StmBlockScanner) GetScannedBlockHeight() uint64
- func (bs *StmBlockScanner) InitExtractResult(sourceKey string, operation *types.Op, result *ExtractResult, optType int64)
- func (bs *StmBlockScanner) RescanFailedRecord()
- func (bs *StmBlockScanner) SaveLocalBlock(blockHeader *Block) error
- func (bs *StmBlockScanner) SaveLocalBlockHead(blockHeight uint32, blockHash string) error
- func (bs *StmBlockScanner) SaveUnscanRecord(record *UnscanRecord) error
- func (bs *StmBlockScanner) ScanBlock(height uint64) error
- func (bs *StmBlockScanner) ScanBlockTask()
- func (bs *StmBlockScanner) SetRescanBlockHeight(height uint64) error
- 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 UnscanRecord
- type WalletClient
- func (c *WalletClient) BroadcastTransaction(tx interface{}) (*BroadcastResponse, error)
- func (c *WalletClient) GetAccountID(name string) (*types.ObjectID, error)
- func (c *WalletClient) GetAccounts(names_or_ids ...string) ([]*types.Account, error)
- func (c *WalletClient) GetAssetsBalance(account types.ObjectID, asset types.ObjectID) (*Balance, error)
- func (c *WalletClient) GetBlockByHeight(height uint32) (*Block, error)
- func (c *WalletClient) GetBlockchainInfo() (*BlockchainInfo, error)
- func (c *WalletClient) GetRequiredFee(ops []bt.Operation, assetID string) ([]bt.AssetAmount, error)
- func (c *WalletClient) GetTransaction(height uint32, trxInBlock int) (*types.Transaction, error)
- func (c *WalletClient) GetTransactionHex(rawTx interface{}) ([]byte, error)
- func (c *WalletClient) GetTransactionID(tx *types.Transaction) (string, error)
- type WalletConfig
- type WalletManager
- func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
- func (wm *WalletManager) CurveType() uint32
- func (wm *WalletManager) Decimal() int32
- func (wm *WalletManager) DeleteUnscanRecordNotFindTX() error
- func (wm *WalletManager) FullName() string
- func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
- func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
- func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
- func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
- func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
- func (wm *WalletManager) GetUnscanRecords() ([]*UnscanRecord, error)
- 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 // 链上各币的operation_type SteemNai = "@@000000021" SBDNai = "@@000000013" VestsNai = "@@000000037" )
const TimeLayout = `2006-01-02T15:04:05`
Variables ¶
var (
//币种
Symbol = "STM"
)
Functions ¶
func NewAddressDecoder ¶
func NewAddressDecoder(wm *WalletManager) *addressDecoder
NewAddressDecoder 地址解析器
func NewTransaction ¶
Types ¶
type Balance ¶
func NewBalance ¶
type Block ¶
type Block struct { Previous string `json:"previous"` Timestamp types.Time `json:"timestamp"` Witness string `json:"witness"` TransactionMerkleRoot string `json:"transaction_merkle_root"` Extensions []json.RawMessage `json:"extensions"` WitnessSignature string `json:"witness_signature"` Transactions []*types.Transaction `json:"transactions"` BlockID string `json:"block_id"` SigningKey string `json:"signing_key"` TransactionIDs []string `json:"transaction_ids"` Height uint64 }
func (*Block) CalculateID ¶
type BlockHeader ¶
type BlockHeader struct { TransactionMerkleRoot string `json:"transaction_merkle_root"` Previous string `json:"previous"` Timestamp types.Time `json:"timestamp"` Witness string `json:"witness"` Extensions []json.RawMessage `json:"extensions"` WitnessSignature string `json:"witness_signature"` }
func NewBlockHeader ¶
func NewBlockHeader(result *gjson.Result) *BlockHeader
func (*BlockHeader) CalculateID ¶
func (block *BlockHeader) CalculateID() (string, error)
func (*BlockHeader) Marshal ¶
func (block *BlockHeader) Marshal(encoder *encoding.Encoder) error
MarshalBlockHeader implements encoding_.Marshaller interface.
func (*BlockHeader) Serialize ¶
func (block *BlockHeader) Serialize() ([]byte, error)
type BlockchainInfo ¶
type BlockchainInfo struct { HeadBlockNum uint64 `json:"head_block_number"` HeadBlockID string `json:"head_block_id"` LastIrreversibleBlockNum uint64 `json:"last_irreversible_block_num"` Timestamp time.Time `json:"time"` }
func NewBlockchainInfo ¶
func NewBlockchainInfo(result *gjson.Result) *BlockchainInfo
type BroadcastResponse ¶
type BroadcastResponse struct {
ID string `json:"id"`
}
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 ContractDecoder ¶
type ContractDecoder struct { openwallet.SmartContractDecoderBase // contains filtered or unexported fields }
func NewContractDecoder ¶
func NewContractDecoder(wm *WalletManager) *ContractDecoder
NewContractDecoder 智能合约解析器
func (*ContractDecoder) GetTokenBalanceByAddress ¶
func (decoder *ContractDecoder) GetTokenBalanceByAddress(contract openwallet.SmartContract, address ...string) ([]*openwallet.TokenBalance, error)
GetTokenBalanceByAddress return the balance by account alias, queried by rpc
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 StmBlockScanner ¶ added in v1.0.2
type StmBlockScanner struct { *openwallet.BlockScannerBase CurrentBlockHeight uint64 //当前区块高度 IsScanMemPool bool //是否扫描交易池 RescanLastBlockCount uint64 //重扫上N个区块数量 // contains filtered or unexported fields }
StmBlockScanner BTS block scanner
func NewBlockScanner ¶
func NewBlockScanner(wm *WalletManager) *StmBlockScanner
NewBlockScanner create a block scanner
func (*StmBlockScanner) BatchExtractTransactions ¶ added in v1.0.2
func (bs *StmBlockScanner) BatchExtractTransactions(blockHeight uint64, blockHash string, blockTime int64, transactions []*types.Transaction, txIDs []string) error
BatchExtractTransactions 批量提取交易单
func (*StmBlockScanner) DeleteUnscanRecord ¶ added in v1.0.2
func (bs *StmBlockScanner) DeleteUnscanRecord(height uint32) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*StmBlockScanner) ExtractTransaction ¶ added in v1.0.2
func (bs *StmBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, transaction *types.Transaction, scanTargetFunc openwallet.BlockScanTargetFunc) ExtractResult
ExtractTransaction 提取交易单
func (*StmBlockScanner) GetBalanceByAddress ¶ added in v1.0.2
func (bs *StmBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
GetBalanceByAddress 查询地址余额
func (*StmBlockScanner) GetChainInfo ¶ added in v1.0.2
func (bs *StmBlockScanner) GetChainInfo() (infoResp *BlockchainInfo, err error)
GetChainInfo GetChainInfo
func (*StmBlockScanner) GetCurrentBlockHeader ¶ added in v1.0.2
func (bs *StmBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
func (*StmBlockScanner) GetGlobalHeadBlock ¶ added in v1.0.2
func (bs *StmBlockScanner) GetGlobalHeadBlock() (block *Block, err error)
GetGlobalHeadBlock GetGlobalHeadBlock
func (*StmBlockScanner) GetGlobalMaxBlockHeight ¶ added in v1.0.2
func (bs *StmBlockScanner) GetGlobalMaxBlockHeight() uint64
GetGlobalMaxBlockHeight GetGlobalMaxBlockHeight
func (*StmBlockScanner) GetLocalBlock ¶ added in v1.0.2
func (bs *StmBlockScanner) GetLocalBlock(height uint32) (*Block, error)
GetLocalBlock 获取本地区块数据
func (*StmBlockScanner) GetLocalBlockHead ¶ added in v1.0.2
func (bs *StmBlockScanner) GetLocalBlockHead() (uint32, string, error)
GetLocalBlockHead 获取本地记录的区块高度和hash
func (*StmBlockScanner) GetScannedBlockHeight ¶ added in v1.0.2
func (bs *StmBlockScanner) GetScannedBlockHeight() uint64
GetScannedBlockHeight 获取已扫区块高度
func (*StmBlockScanner) InitExtractResult ¶ added in v1.0.2
func (bs *StmBlockScanner) InitExtractResult(sourceKey string, operation *types.Op, result *ExtractResult, optType int64)
InitExtractResult optType = 0: 输入输出提取,1: 输入提取,2:输出提取
func (*StmBlockScanner) RescanFailedRecord ¶ added in v1.0.2
func (bs *StmBlockScanner) RescanFailedRecord()
rescanFailedRecord 重扫失败记录
func (*StmBlockScanner) SaveLocalBlock ¶ added in v1.0.2
func (bs *StmBlockScanner) SaveLocalBlock(blockHeader *Block) error
SaveLocalBlock 记录本地新区块
func (*StmBlockScanner) SaveLocalBlockHead ¶ added in v1.0.2
func (bs *StmBlockScanner) SaveLocalBlockHead(blockHeight uint32, blockHash string) error
SaveLocalBlockHead 记录区块高度和hash到本地
func (*StmBlockScanner) SaveUnscanRecord ¶ added in v1.0.2
func (bs *StmBlockScanner) SaveUnscanRecord(record *UnscanRecord) error
SaveUnscanRecord 保存交易记录到钱包数据库
func (*StmBlockScanner) ScanBlock ¶ added in v1.0.2
func (bs *StmBlockScanner) ScanBlock(height uint64) error
ScanBlock 扫描指定高度区块
func (*StmBlockScanner) ScanBlockTask ¶ added in v1.0.2
func (bs *StmBlockScanner) ScanBlockTask()
ScanBlockTask scan block task
func (*StmBlockScanner) SetRescanBlockHeight ¶ added in v1.0.2
func (bs *StmBlockScanner) SetRescanBlockHeight(height uint64) error
SetRescanBlockHeight 重置区块链扫描高度
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 UnscanRecord ¶
type UnscanRecord struct { ID string `storm:"id"` // primary key BlockHeight uint64 TxID string Reason string }
UnscanRecord 扫描失败的区块及交易
func NewUnscanRecord ¶
func NewUnscanRecord(height uint64, txID, reason string) *UnscanRecord
NewUnscanRecord new UnscanRecord
type WalletClient ¶
type WalletClient struct {
WalletAPI, ServerAPI string
Debug bool
// contains filtered or unexported fields
}
WalletClient is a Bitshares RPC client. It performs RPCs over HTTP using JSON request and responses. A Client must be configured with a secret token to authenticate with other Cores on the network.
func NewWalletClient ¶
func NewWalletClient(serverAPI, walletAPI string, debug bool) *WalletClient
NewWalletClient init a rpc client
func (*WalletClient) BroadcastTransaction ¶
func (c *WalletClient) BroadcastTransaction(tx interface{}) (*BroadcastResponse, error)
BroadcastTransaction broadcast a transaction
func (*WalletClient) GetAccountID ¶
func (c *WalletClient) GetAccountID(name string) (*types.ObjectID, error)
lockup_account_names Returns information about the given account.
func (*WalletClient) GetAccounts ¶
func (c *WalletClient) GetAccounts(names_or_ids ...string) ([]*types.Account, error)
GetAssetsBalance Returns information about the given account.
func (*WalletClient) GetAssetsBalance ¶
func (c *WalletClient) GetAssetsBalance(account types.ObjectID, asset types.ObjectID) (*Balance, error)
GetAssetsBalance Returns information about the given account.
func (*WalletClient) GetBlockByHeight ¶
func (c *WalletClient) GetBlockByHeight(height uint32) (*Block, error)
GetBlockByHeight returns a certain block
func (*WalletClient) GetBlockchainInfo ¶
func (c *WalletClient) GetBlockchainInfo() (*BlockchainInfo, error)
GetBlockchainInfo returns current blockchain data
func (*WalletClient) GetRequiredFee ¶
func (c *WalletClient) GetRequiredFee(ops []bt.Operation, assetID string) ([]bt.AssetAmount, error)
func (*WalletClient) GetTransaction ¶
func (c *WalletClient) GetTransaction(height uint32, trxInBlock int) (*types.Transaction, error)
GetTransaction returns the TX
func (*WalletClient) GetTransactionHex ¶ added in v1.0.2
func (c *WalletClient) GetTransactionHex(rawTx interface{}) ([]byte, error)
func (*WalletClient) GetTransactionID ¶
func (c *WalletClient) GetTransactionID(tx *types.Transaction) (string, error)
GetTransactionID return the TX ID
type WalletConfig ¶
type WalletConfig struct { //币种 Symbol string //区块链数据文件 BlockchainFile string //钱包服务API ServerAPI string ServerWS string WalletAPI string //默认配置内容 DefaultConfig string //曲线类型 CurveType uint32 //数据目录 DataDir string MemoPrivateKey string ChainId string // 链id IsTestNet bool //是否测试网 // contains filtered or unexported fields }
func NewConfig ¶
func NewConfig(symbol string) *WalletConfig
type WalletManager ¶
type WalletManager struct { openwallet.AssetsAdapterBase Api *WalletClient // 节点客户端 Config *WalletConfig // 节点配置 Decoder openwallet.AddressDecoder //地址编码器 DecoderV2 openwallet.AddressDecoderV2 //地址编码器V2 TxDecoder openwallet.TransactionDecoder //交易单编码器 Log *log.OWLogger //日志工具 ContractDecoder openwallet.SmartContractDecoder //智能合约解析器 Blockscanner *StmBlockScanner //区块扫描器 CacheManager openwallet.ICacheManager //缓存管理器 WebsocketAPI string //steem WebsocketAPI ChainId string }
func NewWalletManager ¶
func NewWalletManager(cacheManager openwallet.ICacheManager) *WalletManager
func (*WalletManager) BalanceModelType ¶
func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
BalanceModelType 余额模型类型
func (*WalletManager) DeleteUnscanRecordNotFindTX ¶
func (wm *WalletManager) DeleteUnscanRecordNotFindTX() error
DeleteUnscanRecordNotFindTX 删除未没有找到交易记录的重扫记录
func (*WalletManager) GetAddressDecode ¶
func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
GetAddressDecode 地址解析器
func (*WalletManager) GetAssetsLogger ¶
func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
GetAssetsLogger 获取资产账户日志工具
func (*WalletManager) GetBlockScanner ¶
func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
GetBlockScanner 获取区块链
func (*WalletManager) GetSmartContractDecoder ¶
func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
GetSmartContractDecoder 获取智能合约解析器
func (*WalletManager) GetTransactionDecoder ¶
func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
GetTransactionDecoder 交易单解析器
func (*WalletManager) GetUnscanRecords ¶
func (wm *WalletManager) GetUnscanRecords() ([]*UnscanRecord, error)
获取未扫记录
func (*WalletManager) InitAssetsConfig ¶
func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
InitAssetsConfig 初始化默认配置
func (*WalletManager) LoadAssetsConfig ¶
func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
LoadAssetsConfig 加载外部配置