ontology

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

* Copyright 2018 The openwallet Authors * This file is part of the openwallet library. * * The openwallet library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The openwallet library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details.

Index

Constants

View Source
const (
	RPCServerRest        = 0 //RPC服务,Restful 测试 API
	RPCServerMainnetNode = 1 // RPC服务,主网节点 API
)
View Source
const (
	//币种
	Symbol    = "ONT"
	MasterKey = "Ontology seed"
	CurveType = owcrypt.ECC_CURVE_SECP256R1
)

Variables

This section is empty.

Functions

func NewAddressDecoder

func NewAddressDecoder(wm *WalletManager) *addressDecoder

NewAddressDecoder 地址解析器

Types

type AddrBalance

type AddrBalance struct {
	Address    string
	ONTBalance *big.Int
	ONGBalance *big.Int
	ONGUnbound *big.Int
	// contains filtered or unexported fields
}

type Block

type Block struct {
	Hash             string
	Size             uint64
	Version          byte
	PrevBlockHash    string
	TransactionsRoot string
	BlockRoot        string
	Timestamp        uint64
	Height           uint64
	ConsensusData    string
	ConsensusPayload string
	NextBookkeeper   string
	Bookkeepers      []string
	SigData          []string
	Transactions     []string
}

func NewBlock

func NewBlock(json *gjson.Result) *Block

func (*Block) BlockHeader

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

BlockHeader 区块链头

type ContractDecoder

type ContractDecoder struct {
	// 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 ExtractResult

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

ExtractResult 扫描完成的提取结果

type JsonRpcRequest

type JsonRpcRequest struct {
	Version string        `json:"jsonrpc"`
	Id      string        `json:"id"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
}

type JsonRpcResponse

type JsonRpcResponse struct {
	Id     string          `json:"id"`
	Error  int64           `json:"error"`
	Desc   string          `json:"desc"`
	Result json.RawMessage `json:"result"`
}

type ONTBlockScanner

type ONTBlockScanner struct {
	*openwallet.BlockScannerBase

	CurrentBlockHeight uint64 //当前区块高度

	IsScanMemPool        bool   //是否扫描交易池
	RescanLastBlockCount uint64 //重扫上N个区块数量

	RPCServer int
	// contains filtered or unexported fields
}

ONTBlockScanner ontology的区块链扫描器

func NewONTBlockScanner

func NewONTBlockScanner(wm *WalletManager) *ONTBlockScanner

NewONTBlockScanner 创建区块链扫描器

func (*ONTBlockScanner) BatchExtractTransaction

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

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

func (*ONTBlockScanner) ExtractTransaction

func (bs *ONTBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, txid string, scanAddressFunc openwallet.BlockScanAddressFunc) ExtractResult

ExtractTransaction 提取交易单

func (*ONTBlockScanner) ExtractTransactionData

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

func (*ONTBlockScanner) GetBalanceByAddress

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

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

func (*ONTBlockScanner) GetCurrentBlockHeader

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

GetCurrentBlockHeader 获取当前区块高度

func (*ONTBlockScanner) GetScannedBlockHeader

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

GetScannedBlockHeader 获取当前已扫区块高度

func (*ONTBlockScanner) GetScannedBlockHeight

func (bs *ONTBlockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*ONTBlockScanner) GetSourceKeyByAddress

func (bs *ONTBlockScanner) GetSourceKeyByAddress(address string) (string, bool)

GetSourceKeyByAddress 获取地址对应的数据源标识

func (*ONTBlockScanner) GetTransactionsByAddress

func (bs *ONTBlockScanner) GetTransactionsByAddress(offset, limit int, coin openwallet.Coin, address ...string) ([]*openwallet.TxExtractData, error)

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

func (*ONTBlockScanner) Pause

func (bs *ONTBlockScanner) Pause() error

Pause 暂停扫描

func (*ONTBlockScanner) RescanFailedRecord

func (bs *ONTBlockScanner) RescanFailedRecord()

rescanFailedRecord 重扫失败记录

func (*ONTBlockScanner) Restart

func (bs *ONTBlockScanner) Restart() error

Restart 继续扫描

func (*ONTBlockScanner) Run

func (bs *ONTBlockScanner) Run() error

Run 运行

func (*ONTBlockScanner) SaveUnscanRecord

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

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

func (*ONTBlockScanner) ScanBlock

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

ScanBlock 扫描指定高度区块

func (*ONTBlockScanner) ScanBlockTask

func (bs *ONTBlockScanner) ScanBlockTask()

ScanBlockTask 扫描任务

func (*ONTBlockScanner) ScanTxMemPool

func (bs *ONTBlockScanner) ScanTxMemPool()

ScanTxMemPool 扫描交易内存池

func (*ONTBlockScanner) SetRescanBlockHeight

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

SetRescanBlockHeight 重置区块链扫描高度

func (*ONTBlockScanner) Stop

func (bs *ONTBlockScanner) Stop() error

//Stop 停止扫描

type RpcClient

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

func NewRpcClient

func NewRpcClient(addr string) *RpcClient

type SaveResult

type SaveResult struct {
	TxID        string
	BlockHeight uint64
	Success     bool
}

SaveResult 保存结果

type Transaction

type Transaction struct {
	TxID        string
	Version     byte
	Nonce       uint32
	GasPrice    uint64
	GasLimit    uint64
	Payer       string
	TxType      byte
	Payload     string
	BlockHeight uint64
	BlockHash   string
}

type TransactionDecoder

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

func NewTransactionDecoder

func NewTransactionDecoder(wm *WalletManager) *TransactionDecoder

NewTransactionDecoder 交易单解析器

func (*TransactionDecoder) CreateONTRawTransaction

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

func (*TransactionDecoder) CreateRawTransaction

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

CreateRawTransaction 创建交易单

func (*TransactionDecoder) SignONTRawTransaction

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

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)

func (*TransactionDecoder) VerifyONTRawTransaction

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

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

UnscanRecords 扫描失败的区块及交易

func NewUnscanRecord

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

type WalletConfig

type WalletConfig struct {

	//币种
	Symbol    string
	MasterKey string

	//RPC认证账户名
	RpcUser string
	//RPC认证账户密码
	RpcPassword string
	//证书目录
	CertsDir string

	//rpc证书
	CertFileName string
	//区块链数据文件
	BlockchainFile string
	//是否测试网络
	IsTestNet bool
	// 核心钱包是否只做监听
	CoreWalletWatchOnly bool
	//最大的输入数量
	MaxTxInputs int

	//钱包服务API
	ServerAPI string
	//Restful API
	RestfulServerAPI string
	//Mainnet node API
	MainnetNodeAPI string
	//钱包安装的路径
	NodeInstallPath string
	//钱包数据文件目录
	WalletDataPath string
	//汇总阀值
	Threshold decimal.Decimal
	//汇总地址
	SumAddress string
	//汇总执行间隔时间
	CycleSeconds time.Duration
	//默认配置内容
	DefaultConfig string
	//曲线类型
	CurveType uint32
	//小数位长度
	CoinDecimal decimal.Decimal
	//核心钱包密码,配置有值用于自动解锁钱包
	WalletPassword string
	//后台数据源类型
	RPCServerType int
	//s是否支持隔离验证
	SupportSegWit bool
	//GasLimit
	GasLimit uint64
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(symbol string, masterKey string) *WalletConfig

func (*WalletConfig) InitConfig

func (wc *WalletConfig) InitConfig()

initConfig 初始化配置文件

func (*WalletConfig) PrintConfig

func (wc *WalletConfig) PrintConfig() error

printConfig Print config information

type WalletManager

type WalletManager struct {
	openwallet.AssetsAdapterBase

	Storage         *hdkeystore.HDKeystore        //秘钥存取
	RPCClient       *RpcClient                    // RPC API
	Config          *WalletConfig                 //钱包管理配置
	WalletsInSum    map[string]*openwallet.Wallet //参与汇总的钱包
	Blockscanner    *ONTBlockScanner              //区块扫描器
	Decoder         openwallet.AddressDecoder     //地址编码器
	TxDecoder       openwallet.TransactionDecoder //交易单编码器
	ContractDecoder *ContractDecoder              //智能合约解析器
}

func NewWalletManager

func NewWalletManager() *WalletManager

func (*WalletManager) BackupWalletFlow

func (wm *WalletManager) BackupWalletFlow() error

备份钱包流程

func (*WalletManager) CreateAddressFlow

func (wm *WalletManager) CreateAddressFlow() error

创建地址流程

func (*WalletManager) CreateWalletFlow

func (wm *WalletManager) CreateWalletFlow() error

创建钱包流程

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

AddressDecode 地址解析器

func (*WalletManager) GetAddressWithBalance

func (wm *WalletManager) GetAddressWithBalance(address ...*openwallet.Address) error

GetAddressWithBalance

func (*WalletManager) GetAssetsLogger

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

GetAssetsLogger 获取资产账户日志工具

func (*WalletManager) GetBlock

func (wm *WalletManager) GetBlock(hash string) (*Block, error)

GetBlock 获取区块数据

func (*WalletManager) GetBlockHash

func (wm *WalletManager) GetBlockHash(height uint64) (string, error)

GetBlockHash 根据区块高度获得区块hash

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) (*Transaction, error)

GetTransaction 获取交易单

func (*WalletManager) GetTransactionDecoder

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

TransactionDecoder 交易单解析器

func (*WalletManager) GetTxIDsInMemPool

func (wm *WalletManager) GetTxIDsInMemPool() ([]string, error)

GetTxIDsInMemPool 获取待处理的交易池中的交易单IDs

func (*WalletManager) GetUnscanRecords

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

获取未扫记录

func (*WalletManager) GetWalletInfo

func (wm *WalletManager) GetWalletInfo(walletID string) (*openwallet.Wallet, error)

GetWalletInfo 获取钱包列表

func (*WalletManager) GetWalletList

func (wm *WalletManager) GetWalletList() error

GetWalletList 获取钱包列表

func (*WalletManager) GetWallets

func (wm *WalletManager) GetWallets() ([]*openwallet.Wallet, error)

GetWallets 获取钱包列表

func (*WalletManager) ImportWatchOnlyAddress

func (wm *WalletManager) ImportWatchOnlyAddress(address ...*openwallet.Address) error

ImportWatchOnlyAddress 导入观测地址

func (*WalletManager) InitAssetsConfig

func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)

InitAssetsConfig 初始化默认配置

func (*WalletManager) InitConfigFlow

func (wm *WalletManager) InitConfigFlow() error

初始化配置流程

func (*WalletManager) InitNodeConfigFlow

func (wm *WalletManager) InitNodeConfigFlow() error

InitNodeConfig 初始化节点配置文件

func (*WalletManager) InstallNodeFlow

func (wm *WalletManager) InstallNodeFlow() error

InstallNode 安装节点

func (*WalletManager) LoadAssetsConfig

func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error

LoadAssetsConfig 加载外部配置

func (*WalletManager) RestartNodeFlow

func (wm *WalletManager) RestartNodeFlow() error

RestartNodeFlow 重启节点

func (*WalletManager) RestoreWalletFlow

func (wm *WalletManager) RestoreWalletFlow() error

RestoreWalletFlow 恢复钱包流程

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

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

SendRawTransaction 广播交易

func (*WalletManager) SetConfigFlow

func (wm *WalletManager) SetConfigFlow(subCmd string) error

SetConfigFlow 初始化配置流程

func (*WalletManager) ShowConfig

func (wm *WalletManager) ShowConfig() error

查看配置信息

func (*WalletManager) ShowConfigInfo

func (wm *WalletManager) ShowConfigInfo(subCmd string) error

ShowConfigInfo 查看配置信息

func (*WalletManager) ShowNodeInfo

func (wm *WalletManager) ShowNodeInfo() error

ShowNodeInfo 显示节点信息

func (*WalletManager) StartNodeFlow

func (wm *WalletManager) StartNodeFlow() error

StartNodeFlow 开启节点

func (*WalletManager) StopNodeFlow

func (wm *WalletManager) StopNodeFlow() error

StopNodeFlow 关闭节点

func (*WalletManager) SummaryFollow

func (wm *WalletManager) SummaryFollow() error

SummaryFollow 汇总流程

func (*WalletManager) Symbol

func (wm *WalletManager) Symbol() string

Symbol 币种标识

func (*WalletManager) TransferFlow

func (wm *WalletManager) TransferFlow() error

SendTXFlow 发送交易

Jump to

Keyboard shortcuts

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