aeternity

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//币种
	Symbol    = "AE"
	CurveType = owcrypt.ECC_CURVE_ED25519
)

Variables

This section is empty.

Functions

func SignEncodeTx

func SignEncodeTx(txRaw, sigRaw []byte) (string, error)

SignEncodeTx sign and encode a transaction

Types

type AEBlockScanner

type AEBlockScanner struct {
	*openwallet.BlockScannerBase

	CurrentBlockHeight uint64 //当前区块高度

	RescanLastBlockCount uint64 //重扫上N个区块数量
	// contains filtered or unexported fields
}

AEBlockScanner AE block scanner

func NewAEBlockScanner

func NewAEBlockScanner(wm *WalletManager) *AEBlockScanner

NewEOSBlockScanner create a block scanner

func (*AEBlockScanner) BatchExtractTransaction

func (bs *AEBlockScanner) BatchExtractTransaction(block *Block) error

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

func (*AEBlockScanner) ExtractMicroBlock

func (bs *AEBlockScanner) ExtractMicroBlock(block *Block, microBlockID string, scanTargetFunc openwallet.BlockScanTargetFunc) ExtractResult

ExtractMicroBlock

func (*AEBlockScanner) ExtractTransaction

func (bs *AEBlockScanner) ExtractTransaction(block *Block, microBlockID string, trx *models.GenericSignedTx, scanTargetFunc openwallet.BlockScanTargetFunc) (*ExtractTxResult, error)

ExtractTransaction 提取交易单

func (*AEBlockScanner) ExtractTransactionData

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

ExtractTransactionData

func (*AEBlockScanner) GetBalanceByAddress

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

GetBalanceByAddress 查询地址余额

func (*AEBlockScanner) GetBlockByHeight

func (bs *AEBlockScanner) GetBlockByHeight(height uint64) (*Block, error)

func (*AEBlockScanner) GetBlockHeight

func (bs *AEBlockScanner) GetBlockHeight() (uint64, error)

GetBlockHeight 获取区块链高度

func (*AEBlockScanner) GetCurrentBlock

func (bs *AEBlockScanner) GetCurrentBlock() (*Block, error)

GetCurrentBlock 获取当前最新区块

func (*AEBlockScanner) GetCurrentBlockHeader

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

GetCurrentBlockHeader 获取当前区块高度

func (*AEBlockScanner) GetGlobalMaxBlockHeight

func (bs *AEBlockScanner) GetGlobalMaxBlockHeight() uint64

GetGlobalMaxBlockHeight 获取区块链全网最大高度

func (*AEBlockScanner) GetScannedBlockHeader

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

GetScannedBlockHeader 获取当前扫描的区块头

func (*AEBlockScanner) GetScannedBlockHeight

func (bs *AEBlockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*AEBlockScanner) GetTopBlock

func (bs *AEBlockScanner) GetTopBlock() (*models.KeyBlockOrMicroBlockHeader, error)

GetTopBlock 获取顶部区块,可能是micro block 或 key block

func (*AEBlockScanner) GetTransactionsByBlock

func (bs *AEBlockScanner) GetTransactionsByBlock(block *Block) ([]*models.GenericSignedTx, error)

GetTransactionsByBlockHash

func (*AEBlockScanner) GetTransactionsByMicroBlockHash

func (bs *AEBlockScanner) GetTransactionsByMicroBlockHash(hash string) ([]*models.GenericSignedTx, error)

GetTransactionsByMicroBlockHash

func (*AEBlockScanner) GetTransactionsByMicroBlockHash2

func (bs *AEBlockScanner) GetTransactionsByMicroBlockHash2(hash string) ([]*models.GenericSignedTx, error)

GetTransactionsByMicroBlockHash

func (*AEBlockScanner) RescanFailedRecord

func (bs *AEBlockScanner) RescanFailedRecord()

rescanFailedRecord 重扫失败记录

func (*AEBlockScanner) SaveUnscanRecord

func (bs *AEBlockScanner) SaveUnscanRecord(record *UnscanRecord) error

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

func (*AEBlockScanner) ScanBlock

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

ScanBlock 扫描指定高度区块

func (*AEBlockScanner) ScanBlockTask

func (bs *AEBlockScanner) ScanBlockTask()

ScanBlockTask 扫描任务

func (*AEBlockScanner) SetRescanBlockHeight

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

SetRescanBlockHeight 重置区块链扫描高度

type AddrBalance

type AddrBalance struct {
	Address      string
	Balance      *big.Int
	TokenBalance *big.Int
}

type AddressDecoder

type AddressDecoder struct {
	// contains filtered or unexported fields
}

func NewAddressDecoder

func NewAddressDecoder(wm *WalletManager) *AddressDecoder

NewAddressDecoder 地址解析器

func (*AddressDecoder) PrivateKeyToWIF

func (decoder *AddressDecoder) PrivateKeyToWIF(priv []byte, isTestnet bool) (string, error)

PrivateKeyToWIF 私钥转WIF

func (*AddressDecoder) PublicKeyToAddress

func (decoder *AddressDecoder) PublicKeyToAddress(pub []byte, isTestnet bool) (string, error)

PublicKeyToAddress 公钥转地址

func (*AddressDecoder) RedeemScriptToAddress

