beam

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: GPL-3.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	//币种
	Symbol    = "BEAM"
	CurveType = owcrypt.ECC_CURVE_SECP256K1

	//交易单发送超时时限
	DefaultTxSendingTimeout = 5 * time.Minute
)
View Source
const (
	TxStatusPending     = 0
	TxStatusInProgress  = 1
	TxStatusCanceled    = 2
	TxStatusCompleted   = 3
	TxStatusFailed      = 4
	TxStatusRegistering = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressCreateResult

type AddressCreateResult struct {
	Success bool
	Err     error
	Address string
}

type BEAMBlockScanner

type BEAMBlockScanner struct {
	*openwallet.BlockScannerBase

	CurrentBlockHeight uint64 //当前区块高度

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

BEAMBlockScanner BEAM block scanner

func NewBEAMBlockScanner

func NewBEAMBlockScanner(wm *WalletManager) *BEAMBlockScanner

NewEOSBlockScanner create a block scanner

func (*BEAMBlockScanner) BatchExtractTransaction

func (bs *BEAMBlockScanner) BatchExtractTransaction(blockHeight uint64, blockHash string) error

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

func (*BEAMBlockScanner) ExtractTransaction

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

提取交易单

func (*BEAMBlockScanner) ExtractTransactionData

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

ExtractTransactionData

func (*BEAMBlockScanner) GetBalanceByAddress

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

GetBalanceByAddress 查询地址余额

func (*BEAMBlockScanner) GetBlockByHash

func (bs *BEAMBlockScanner) GetBlockByHash(hash string) (*Block, error)

func (*BEAMBlockScanner) GetBlockByHeight

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

func (*BEAMBlockScanner) GetBlockHeight

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

GetBlockHeight 获取区块链高度

func (*BEAMBlockScanner) GetCurrentBlock

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

GetCurrentBlock 获取当前最新区块

func (*BEAMBlockScanner) GetCurrentBlockHeader

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

GetCurrentBlockHeader 获取当前区块高度

func (*BEAMBlockScanner) GetGlobalMaxBlockHeight

func (bs *BEAMBlockScanner) GetGlobalMaxBlockHeight() uint64

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

func (*BEAMBlockScanner) GetScannedBlockHeader

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

GetScannedBlockHeader 获取当前扫描的区块头

func (*BEAMBlockScanner) GetScannedBlockHeight

func (bs *BEAMBlockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*BEAMBlockScanner) GetTransaction

func (bs *BEAMBlockScanner) GetTransaction(hash string) (*Transaction, error)

GetTransaction

func (*BEAMBlockScanner) InitExtractResult

func (bs *BEAMBlockScanner) InitExtractResult(tx *Transaction, sourceKey string, result *ExtractResult, operate int64)

InitTronExtractResult operate = 0: 输入输出提取,1: 输入提取,2:输出提取

func (*BEAMBlockScanner) RescanFailedRecord

func (bs *BEAMBlockScanner) RescanFailedRecord()

rescanFailedRecord 重扫失败记录

func (*BEAMBlockScanner) SaveUnscanRecord

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

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

func (*BEAMBlockScanner) ScanBlock

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

ScanBlock 扫描指定高度区块

func (*BEAMBlockScanner) ScanBlockTask

func (bs *BEAMBlockScanner) ScanBlockTask()

ScanBlockTask 扫描任务

func (*BEAMBlockScanner) SetRescanBlockHeight

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

SetRescanBlockHeight 重置区块链扫描高度

type Block

type Block struct {
	Chainwork     string
	Hash          string
	Found         bool
	PrevBlockHash string
	Time          int64
	Height        uint64
	// contains filtered or unexported fields
}

func NewBlock

func NewBlock(result *gjson.Result) *Block

func (*Block) BlockHeader

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

BlockHeader 区块链头

type BlockchainInfo

type BlockchainInfo struct {
	Chainwork  string
	Hash       string
	Height     uint64
	LowHorizon uint64
	Timestamp  int64
}

func NewBlockchainInfo

func NewBlockchainInfo(result *gjson.Result) *BlockchainInfo

type Client

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

func NewClient

func NewClient(wm *WalletManager) (*Client, error)

func (*Client) CreateBatchAddress

func (c *Client) CreateBatchAddress(count, workerSize uint64) ([]string, error)

CreateBatchAddress

func (*Client) GetBlockByHeight

func (c *Client) GetBlockByHeight(height uint64) (*Block, error)

GetBlockByHeight

func (*Client) GetTransaction

func (c *Client) GetTransaction(txid string) (*Transaction, error)

GetTransaction

func (*Client) GetTransactionsByHeight

func (c *Client) GetTransactionsByHeight(height uint64) ([]*Transaction, error)

GetTransactionsByHeight

func (*Client) GetWalletAddress

func (c *Client) GetWalletAddress() ([]string, error)

GetWalletAddress

func (*Client) GetWalletBalance

func (c *Client) GetWalletBalance() (*openwallet.Balance, error)

GetWalletBalance

func (*Client) GetWalletStatus added in v1.0.8

func (c *Client) GetWalletStatus() (*WalletStatus, error)

GetWalletStatus 获取钱包当前状态

func (*Client) SummaryToAddress added in v1.0.8

func (c *Client) SummaryToAddress(summaryAddress string) (string, string, string, error)

打币

func (*Client) TransFCoin added in v1.0.8

func (c *Client) TransFCoin(toAddress, toAmount string) (string, error)

打币

func (*Client) ValidateAddress added in v1.0.8

func (c *Client) ValidateAddress(address string) (bool, error)

验证地址

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 result

type Server

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

func NewServer

func NewServer(wm *WalletManager) (*Server, error)

func (*Server) Close

func (server *Server) Close()

Close 关闭监听

func (*Server) GetWalletStatus added in v1.0.8

func (server *Server) GetWalletStatus(ctx *owtp.Context)

func (*Server) Listen

func (server *Server) Listen()

Listen 启动监听

func (*Server) SetConnectHandler

func (server *Server) SetConnectHandler(h func(node *Server, nodeInfo *TrustNodeInfo))

SetConnectHandler 设置托管节点断开连接后的通知

func (*Server) SetDisconnectHandler

func (server *Server) SetDisconnectHandler(h func(node *Server, nodeID string))

SetDisconnectHandler 设置托管节点连接成功的通知

type Transaction

type Transaction struct {
	Comment       string
	CreateTime    int64
	Fee           uint64
	TxID          string
	Value         uint64
	Kernel        string
	Receiver      string
	Sender        string
	Income        bool
	Status        int64
	StatusString  string
	Confirmations uint64
	BlockHeight   uint64
	BlockHash     string
}

func NewTransaction

func NewTransaction(result *gjson.Result) *Transaction

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 TrustNodeInfo

type TrustNodeInfo struct {
	NodeID      string `json:"nodeID"` //@required 节点ID
	NodeName    string `json:"nodeName"`
	ConnectType string `json:"connectType"`
}

type UnscanRecord

type UnscanRecord struct {
	ID          string `storm:"id"` // primary key
	BlockHeight uint64
	TxID        string
	Reason      string
}

UnscanRecords 扫描失败的区块及交易

func NewUnscanRecord

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

type WalletClient

type WalletClient struct {
	WalletAPI, ExplorerAPI 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 NewWalletClient

func NewWalletClient(walletAPI, explorerAPI string, debug bool) *WalletClient

func (*WalletClient) CancelTx

func (c *WalletClient) CancelTx(txid string) (bool, error)

CancelTx 取消交易

func (*WalletClient) CreateAddress

func (c *WalletClient) CreateAddress() (string, error)

CreateAddress

func (*WalletClient) CreateBatchAddress

func (c *WalletClient) CreateBatchAddress(count, workerSize uint64) ([]string, error)

CreateBatchAddress 批量创建地址 @count 连续创建数量 @workerSize 并行线程数。建议20条。

func (*WalletClient) GetAddressList

func (c *WalletClient) GetAddressList() ([]string, error)

GetAddressList

func (*WalletClient) GetBlockByHash

func (c *WalletClient) GetBlockByHash(hash string) (*Block, error)

GetBlockByHash

func (*WalletClient) GetBlockByHeight

func (c *WalletClient) GetBlockByHeight(height uint64) (*Block, error)

GetBlockByHeight

func (*WalletClient) GetBlockByKernel

func (c *WalletClient) GetBlockByKernel(kernel string) (*Block, error)

GetBlockByKernel

func (*WalletClient) GetBlockchainInfo

func (c *WalletClient) GetBlockchainInfo() (*BlockchainInfo, error)

GetBlockchainInfo

func (*WalletClient) GetTransaction

func (c *WalletClient) GetTransaction(txid string) (*Transaction, error)

GetTransaction

func (*WalletClient) GetTransactionsByHeight

func (c *WalletClient) GetTransactionsByHeight(height uint64) ([]*Transaction, error)

GetTransactionsByHeight

func (*WalletClient) GetTransactionsByStatus

func (c *WalletClient) GetTransactionsByStatus(status int) ([]*Transaction, error)

GetTransactionsByStatus

func (*WalletClient) GetWalletStatus

func (c *WalletClient) GetWalletStatus() (*WalletStatus, error)

GetWalletStatus

func (*WalletClient) SendTransaction

func (c *WalletClient) SendTransaction(from, to string, value, fee uint64, comment string) (string, error)

SendTransaction

func (*WalletClient) ValidateAddress added in v1.0.8

func (c *WalletClient) ValidateAddress(address string) (bool, error)

CancelTx 取消交易

type WalletConfig

type WalletConfig struct {

	//币种
	Symbol string

	//区块链数据文件
	BlockchainFile string

	//默认配置内容
	DefaultConfig string
	//曲线类型
	CurveType uint32
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(symbol string) *WalletConfig

type WalletManager

type WalletManager struct {
	openwallet.AssetsAdapterBase

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

func NewWalletManager

func NewWalletManager() *WalletManager

func (*WalletManager) BackupWalletData

func (wm *WalletManager) BackupWalletData() error

BackupWalletData

func (*WalletManager) BalanceModelType

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

BalanceModelType 余额模型类别

func (*WalletManager) ClearExpireTx

func (wm *WalletManager) ClearExpireTx() error

ClearExpireTx

func (WalletManager) CreateLocalWalletAddress

func (wm WalletManager) CreateLocalWalletAddress(count, workerSize uint64) ([]string, error)

func (WalletManager) CreateRemoteWalletAddress

func (wm WalletManager) CreateRemoteWalletAddress(count, workerSize uint64) ([]string, error)

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

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

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

func (WalletManager) GetLocalWalletAddress

func (wm WalletManager) GetLocalWalletAddress() ([]string, error)

func (WalletManager) GetLocalWalletBalance

func (wm WalletManager) GetLocalWalletBalance() (*openwallet.Balance, error)

func (WalletManager) GetRemoteBlockByHeight

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

func (WalletManager) GetRemoteWalletAddress

func (wm WalletManager) GetRemoteWalletAddress() ([]string, error)

func (WalletManager) GetRemoteWalletBalance

func (wm WalletManager) GetRemoteWalletBalance() (*openwallet.Balance, error)

func (*WalletManager) GetSmartContractDecoder

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

GetSmartContractDecoder 获取智能合约解析器

func (*WalletManager) GetTransaction

func (wm *WalletManager) GetTransaction(txid string) (*Transaction, error)

GetTransactionsByHeight

func (*WalletManager) GetTransactionDecoder

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

GetTransactionDecoder 交易单解析器

func (*WalletManager) GetTransactionsByHeight

func (wm *WalletManager) GetTransactionsByHeight(height uint64) ([]*Transaction, error)

GetTransactionsByHeight

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

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

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

func (*WalletManager) SetupLog

func (wm *WalletManager) SetupLog(logDir, logFile string, debug bool)

SetupLog 配置日志

func (*WalletManager) StartSummaryWallet

func (wm *WalletManager) StartSummaryWallet() error

func (*WalletManager) SummaryWalletProcess

func (wm *WalletManager) SummaryWalletProcess(summaryToAddress string) (string, string, string, error)

汇总到目标地址 return txId,summaryAmount,feeAmount,err

func (*WalletManager) SummaryWalletProcessRemote added in v1.0.8

func (wm *WalletManager) SummaryWalletProcessRemote(summaryToAddress string) (string, string, string, error)

汇总 远程调用

func (*WalletManager) SummaryWallets

func (wm *WalletManager) SummaryWallets()

SummaryWallets 执行汇总流程

func (*WalletManager) Symbol

func (wm *WalletManager) Symbol() string

Symbol 币种标识

func (*WalletManager) TransferCoinRemote added in v1.0.8

func (wm *WalletManager) TransferCoinRemote(toAddress, toAmount string) (string, error)

打币 远程调用

func (*WalletManager) ValidateAddress added in v1.0.8

func (wm *WalletManager) ValidateAddress(address string) (bool, error)

验证地址格式

func (*WalletManager) ValidateAddressRemote added in v1.0.8

func (wm *WalletManager) ValidateAddressRemote(address string) (bool, error)

远程验证地址格式

type WalletStatus

type WalletStatus struct {
	CurrentHeight    uint64
	CurrentStateHash string
	PrevStateHash    string
	Available        uint64
	Receiving        uint64
	Sending          uint64
	Maturing         uint64
	Locked           uint64
}

func NewWalletStatus

func NewWalletStatus(result *gjson.Result) *WalletStatus

Jump to

Keyboard shortcuts

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