metaverse

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//币种
	Symbol    = "ETP"
	CurveType = owcrypt.ECC_CURVE_SECP256K1
	Decimals  = int32(8)
)

Variables

This section is empty.

Functions

func NewAddressDecoder

func NewAddressDecoder(wm *WalletManager) *addressDecoder

NewAddressDecoder 地址解析器

Types

type AssetAttachment

type AssetAttachment struct {
	Quantity string `json:"quantity"`
	Symbol   string `json:"symbol"`
}

type Block

type Block struct {
	Hash              string
	Merkleroot        string
	Previousblockhash string
	Height            uint64
	Version           uint64
	Time              uint64
	Fork              bool
	// contains filtered or unexported fields
}

func (*Block) BlockHeader

func (b *Block) BlockHeader(symbol string) *openwallet.BlockHeader

BlockHeader 区块链头

type Client

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

A Client is a Bitcoin 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 NewClient

func NewClient(url string, debug bool) *Client

func (*Client) Call

func (c *Client) Call(path string, request []interface{}) (*gjson.Result, *openwallet.Error)

Call calls a remote procedure on another node, specified by the path.

type ClientInterface

type ClientInterface interface {
	Call(path string, request []interface{}) (*gjson.Result, error)
}

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)

type ETPBalance

type ETPBalance struct {
	Address   string
	Available string
	Confirmed string
	Frozen    string
	Received  string
	Unspent   string
}

func NewETPBalance

func NewETPBalance(json *gjson.Result) *ETPBalance

type ETPBlockScanner

type ETPBlockScanner struct {
	*openwallet.BlockScannerBase

	CurrentBlockHeight uint64 //当前区块高度

	IsScanMemPool        bool   //是否扫描交易池
	RescanLastBlockCount uint64 //重扫上N个区块数量
	// contains filtered or unexported fields
}

ETPBlockScanner

func NewETPBlockScanner

func NewETPBlockScanner(wm *WalletManager) *ETPBlockScanner

NewETPBlockScanner 创建区块链扫描器

func (*ETPBlockScanner) BatchExtractTransaction

func (bs *ETPBlockScanner) BatchExtractTransaction(blockHeight uint64, blockHash string, txs []*Transaction) error

BatchExtractTransaction 批量提取交易单 bitcoin 1M的区块链可以容纳3000笔交易,批量多线程处理,速度更快

func (*ETPBlockScanner) DeleteUnscanRecord

func (bs *ETPBlockScanner) DeleteUnscanRecord(height uint64) error

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

func (*ETPBlockScanner) ExtractTransaction

func (bs *ETPBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, trx *Transaction, scanTargetFunc openwallet.BlockScanTargetFuncV2) ExtractResult

ExtractTransaction 提取交易单

func (*ETPBlockScanner) ExtractTransactionData

func (bs *ETPBlockScanner) ExtractTransactionData(txid string, scanTargetFunc openwallet.BlockScanTargetFunc) (map[string][]*openwallet.TxExtractData, error)

func (*ETPBlockScanner) GetBalanceByAddress

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

GetAssetsAccountBalanceByAddress 查询账户相关地址的交易记录

func (*ETPBlockScanner) GetCurrentBlockHeader

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

GetCurrentBlockHeader 获取当前区块高度

func (*ETPBlockScanner) GetGlobalMaxBlockHeight

func (bs *ETPBlockScanner) GetGlobalMaxBlockHeight() uint64

func (*ETPBlockScanner) GetLocalBlock

func (bs *ETPBlockScanner) GetLocalBlock(height uint64) (*Block, error)

GetLocalBlock 获取本地区块数据

func (*ETPBlockScanner) GetLocalBlockHead

func (bs *ETPBlockScanner) GetLocalBlockHead() (uint64, string, error)

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

func (*ETPBlockScanner) GetScannedBlockHeader added in v1.0.3

func (bs *ETPBlockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)

GetScannedBlockHeader 获取当前扫描的区块头

func (*ETPBlockScanner) GetScannedBlockHeight

func (bs *ETPBlockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*ETPBlockScanner) GetUnscanRecords

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

func (*ETPBlockScanner) RescanFailedRecord