func (decoder *AddressDecoder) RedeemScriptToAddress(pubs [][]byte, required uint64, isTestnet bool) (string, error)

RedeemScriptToAddress 多重签名赎回脚本转地址

func (*AddressDecoder) WIFToPrivateKey

func (decoder *AddressDecoder) WIFToPrivateKey(wif string, isTestnet bool) ([]byte, error)

WIFToPrivateKey WIF转私钥

type Block

type Block struct {
	Hash              string
	Confirmations     uint64
	Merkleroot        string
	MicroBlocks       []string
	Previousblockhash string
	Height            uint64 `storm:"id"`
	Version           uint64
	Time              uint64
	Fork              bool
}

func NewBlock

func NewBlock(generation *models.Generation) *Block

func (*Block) BlockHeader

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

BlockHeader 区块链头

type Client

type Client struct {
	BaseURL     string
	AccessToken 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, method string, request interface{}) (*gjson.Result, 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 ExtractResult

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

ExtractResult extract result

type ExtractTxResult

type ExtractTxResult struct {
	TxID string
	// contains filtered or unexported fields
}

ExtractResult extract result

type MicroBlock

type MicroBlock struct {
	Hash   string `storm:"id"`
	Height uint64
}

func NewMicroBlock

func NewMicroBlock(height uint64, hash string) *MicroBlock

type Response

type Response struct {
	Code    int         `json:"code,omitempty"`
	Error   interface{} `json:"error,omitempty"`
	Result  interface{} `json:"result,omitempty"`
	Message string      `json:"message,omitempty"`
	Id      string      `json:"id,omitempty"`
}

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
}

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)

SendRawTransaction 广播交易单

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
	MicroBlockID string
	Reason       string
}

UnscanRecords 扫描失败的区块及交易

func NewUnscanRecord

func NewUnscanRecord(height uint64, microBlockID, reason string) *UnscanRecord

type WalletConfig

type WalletConfig struct {

	//币种
	Symbol string

	//区块链数据文件
	BlockchainFile string

	//钱包服务API
	ServerAPI string
	//默认配置内容
	DefaultConfig string
	//曲线类型
	CurveType uint32
	//链ID
	NetworkID string
	//固定手续费
	FixFees string
	//数据目录
	DataDir string
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(symbol string) *WalletConfig

type WalletManager

type WalletManager struct {
	openwallet.AssetsAdapterBase

	Api             *aeternity.Node                 // 节点客户端
	Config          *WalletConfig                   // 节点配置
	Decoder         openwallet.AddressDecoder       //地址编码器
	TxDecoder       openwallet.TransactionDecoder   //交易单编码器
	Log             *log.OWLogger                   //日志工具
	ContractDecoder openwallet.SmartContractDecoder //智能合约解析器
	Blockscanner    *AEBlockScanner                 //区块扫描器
	// contains filtered or unexported fields
}

func NewWalletManager

func NewWalletManager() *WalletManager

func (*WalletManager) BalanceModelType

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

BalanceModelType 余额模型类别

func (*WalletManager) BroadcastTransaction

func (wm *WalletManager) BroadcastTransaction(txHex string) (string, error)

BroadcastTransaction recalculates the transaction hash and sends the transaction to the node.

func (*WalletManager) CurveType

func (wm *WalletManager) CurveType() uint32

CurveType 曲线类型

func (*WalletManager) Decimal

func (wm *WalletManager) Decimal() int32

Decimal 小数位精度

func (*WalletManager) DeleteUnscanRecord

func (wm *WalletManager) DeleteUnscanRecord(height uint64) error

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

func (*WalletManager) DeleteUnscanRecordNotFindTX

func (wm *WalletManager) DeleteUnscanRecordNotFindTX() error

DeleteUnscanRecordNotFindTX 删除未没有找到交易记录的重扫记录

func (*WalletManager) FullName

func (wm *WalletManager) FullName() string

FullName 币种全名

func (*WalletManager) GetAccount

func (wm *WalletManager) GetAccount(address string) (*models.Account, error)

GetAccount

func (*WalletManager) GetAccountPendingTxCount

func (wm *WalletManager) GetAccountPendingTxCount(address string) (uint64, error)

GetAccountPendingTxCount

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

func (wm *WalletManager) GetLocalBlock(height uint64) (*Block, error)

GetLocalBlock 获取本地区块数据

func (*WalletManager) GetLocalMicroBlock

func (wm *WalletManager) GetLocalMicroBlock(hash string) (*MicroBlock, error)

GetLocalMicroBlock 获取本地微区块数据

func (*WalletManager) GetLocalNewBlock

func (wm *WalletManager) GetLocalNewBlock() (uint64, string)

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

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

func (*WalletManager) SaveLocalBlock

func (wm *WalletManager) SaveLocalBlock(block *Block)

SaveLocalBlock 记录本地新区块

func (*WalletManager) SaveLocalMicroBlock

func (wm *WalletManager) SaveLocalMicroBlock(block *MicroBlock)

SaveLocalMicroBlock 记录本地微区块

func (*WalletManager) SaveLocalNewBlock

func (wm *WalletManager) SaveLocalNewBlock(blockHeight uint64, blockHash string)

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

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