Documentation ¶
Index ¶
- Constants
- Variables
- func NewAddressDecoder(wm *WalletManager) *addressDecoder
- func NewTransaction(result *gjson.Result, transactionID string) (*types.Transaction, error)
- func NewWebsocketAPI(api string) bitshares.WebsocketAPI
- func ParseHeader(b *Block) *openwallet.BlockHeader
- type Asset
- type Balance
- type Block
- type BlockHeader
- type BlockchainInfo
- type BroadcastResponse
- type BtsBlockScanner
- func (bs *BtsBlockScanner) BatchExtractTransactions(blockHeight uint64, blockHash string, blockTime int64, ...) error
- func (bs *BtsBlockScanner) DeleteUnscanRecord(height uint32) error
- func (bs *BtsBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, ...) ExtractResult
- func (bs *BtsBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
- func (bs *BtsBlockScanner) GetChainInfo() (infoResp *BlockchainInfo, err error)
- func (bs *BtsBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *BtsBlockScanner) GetGlobalHeadBlock() (block *Block, err error)
- func (bs *BtsBlockScanner) GetGlobalMaxBlockHeight() uint64
- func (bs *BtsBlockScanner) GetLocalBlock(height uint32) (*Block, error)
- func (bs *BtsBlockScanner) GetLocalBlockHead() (uint32, string, error)
- func (bs *BtsBlockScanner) GetScannedBlockHeight() uint64
- func (bs *BtsBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
- func (bs *BtsBlockScanner) InitExtractResult(sourceKey string, operation *types.TransferOperation, result *ExtractResult, ...)
- func (bs *BtsBlockScanner) RescanFailedRecord()
- func (bs *BtsBlockScanner) SaveLocalBlock(blockHeader *Block) error
- func (bs *BtsBlockScanner) SaveLocalBlockHead(blockHeight uint32, blockHash string) error
- func (bs *BtsBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
- func (bs *BtsBlockScanner) ScanBlock(height uint64) error
- func (bs *BtsBlockScanner) ScanBlockTask()
- func (bs *BtsBlockScanner) SetRescanBlockHeight(height uint64) error
- func (bs *BtsBlockScanner) SupportBlockchainDAI() bool
- 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 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 WalletClient
- func (c *WalletClient) BroadcastTransaction(tx *bt.SignedTransaction) (*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) GetObjects(assets ...types.ObjectID) (*gjson.Result, 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) 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) 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) 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
)
const TimeLayout = `2006-01-02T15:04:05`
Variables ¶
var (
//币种
Symbol = "BTS"
)
Functions ¶
func NewAddressDecoder ¶
func NewAddressDecoder(wm *WalletManager) *addressDecoder
NewAddressDecoder 地址解析器
func NewTransaction ¶
func NewWebsocketAPI ¶
func NewWebsocketAPI(api string) bitshares.WebsocketAPI
Types ¶
type Balance ¶
func NewBalance ¶
type Block ¶
type Block struct { Height uint64 BlockID string `json:"block_id"` 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"` Transactions []*types.Transaction `json:"transactions"` TransactionIDs []string `json:"transaction_ids"` }
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 BtsBlockScanner ¶
type BtsBlockScanner struct { *openwallet.BlockScannerBase CurrentBlockHeight uint64 //当前区块高度 IsScanMemPool bool //是否扫描交易池 RescanLastBlockCount uint64 //重扫上N个区块数量 // contains filtered or unexported fields }
BtsBlockScanner BTS block scanner
func NewBlockScanner ¶
func NewBlockScanner(wm *WalletManager) *BtsBlockScanner
NewBlockScanner create a block scanner
func (*BtsBlockScanner) BatchExtractTransactions ¶
func (bs *BtsBlockScanner) BatchExtractTransactions(blockHeight uint64, blockHash string, blockTime int64, transactions []*types.Transaction, txIDs []string) error
BatchExtractTransactions 批量提取交易单
func (*BtsBlockScanner) DeleteUnscanRecord ¶
func (bs *BtsBlockScanner) DeleteUnscanRecord(height uint32) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*BtsBlockScanner) ExtractTransaction ¶
func (bs *BtsBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, transaction *types.Transaction, scanTargetFunc openwallet.BlockScanTargetFunc) ExtractResult
ExtractTransaction 提取交易单
func (*BtsBlockScanner) GetBalanceByAddress ¶
func (bs *BtsBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
GetBalanceByAddress 查询地址余额
func (*BtsBlockScanner) GetChainInfo ¶
func (bs *BtsBlockScanner) GetChainInfo() (infoResp *BlockchainInfo, err error)
GetChainInfo GetChainInfo
func (*BtsBlockScanner) GetCurrentBlockHeader ¶
func (bs *BtsBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
func (*BtsBlockScanner) GetGlobalHeadBlock ¶
func (bs *BtsBlockScanner) GetGlobalHeadBlock() (block *Block, err error)
GetGlobalHeadBlock GetGlobalHeadBlock
func (*BtsBlockScanner) GetGlobalMaxBlockHeight ¶
func (bs *BtsBlockScanner) GetGlobalMaxBlockHeight() uint64
GetGlobalMaxBlockHeight GetGlobalMaxBlockHeight
func (*BtsBlockScanner) GetLocalBlock ¶
func (bs *BtsBlockScanner) GetLocalBlock(height uint32) (*Block, error)
GetLocalBlock 获取本地区块数据
func (*BtsBlockScanner) GetLocalBlockHead ¶
func (bs *BtsBlockScanner) GetLocalBlockHead() (uint32, string, error)
GetLocalBlockHead 获取本地记录的区块高度和hash
func (*BtsBlockScanner) GetScannedBlockHeight ¶
func (bs *BtsBlockScanner) GetScannedBlockHeight() uint64
GetScannedBlockHeight 获取已扫区块高度
func (*BtsBlockScanner) GetUnscanRecords ¶ added in v1.1.0
func (bs *BtsBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
获取未扫记录
func (*BtsBlockScanner) InitExtractResult ¶
func (bs *BtsBlockScanner) InitExtractResult(sourceKey string, operation *types.TransferOperation, result *ExtractResult, optType int64)
InitExtractResult optType = 0: 输入输出提取,1: 输入提取,2:输出提取
func (*BtsBlockScanner) RescanFailedRecord ¶ added in v1.0.8
func (bs *BtsBlockScanner) RescanFailedRecord()
rescanFailedRecord 重扫失败记录
func (*BtsBlockScanner) SaveLocalBlock ¶
func (bs *BtsBlockScanner) SaveLocalBlock(blockHeader *Block) error
SaveLocalBlock 记录本地新区块
func (*BtsBlockScanner) SaveLocalBlockHead ¶
func (bs *BtsBlockScanner) SaveLocalBlockHead(blockHeight uint32, blockHash string) error
SaveLocalBlockHead 记录区块高度和hash到本地
func (*BtsBlockScanner) SaveUnscanRecord ¶
func (bs *BtsBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
SaveUnscanRecord 保存交易记录到钱包数据库
func (*BtsBlockScanner) ScanBlock ¶
func (bs *BtsBlockScanner) ScanBlock(height uint64) error
ScanBlock 扫描指定高度区块
func (*BtsBlockScanner) ScanBlockTask ¶
func (bs *BtsBlockScanner) ScanBlockTask()
ScanBlockTask scan block task
func (*BtsBlockScanner) SetRescanBlockHeight ¶
func (bs *BtsBlockScanner) SetRescanBlockHeight(height uint64) error
SetRescanBlockHeight 重置区块链扫描高度
func (*BtsBlockScanner) SupportBlockchainDAI ¶ added in v1.1.0
func (bs *BtsBlockScanner) SupportBlockchainDAI() bool
SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional
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 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 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 *bt.SignedTransaction) (*BroadcastResponse, error)
BroadcastTransaction broadcast a transaction
func (*WalletClient) GetAccountID ¶
func (c *WalletClient) GetAccountID(name string) (*types.ObjectID, error)
GetAssetsBalance 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) GetObjects ¶
GetObjects return a block by the given block number
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) GetTransactionID ¶
func (c *WalletClient) GetTransactionID(tx *types.Transaction) (string, error)
GetTransactionID return the TX ID
type WalletConfig ¶
type WalletConfig struct { //币种 Symbol string //钱包服务API ServerAPI string ServerWS string WalletAPI string //默认配置内容 DefaultConfig string //曲线类型 CurveType uint32 //数据目录 DataDir string MemoPrivateKey string // 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 *BtsBlockScanner //区块扫描器 CacheManager openwallet.ICacheManager //缓存管理器 WebsocketAPI bitshares.WebsocketAPI //bitshares WebsocketAPI }
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.2.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) 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 加载外部配置