func (bs *ETPBlockScanner) RescanFailedRecord()

rescanFailedRecord 重扫失败记录

func (*ETPBlockScanner) SaveLocalBlock

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

SaveLocalBlock 记录本地新区块

func (*ETPBlockScanner) SaveLocalBlockHead

func (bs *ETPBlockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error

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

func (*ETPBlockScanner) SaveUnscanRecord

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

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

func (*ETPBlockScanner) ScanBlock

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

ScanBlock 扫描指定高度区块

func (*ETPBlockScanner) ScanBlockTask

func (bs *ETPBlockScanner) ScanBlockTask()

ScanBlockTask 扫描任务

func (*ETPBlockScanner) SetRescanBlockHeight

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

SetRescanBlockHeight 重置区块链扫描高度

func (*ETPBlockScanner) SupportBlockchainDAI

func (bs *ETPBlockScanner) SupportBlockchainDAI() bool

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

type ExtractData

type ExtractData map[string]*openwallet.TxExtractData

type ExtractInput

type ExtractInput map[string][]*openwallet.TxInput

type ExtractOutput

type ExtractOutput map[string][]*openwallet.TxOutPut

type ExtractResult

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

ExtractResult 扫描完成的提取结果

type SaveResult

type SaveResult struct {
	TxID        string
	BlockHeight uint64
	Success     bool
}

SaveResult 保存结果

type TokenBalance

type TokenBalance struct {
	Address        string
	Decimals       int32
	Symbol         string
	Quantity       string
	Status         string
	LockedQuantity string
}

func NewTokenBalance

func NewTokenBalance(json *gjson.Result) *TokenBalance

type Transaction

type Transaction struct {
	TxID        string
	Version     uint64
	LockTime    int64
	BlockHash   string
	BlockHeight uint64
	Blocktime   int64
	IsCoinBase  bool
	Decimals    int32
	RawHex      string

	Vins  []*Vin
	Vouts []*Vout
}

type TransactionDecoder

type TransactionDecoder struct {
	openwallet.TransactionDecoderBase
	// contains filtered or unexported fields
}

func NewTransactionDecoder

func NewTransactionDecoder(wm *WalletManager) *TransactionDecoder

NewTransactionDecoder 交易单解析器

func (*TransactionDecoder) CreateETPRawTransaction

func (decoder *TransactionDecoder) CreateETPRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

CreateRawTransaction 创建交易单

func (*TransactionDecoder) CreateETPSummaryRawTransaction

func (decoder *TransactionDecoder) CreateETPSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)

CreateETPSummaryRawTransaction 创建ETP汇总交易

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) CreateTokenRawTransaction

func (decoder *TransactionDecoder) CreateTokenRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

CreateTokenRawTransaction 创建Token交易单

func (*TransactionDecoder) CreateTokenSummaryRawTransaction

func (decoder *TransactionDecoder) CreateTokenSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)

CreateTokenSummaryRawTransaction 创建Token汇总交易

func (*TransactionDecoder) GetRawTransactionFeeRate

func (decoder *TransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)

GetRawTransactionFeeRate 获取交易单的费率

func (*TransactionDecoder) SignETPRawTransaction

func (decoder *TransactionDecoder) SignETPRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

SignRawTransaction 签名交易单

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)

SendRawTransaction 广播交易单

func (*TransactionDecoder) VerifyETPRawTransaction

func (decoder *TransactionDecoder) VerifyETPRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单

func (*TransactionDecoder) VerifyRawTransaction

func (decoder *TransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单

type Vin

type Vin struct {
	TxID            string
	Vout            uint64
	N               uint64
	Addr            string
	Value           string
	AssetAttachment *AssetAttachment
	IsToken         bool
	LockScript      string
	// contains filtered or unexported fields
}

func NewTxInput

func NewTxInput(json *gjson.Result) *Vin

type Vout

type Vout struct {
	N                 uint64
	Addr              string
	Value             string
	Type              string
	AssetAttachment   *AssetAttachment
	IsToken           bool
	LockedHeightRange int64
	LockScript        string
}

func NewTxOut

func NewTxOut(json *gjson.Result) *Vout

type WalletConfig

type WalletConfig struct {

	//币种
	Symbol string
	//最大的输入数量
	MaxTxInputs int
	//本地数据库文件路径
	DBPath string
	//钱包服务API
	ServerAPI string
	//最低手续费
	MinFees decimal.Decimal
	//数据目录
	DataDir string
	//曲线类型
	CurveType uint32
	//是否测试网
	IsTestNet bool
}

func NewConfig

func NewConfig(symbol string) *WalletConfig

type WalletManager

type WalletManager struct {
	openwallet.AssetsAdapterBase
	WalletClient    *Client                         // 节点客户端
	Config          *WalletConfig                   //钱包管理配置
	Decoder         openwallet.AddressDecoder       //地址编码器
	DecoderV2       openwallet.AddressDecoderV2     //地址编码器
	TxDecoder       openwallet.TransactionDecoder   //交易单编码器
	Log             *log.OWLogger                   //日志工具
	Blockscanner    openwallet.BlockScanner         //区块扫描器
	ContractDecoder openwallet.SmartContractDecoder //智能合约解析器
}

func NewWalletManager

func NewWalletManager() *WalletManager

func (*WalletManager) BalanceModelType

func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType

func (*WalletManager) CreateRawTx

func (wm *WalletManager) CreateRawTx(sender []string, receivers map[string]string, change, fees, symbol string, isToken bool) (string, *openwallet.Error)

CreateRawTx

func (*WalletManager) CurveType

func (wm *WalletManager) CurveType() uint32

CurveType 曲线类型

func (*WalletManager) Decimal

func (wm *WalletManager) Decimal() int32

小数位精度

func (*WalletManager) DecodeRawTx

func (wm *WalletManager) DecodeRawTx(rawHex string) (*Transaction, *openwallet.Error)

DecodeRawTx

func (*WalletManager) FillInputFields

func (wm *WalletManager) FillInputFields(tx *Transaction) *openwallet.Error

FillInputFields

func (*WalletManager) FullName

func (wm *WalletManager) FullName() string

FullName 币种全名

func (*WalletManager) GetAddressAsset

func (wm *WalletManager) GetAddressAsset(address, symbol string) (*TokenBalance, *openwallet.Error)

GetAddressAsset

func (*WalletManager) GetAddressDecode

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

AddressDecode 地址解析器

func (*WalletManager) GetAddressDecoderV2 added in v1.1.0

func (wm *WalletManager) GetAddressDecoderV2() openwallet.AddressDecoderV2

AddressDecode 地址解析器

func (*WalletManager) GetAddressETP

func (wm *WalletManager) GetAddressETP(address string) (*ETPBalance, *openwallet.Error)

GetAddressETP

func (*WalletManager) GetAssetsLogger

func (wm *WalletManager) GetAssetsLogger() *log.OWLogger

GetAssetsLogger 获取资产账户日志工具

func (*WalletManager) GetBlockByHeight

func (wm *WalletManager) GetBlockByHeight(height uint64) (*Block, *openwallet.Error)

GetBlockByHeight 获取区块数据

func (*WalletManager) GetBlockHeader

func (wm *WalletManager) GetBlockHeader(height ...uint64) (*openwallet.BlockHeader, *openwallet.Error)

GetBlockHeight 获取区块链高度

func (*WalletManager) GetBlockScanner

func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner

GetBlockScanner 获取区块链

func (*WalletManager) GetInfo

func (wm *WalletManager) GetInfo() (*gjson.Result, error)

func (*WalletManager) GetSmartContractDecoder

func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder

GetSmartContractDecoder 获取智能合约解析器

func (*WalletManager) GetTransaction

func (wm *WalletManager) GetTransaction(txid string) (*Transaction, *openwallet.Error)

GetTransaction 获取交易单

func (*WalletManager) GetTransactionDecoder

func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder

TransactionDecoder 交易单解析器

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) NewBlock

func (wm *WalletManager) NewBlock(json *gjson.Result) *Block

func (*WalletManager) NewTransaction

func (wm *WalletManager) NewTransaction(json *gjson.Result) *Transaction

func (*WalletManager) SendRawTx

func (wm *WalletManager) SendRawTx(rawHex string) (string, *openwallet.Error)

SendRawTx

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