Documentation ¶
Index ¶
- Constants
- type AddressDecoder
- func (decoder *AddressDecoder) PrivateKeyToWIF(priv []byte, isTestnet bool) (string, error)
- func (decoder *AddressDecoder) PublicKeyToAddress(pub []byte, isTestnet bool) (string, error)
- func (decoder *AddressDecoder) RedeemScriptToAddress(pubs [][]byte, required uint64, isTestnet bool) (string, error)
- func (decoder *AddressDecoder) WIFToPrivateKey(wif string, isTestnet bool) ([]byte, error)
- type Block
- type BlockScanner
- func (bs *BlockScanner) BatchExtractTransactions(blockHeight uint64, blockHash string, blockTime int64) error
- func (bs *BlockScanner) DeleteUnscanRecord(height uint32) error
- func (bs *BlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, trx *rpc.Transaction, ...) ExtractResult
- func (bs *BlockScanner) ExtractTransactionData(txid string, scanTargetFunc openwallet.BlockScanTargetFunc) (map[string][]*openwallet.TxExtractData, error)
- func (bs *BlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
- func (bs *BlockScanner) GetByHeight(height uint32) (block *Block, err error)
- func (bs *BlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *BlockScanner) GetGlobalHeadBlock() (block *Block, err error)
- func (bs *BlockScanner) GetGlobalMaxBlockHeight() uint64
- func (bs *BlockScanner) GetLocalBlock(height uint32) (*Block, error)
- func (bs *BlockScanner) GetLocalBlockHead() (uint32, string, error)
- func (bs *BlockScanner) GetScannedBlockHeight() uint64
- func (bs *BlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
- func (bs *BlockScanner) InitExtractResult(sourceKey string, trx *rpc.Transaction, result *ExtractResult, optType int64)
- func (bs *BlockScanner) RescanFailedRecord()
- func (bs *BlockScanner) SaveLocalBlock(blockHeader *Block) error
- func (bs *BlockScanner) SaveLocalBlockHead(blockHeight uint32, blockHash string) error
- func (bs *BlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
- func (bs *BlockScanner) ScanBlock(height uint64) error
- func (bs *BlockScanner) ScanBlockTask()
- func (bs *BlockScanner) SetRescanBlockHeight(height uint64) error
- func (bs *BlockScanner) SupportBlockchainDAI() bool
- type ContractDecoder
- type ExtractResult
- type SaveResult
- type TransactionDecoder
- func (decoder *TransactionDecoder) CreateNSGRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) CreateNSGSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (decoder *TransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
- func (decoder *TransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (decoder *TransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)
- func (decoder *TransactionDecoder) SignNSGRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
- func (decoder *TransactionDecoder) VerifyNSGRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- type WalletConfig
- type WalletManager
- func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
- func (wm *WalletManager) CurveType() uint32
- func (wm *WalletManager) Decimal() int32
- func (wm *WalletManager) FullName() string
- func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
- func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
- func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
- func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
- func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
- func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
- func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
- func (wm *WalletManager) Symbol() string
Constants ¶
const ( //币种 Symbol = "NSG" 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 ¶
func (*Block) BlockHeader ¶
func (block *Block) BlockHeader(symbol string) (header *openwallet.BlockHeader)
type BlockScanner ¶
type BlockScanner struct { *openwallet.BlockScannerBase CurrentBlockHeight uint64 //当前区块高度 IsScanMemPool bool //是否扫描交易池 RescanLastBlockCount uint64 //重扫上N个区块数量 // contains filtered or unexported fields }
BlockScanner block scanner
func NewBlockScanner ¶
func NewBlockScanner(wm *WalletManager) *BlockScanner
NewBlockScanner create a block scanner
func (*BlockScanner) BatchExtractTransactions ¶
func (bs *BlockScanner) BatchExtractTransactions(blockHeight uint64, blockHash string, blockTime int64) error
BatchExtractTransactions 批量提取交易单
func (*BlockScanner) DeleteUnscanRecord ¶
func (bs *BlockScanner) DeleteUnscanRecord(height uint32) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*BlockScanner) ExtractTransaction ¶
func (bs *BlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, trx *rpc.Transaction, scanTargetFunc openwallet.BlockScanTargetFunc) ExtractResult
ExtractTransaction 提取交易单
func (*BlockScanner) ExtractTransactionData ¶
func (bs *BlockScanner) ExtractTransactionData(txid string, scanTargetFunc openwallet.BlockScanTargetFunc) (map[string][]*openwallet.TxExtractData, error)
ExtractTransactionData 扫描一笔交易
func (*BlockScanner) GetBalanceByAddress ¶
func (bs *BlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
GetBalanceByAddress 查询地址余额
func (*BlockScanner) GetByHeight ¶
func (bs *BlockScanner) GetByHeight(height uint32) (block *Block, err error)
GetByHeight GetByHeight
func (*BlockScanner) GetCurrentBlockHeader ¶
func (bs *BlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
func (*BlockScanner) GetGlobalHeadBlock ¶
func (bs *BlockScanner) GetGlobalHeadBlock() (block *Block, err error)
GetGlobalHeadBlock GetGlobalHeadBlock
func (*BlockScanner) GetGlobalMaxBlockHeight ¶
func (bs *BlockScanner) GetGlobalMaxBlockHeight() uint64
GetGlobalMaxBlockHeight GetGlobalMaxBlockHeight
func (*BlockScanner) GetLocalBlock ¶
func (bs *BlockScanner) GetLocalBlock(height uint32) (*Block, error)
GetLocalBlock 获取本地区块数据
func (*BlockScanner) GetLocalBlockHead ¶
func (bs *BlockScanner) GetLocalBlockHead() (uint32, string, error)
GetLocalBlockHead 获取本地记录的区块高度和hash
func (*BlockScanner) GetScannedBlockHeight ¶
func (bs *BlockScanner) GetScannedBlockHeight() uint64
GetScannedBlockHeight 获取已扫区块高度
func (*BlockScanner) GetUnscanRecords ¶
func (bs *BlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
func (*BlockScanner) InitExtractResult ¶
func (bs *BlockScanner) InitExtractResult(sourceKey string, trx *rpc.Transaction, result *ExtractResult, optType int64)
InitExtractResult optType = 0: 输入输出提取,1: 输入提取,2:输出提取
func (*BlockScanner) RescanFailedRecord ¶
func (bs *BlockScanner) RescanFailedRecord()
rescanFailedRecord 重扫失败记录
func (*BlockScanner) SaveLocalBlock ¶
func (bs *BlockScanner) SaveLocalBlock(blockHeader *Block) error
SaveLocalBlock 记录本地新区块
func (*BlockScanner) SaveLocalBlockHead ¶
func (bs *BlockScanner) SaveLocalBlockHead(blockHeight uint32, blockHash string) error
SaveLocalBlockHead 记录区块高度和hash到本地
func (*BlockScanner) SaveUnscanRecord ¶
func (bs *BlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
SaveUnscanRecord 保存交易记录到钱包数据库
func (*BlockScanner) ScanBlock ¶
func (bs *BlockScanner) ScanBlock(height uint64) error
ScanBlock 扫描指定高度区块
func (*BlockScanner) ScanBlockTask ¶
func (bs *BlockScanner) ScanBlockTask()
ScanBlockTask scan block task
func (*BlockScanner) SetRescanBlockHeight ¶
func (bs *BlockScanner) SetRescanBlockHeight(height uint64) error
SetRescanBlockHeight 重置区块链扫描高度
func (*BlockScanner) SupportBlockchainDAI ¶
func (bs *BlockScanner) SupportBlockchainDAI() bool
SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional
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)
GetTokenBalanceByAddress return the balance by address, queried by rpc
type ExtractResult ¶
type ExtractResult struct { TxID string BlockHash string BlockHeight uint64 BlockTime int64 Success bool // contains filtered or unexported fields }
ExtractResult extract result
type SaveResult ¶
SaveResult result
type TransactionDecoder ¶
type TransactionDecoder struct { openwallet.TransactionDecoderBase // contains filtered or unexported fields }
func NewTransactionDecoder ¶
func NewTransactionDecoder(wm *WalletManager) *TransactionDecoder
NewTransactionDecoder 交易单解析器
func (*TransactionDecoder) CreateNSGRawTransaction ¶
func (decoder *TransactionDecoder) CreateNSGRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
CreateNSGRawTransaction 创建交易单
func (*TransactionDecoder) CreateNSGSummaryRawTransaction ¶
func (decoder *TransactionDecoder) CreateNSGSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateNSGSummaryRawTransaction 创建汇总交易
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) SignNSGRawTransaction ¶
func (decoder *TransactionDecoder) SignNSGRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
SignNSGRawTransaction 签名交易单
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)
SubmitRawTransaction 广播交易单
func (*TransactionDecoder) VerifyNSGRawTransaction ¶
func (decoder *TransactionDecoder) VerifyNSGRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
VerifyNSGRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单
func (*TransactionDecoder) VerifyRawTransaction ¶
func (decoder *TransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单
type WalletConfig ¶
type WalletConfig struct { //币种 Symbol string //区块链数据文件 BlockchainFile string //钱包服务API ServerAPI string //默认配置内容 DefaultConfig string //曲线类型 CurveType uint32 //是否测试网 IsTestNet bool //最大的输入数量 MaxTxInputs int //数据目录 DataDir string //固定手续费 FixFees string //重试次数 RpcRetry int64 // 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 *BlockScanner //区块扫描器 Decoder *AddressDecoder //地址编码器 TxDecoder openwallet.TransactionDecoder //交易单编码器 ContractDecoder openwallet.SmartContractDecoder //智能合约解析器 Log *log.OWLogger //日志工具 }
func NewWalletManager ¶
func NewWalletManager() *WalletManager
func (*WalletManager) BalanceModelType ¶
func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
BalanceModelType 余额模型类型
func (*WalletManager) GetAddressDecode ¶
func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
AddressDecode 地址解析器
func (*WalletManager) GetAssetsLogger ¶
func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
GetAssetsLogger 获取资产账户日志工具
func (*WalletManager) GetBlockScanner ¶
func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
GetBlockScanner 获取区块链
func (*WalletManager) GetSmartContractDecoder ¶
func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
GetSmartContractDecoder 获取智能合约解析器
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 加载外部配置