pizzachain

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2020 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurveType = owcrypt.ECC_CURVE_SECP256K1
)

Variables

View Source
var (
	//币种
	Symbol         = "PIZ"
	FeeAccountName = "token.piz"
	FeeDecimal     = uint8(4)
	FixFee         = decimal.New(2, 0)
	FeeAsset       = eos.Asset{
		Amount: eos.Int64(20000),
		Symbol: eos.Symbol{Precision: FeeDecimal, Symbol: Symbol},
	}
)

Functions

func NewAddressDecoder

func NewAddressDecoder(wm *WalletManager) *addressDecoder

NewAddressDecoder 地址解析器

func NewTransfer

func NewTransfer(from, to eos.AccountName, quantity eos.Asset, memo string, fee eos.Asset) *eos.Action

func ParseHeader

func ParseHeader(b *eos.BlockResp) *openwallet.BlockHeader

ParseHeader 区块链头

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

func ParseBlock

func ParseBlock(b *eos.BlockResp) *Block

ParseBlock 区块

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

type Client struct {
	BaseURL string
	Debug   bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, debug bool) *Client

func (*Client) SendRPCRequest

func (c *Client) SendRPCRequest(method string, request interface{}) ([]byte, error)

SendRPCRequest 发起JSON-RPC请求 @optional

func (*Client) SupportJsonRPCEndpoint

func (c *Client) SupportJsonRPCEndpoint() bool

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 ExtractResult

type ExtractResult struct {
	TxID        string
	BlockHash   string
	BlockHeight uint64
	BlockTime   int64
	Success     bool
	// contains filtered or unexported fields
}

ExtractResult extract result

type PIZBlockScanner

type PIZBlockScanner struct {
	*openwallet.BlockScannerBase

	CurrentBlockHeight uint64 //当前区块高度

	IsScanMemPool        bool            //是否扫描交易池
	RescanLastBlockCount uint64          //重扫上N个区块数量
	MonitorActions       map[string]bool //监控的操作
	// contains filtered or unexported fields
}

PIZBlockScanner EOS block scanner

func NewPIZBlockScanner

func NewPIZBlockScanner(wm *WalletManager) *PIZBlockScanner

NewPIZBlockScanner create a block scanner

func (*PIZBlockScanner) BatchExtractTransactions

func (bs *PIZBlockScanner) BatchExtractTransactions(blockHeight uint64, blockHash string, blockTime int64, transactions []eos.TransactionReceipt) error

BatchExtractTransactions 批量提取交易单

func (*PIZBlockScanner) DeleteUnscanRecord

func (bs *PIZBlockScanner) DeleteUnscanRecord(height uint32) error

DeleteUnscanRecord 删除指定高度的未扫记录

func (*PIZBlockScanner) ExtractTransaction

func (bs *PIZBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, transaction eos.TransactionReceipt, scanTargetFunc openwallet.BlockScanTargetFunc) ExtractResult

ExtractTransaction 提取交易单

func (*PIZBlockScanner) GetBalanceByAddress

func (bs *PIZBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)

GetBalanceByAddress 查询地址余额

func (*PIZBlockScanner) GetChainInfo

func (bs *PIZBlockScanner) GetChainInfo() (infoResp *eos.InfoResp, err error)

GetChainInfo GetChainInfo

func (*PIZBlockScanner) GetCurrentBlockHeader

func (bs *PIZBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)

func (*PIZBlockScanner) GetGlobalHeadBlock

func (bs *PIZBlockScanner) GetGlobalHeadBlock() (block *eos.BlockResp, err error)

GetGlobalHeadBlock GetGlobalHeadBlock

func (*PIZBlockScanner) GetGlobalMaxBlockHeight

func (bs *PIZBlockScanner) GetGlobalMaxBlockHeight() uint64

GetGlobalMaxBlockHeight GetGlobalMaxBlockHeight

func (*PIZBlockScanner) GetLocalBlock

func (bs *PIZBlockScanner) GetLocalBlock(height uint32) (*Block, error)

GetLocalBlock 获取本地区块数据

func (*PIZBlockScanner) GetLocalBlockHead

func (bs *PIZBlockScanner) GetLocalBlockHead() (uint32, string, error)

GetLocalBlockHead 获取本地记录的区块高度和hash

func (*PIZBlockScanner) GetScannedBlockHeight

func (bs *PIZBlockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*PIZBlockScanner) GetUnscanRecords

func (bs *PIZBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)

func (*PIZBlockScanner) InitExtractResult

func (bs *PIZBlockScanner) InitExtractResult(sourceKey string, action TransferAction, result *ExtractResult, optType int64)

InitExtractResult optType = 0: 输入输出提取,1: 输入提取,2:输出提取

func (*PIZBlockScanner) RescanFailedRecord

func (bs *PIZBlockScanner) RescanFailedRecord()

rescanFailedRecord 重扫失败记录

func (*PIZBlockScanner) SaveLocalBlock

func (bs *PIZBlockScanner) SaveLocalBlock(blockHeader *Block) error

SaveLocalBlock 记录本地新区块

func (*PIZBlockScanner) SaveLocalBlockHead

func (bs *PIZBlockScanner) SaveLocalBlockHead(blockHeight uint32, blockHash string) error

SaveLocalBlockHead 记录区块高度和hash到本地

func (*PIZBlockScanner) SaveUnscanRecord

func (bs *PIZBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error

SaveUnscanRecord 保存交易记录到钱包数据库

func (*PIZBlockScanner) ScanBlock

func (bs *PIZBlockScanner) ScanBlock(height uint64) error

ScanBlock 扫描指定高度区块

func (*PIZBlockScanner) ScanBlockTask

func (bs *PIZBlockScanner) ScanBlockTask()

ScanBlockTask scan block task

func (*PIZBlockScanner) SetRescanBlockHeight

func (bs *PIZBlockScanner) SetRescanBlockHeight(height uint64) error

SetRescanBlockHeight 重置区块链扫描高度

func (*PIZBlockScanner) SupportBlockchainDAI

func (bs *PIZBlockScanner) SupportBlockchainDAI() bool

SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional

type SaveResult

type SaveResult struct {
	TxID        string
	BlockHeight uint64
	Success     bool
}

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 Transfer

type Transfer struct {
	From     eos.AccountName `json:"from"`
	To       eos.AccountName `json:"to"`
	Fee      eos.Asset       `json:"fee"`
	Quantity eos.Asset       `json:"quantity"`
	Memo     string          `json:"memo"`
}

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"`
	Fee      eos.Asset `json:"fee,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    *PIZBlockScanner                //区块扫描器
	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) CurveType

func (wm *WalletManager) CurveType() uint32

CurveType 曲线类型

func (*WalletManager) Decimal

func (wm *WalletManager) Decimal() int32

Decimal 小数位精度

func (*WalletManager) FullName

func (wm *WalletManager) FullName() string

FullName 币种全名

func (*WalletManager) GetAddressDecode

func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder

GetAddressDecode 地址解析器

func (*WalletManager) GetAddressDecoderV2

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

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 加载外部配置

func (*WalletManager) Symbol

func (wm *WalletManager) Symbol() string

Symbol 币种标识

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL