velas

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

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
	Merkleroot        string
	Previousblockhash string
	Height            uint64 `storm:"id"`
	Version           uint64
	Time              uint64
	Fork              bool
	// contains filtered or unexported fields
}

func (*Block) BlockHeader

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

BlockHeader 区块链头

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

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

CreateVLXRawTransaction 创建交易单

func (*TransactionDecoder) CreateVLXSummaryRawTransaction

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

CreateVLXSummaryRawTransaction 创建BTC汇总交易

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

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

SignVLXRawTransaction 签名交易单

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 验证交易单,验证交易单并返回加入签名后的交易单

func (*TransactionDecoder) VerifyVLXRawTransaction

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

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

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 VLXBlockScanner

type VLXBlockScanner struct {
	*openwallet.BlockScannerBase

	CurrentBlockHeight uint64 //当前区块高度

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

VLXBlockScanner VLXcoin的区块链扫描器

func NewVLXBlockScanner

func NewVLXBlockScanner(wm *WalletManager) *VLXBlockScanner

NewVLXBlockScanner 创建区块链扫描器

func (*VLXBlockScanner) BatchExtractTransaction

func (bs *VLXBlockScanner) BatchExtractTransaction(blockHeight uint32, blockHash string, timestamp uint32, txs []*crypto.Tx) error

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

func (*VLXBlockScanner) ExtractTransaction

func (bs *VLXBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, timestamp uint32, trx *crypto.Tx, scanAddressFunc openwallet.BlockScanAddressFunc) ExtractResult

ExtractTransaction 提取交易单

func (*VLXBlockScanner) ExtractTransactionData

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

func (*VLXBlockScanner) GetBalanceByAddress

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

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

func (*VLXBlockScanner) GetCurrentBlockHeader

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

GetCurrentBlockHeader 获取当前区块高度

func (*VLXBlockScanner) GetGlobalMaxBlockHeight

func (bs *VLXBlockScanner) GetGlobalMaxBlockHeight() uint64

func (*VLXBlockScanner) GetScannedBlockHeader

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

GetScannedBlockHeader 获取当前扫描的区块头

func (*VLXBlockScanner) GetScannedBlockHeight

func (bs *VLXBlockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*VLXBlockScanner) RescanFailedRecord

func (bs *VLXBlockScanner) RescanFailedRecord()

rescanFailedRecord 重扫失败记录

func (*VLXBlockScanner) SaveUnscanRecord

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

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

func (*VLXBlockScanner) ScanBlock

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

ScanBlock 扫描指定高度区块

func (*VLXBlockScanner) ScanBlockTask

func (bs *VLXBlockScanner) ScanBlockTask()

ScanBlockTask 扫描任务

func (*VLXBlockScanner) SetRescanBlockHeight

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

SetRescanBlockHeight 重置区块链扫描高度

type WalletConfig

type WalletConfig struct {

	//币种
	Symbol string

	//区块链数据文件
	BlockchainFile string

	//钱包服务API
	ServerAPI string
	//默认配置内容
	DefaultConfig string
	//曲线类型
	CurveType uint32
	//是否测试网
	IsTestNet bool
	//最大的输入数量
	MaxTxInputs int
	//数据目录
	DataDir string
	//固定手续费
	FixFees string
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(symbol string) *WalletConfig

type WalletManager

type WalletManager struct {
	openwallet.AssetsAdapterBase

	WalletClient *rpc.Client                   // 节点客户端
	Config       *WalletConfig                 //钱包管理配置
	Blockscanner *VLXBlockScanner              //区块扫描器
	Decoder      *AddressDecoder               //地址编码器
	TxDecoder    openwallet.TransactionDecoder //交易单编码器
	Log          *log.OWLogger                 //日志工具
}

func NewWalletManager

func NewWalletManager() *WalletManager

func (*WalletManager) CurveType

func (wm *WalletManager) CurveType() uint32

CurveType 曲线类型

func (*WalletManager) Decimal

func (wm *WalletManager) Decimal() int32

小数位精度

func (*WalletManager) DeleteUnscanRecord

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

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

func (*WalletManager) FullName

func (wm *WalletManager) FullName() string

FullName 币种全名

func (*WalletManager) GetAddressDecode

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

AddressDecode 地址解析器

func (*WalletManager) GetAssetsLogger

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

GetAssetsLogger 获取资产账户日志工具

func (*WalletManager) GetBlock

func (wm *WalletManager) GetBlock(height uint64) (*rpc.BlockResponse, error)

GetBlock 获取区块数据

func (*WalletManager) GetBlockByHash

func (wm *WalletManager) GetBlockByHash(hash string) (*rpc.BlockResponse, error)

GetBlockByHash 获取区块数据

func (*WalletManager) GetBlockHeight

func (wm *WalletManager) GetBlockHeight() (uint64, error)

GetBlockHeight 获取区块链高度

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

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

GetSmartContractDecoder 获取智能合约解析器

func (*WalletManager) GetTransaction

func (wm *WalletManager) GetTransaction(txid string) (*rpc.TxResponse, error)

GetTransaction 获取交易单

func (*WalletManager) GetTransactionDecoder

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

TransactionDecoder 交易单解析器

func (*WalletManager) GetUnscanRecords

func (wm *WalletManager) GetUnscanRecords() ([]*UnscanRecord, error)

GetUnscanRecords 获取未扫记录

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