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
- type Asset
- type Block
- type BlockData
- type ContractDecoder
- type DOut
- type ExtractData
- type ExtractInput
- type ExtractOutput
- type ExtractResult
- type Nil
- type Out
- type OutState
- type Out_O
- type Out_Z
- type PKr
- type RootState
- type SEROBlockScanner
- func (bs *SEROBlockScanner) BatchExtractTransactions(block *BlockData) error
- func (bs *SEROBlockScanner) DeleteUnscanRecord(height uint64) error
- func (bs *SEROBlockScanner) DeleteUnspent(nilKey string) error
- func (bs *SEROBlockScanner) DeleteUnspentByHeight(height uint64) error
- func (bs *SEROBlockScanner) ExtractTransaction(block *BlockData, txid string, scanTargetFunc openwallet.BlockScanTargetFunc) ExtractResult
- func (bs *SEROBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
- func (bs *SEROBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *SEROBlockScanner) GetGlobalMaxBlockHeight() uint64
- func (bs *SEROBlockScanner) GetLocalBlock(height uint64) (*BlockData, error)
- func (bs *SEROBlockScanner) GetLocalBlockHead() (uint64, string)
- func (bs *SEROBlockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *SEROBlockScanner) GetScannedBlockHeight() uint64
- func (bs *SEROBlockScanner) GetUnscanRecords() ([]*UnscanRecord, error)
- func (bs *SEROBlockScanner) RescanFailedRecord()
- func (bs *SEROBlockScanner) SaveLocalBlock(blockHeader *BlockData) error
- func (bs *SEROBlockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error
- func (bs *SEROBlockScanner) SaveUnscanRecord(record *UnscanRecord) error
- func (bs *SEROBlockScanner) SaveUnspent(utxo *Unspent, nilKeys []string) error
- func (bs *SEROBlockScanner) ScanBlock(height uint64) error
- func (bs *SEROBlockScanner) ScanBlockTask()
- func (bs *SEROBlockScanner) SetRescanBlockHeight(height uint64) error
- type SaveResult
- type TDOut
- type Token
- type TransactionDecoder
- 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() (string, string, 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) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- type U256
- type Uint128
- type Uint256
- type Uint512
- type UnscanRecord
- type Unspent
- type WalletConfig
- type WalletManager
- func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
- func (wm *WalletManager) CommitTx(txJSON string) (string, error)
- func (wm *WalletManager) CreateAccount(alias string, key *hdkeystore.HDKey, newAccIndex uint64) (*openwallet.AssetsAccount, error)
- func (wm *WalletManager) CreateAddress(account *openwallet.AssetsAccount, newIndex uint64) (*openwallet.Address, error)
- func (wm WalletManager) CreateFixAddress(account *openwallet.AssetsAccount, rnd []byte, newIndex uint64) (*openwallet.Address, error)
- func (wm *WalletManager) CreateRootAccount(alias string, key *hdkeystore.HDKey) (*openwallet.AssetsAccount, error)
- func (wm *WalletManager) CreateWallet(name, password, keydir string) (*hdkeystore.HDKey, string, error)
- func (wm *WalletManager) CurveType() uint32
- func (wm *WalletManager) DecOut(outs []Out, tkBytes []byte) ([]TDOut, error)
- func (wm *WalletManager) Decimal() int32
- func (wm *WalletManager) EstimateFee(feeRate decimal.Decimal) (decimal.Decimal, decimal.Decimal, error)
- func (wm *WalletManager) FullName() string
- func (wm *WalletManager) GasPrice() (*big.Int, error)
- func (wm *WalletManager) GenTxParam(from, tk string, decimals int32, feesRate decimal.Decimal, usedUTXO []*Unspent, ...) (*gjson.Result, error)
- func (wm *WalletManager) GetAddressDecoderV2() openwallet.AddressDecoderV2
- func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
- func (wm *WalletManager) GetBlockByNumber(height uint64) (*BlockData, error)
- func (wm *WalletManager) GetBlockHeight() (uint64, error)
- func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
- func (wm *WalletManager) GetBlocksInfo(height uint64) (*Block, error)
- func (wm *WalletManager) GetOut(root string) (*Out, error)
- func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
- func (wm *WalletManager) GetTransactionByHash(txid string) (*gjson.Result, error)
- func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
- func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
- func (wm *WalletManager) ListUnspent(tk string, currency string, offset, limit int) ([]*Unspent, error)
- func (wm *WalletManager) ListUnspentByAddress(address, currency string, offset, limit int) ([]*Unspent, error)
- func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
- func (wm *WalletManager) LocalCurrencyToId(name string) (string, error)
- func (wm *WalletManager) LocalIdToCurrency(id string) (string, error)
- func (wm *WalletManager) LocalPk2Pkr(pk, rnd string) (string, error)
- func (wm *WalletManager) LocalSeed2Sk(seed string) (string, error)
- func (wm *WalletManager) LocalSk2Tk(sk string) (string, error)
- func (wm *WalletManager) LocalTk2Pk(tk string) (string, error)
- func (wm *WalletManager) LockUnspent(root string) error
- func (wm *WalletManager) SignTxWithSk(txJSON string, seed []byte) (*gjson.Result, error)
- func (wm *WalletManager) Symbol() string
- func (wm *WalletManager) UnlockUnspent(currentHeight uint64) error
Constants ¶
const ( //币种 Symbol = "SERO" CurveType = owcrypt.ECC_CURVE_SECP256K1 MaxTxInputs = 200 MinConfirms = uint64(12) )
const (
NilKeyBucket = "nilkey"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockData ¶
type BlockData struct { BlockNumber uint64 `json:"number" storm:"id"` BlockHash string `json:"hash"` ParentHash string `json:"parentHash"` Timestamp uint64 `json:"timestamp"` // contains filtered or unexported fields }
func (*BlockData) BlockHeader ¶
func (b *BlockData) BlockHeader(symbol string) *openwallet.BlockHeader
BlockHeader 区块链头
func (*BlockData) GetOutputInfoByTxID ¶
GetOutputInfoByTxID 根据txid查找blockinfo的output
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)
type ExtractData ¶
type ExtractData map[string]*openwallet.TxExtractData
type ExtractInput ¶
type ExtractInput map[string][]*openwallet.TxInput
type ExtractOutput ¶
type ExtractOutput map[string][]*openwallet.TxOutPut
type ExtractResult ¶
type ExtractResult struct { TxID string BlockHash string BlockHeight uint64 BlockTime int64 Success bool // contains filtered or unexported fields }
ExtractResult extract result
type SEROBlockScanner ¶
type SEROBlockScanner struct { *openwallet.BlockScannerBase CurrentBlockHeight uint64 //当前区块高度 IsScanMemPool bool //是否扫描交易池 RescanLastBlockCount uint64 //重扫上N个区块数量 // contains filtered or unexported fields }
EOSBlockScanner EOS block scanner
func NewSEROBlockScanner ¶
func NewSEROBlockScanner(wm *WalletManager) *SEROBlockScanner
NewSEROBlockScanner create a block scanner
func (*SEROBlockScanner) BatchExtractTransactions ¶
func (bs *SEROBlockScanner) BatchExtractTransactions(block *BlockData) error
BatchExtractTransactions 批量提取交易单
func (*SEROBlockScanner) DeleteUnscanRecord ¶
func (bs *SEROBlockScanner) DeleteUnscanRecord(height uint64) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*SEROBlockScanner) DeleteUnspent ¶
func (bs *SEROBlockScanner) DeleteUnspent(nilKey string) error
DeleteUnspent 删除已使用的未花
func (*SEROBlockScanner) DeleteUnspentByHeight ¶
func (bs *SEROBlockScanner) DeleteUnspentByHeight(height uint64) error
DeleteUnspent 删除已使用的未花
func (*SEROBlockScanner) ExtractTransaction ¶
func (bs *SEROBlockScanner) ExtractTransaction(block *BlockData, txid string, scanTargetFunc openwallet.BlockScanTargetFunc) ExtractResult
ExtractTransaction 提取交易单
func (*SEROBlockScanner) GetBalanceByAddress ¶
func (bs *SEROBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
GetBalanceByAddress 查询地址余额
func (*SEROBlockScanner) GetCurrentBlockHeader ¶
func (bs *SEROBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
func (*SEROBlockScanner) GetGlobalMaxBlockHeight ¶
func (bs *SEROBlockScanner) GetGlobalMaxBlockHeight() uint64
GetGlobalMaxBlockHeight GetGlobalMaxBlockHeight
func (*SEROBlockScanner) GetLocalBlock ¶
func (bs *SEROBlockScanner) GetLocalBlock(height uint64) (*BlockData, error)
GetLocalBlock 获取本地区块数据
func (*SEROBlockScanner) GetLocalBlockHead ¶
func (bs *SEROBlockScanner) GetLocalBlockHead() (uint64, string)
GetLocalBlockHead 获取本地记录的区块高度和hash
func (*SEROBlockScanner) GetScannedBlockHeader ¶
func (bs *SEROBlockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)
GetScannedBlockHeader 获取当前扫描的区块头
func (*SEROBlockScanner) GetScannedBlockHeight ¶
func (bs *SEROBlockScanner) GetScannedBlockHeight() uint64
GetScannedBlockHeight 获取已扫区块高度
func (*SEROBlockScanner) GetUnscanRecords ¶ added in v1.0.8
func (bs *SEROBlockScanner) GetUnscanRecords() ([]*UnscanRecord, error)
获取未扫记录
func (*SEROBlockScanner) RescanFailedRecord ¶ added in v1.0.8
func (bs *SEROBlockScanner) RescanFailedRecord()
rescanFailedRecord 重扫失败记录
func (*SEROBlockScanner) SaveLocalBlock ¶
func (bs *SEROBlockScanner) SaveLocalBlock(blockHeader *BlockData) error
SaveLocalBlock 记录本地新区块
func (*SEROBlockScanner) SaveLocalBlockHead ¶
func (bs *SEROBlockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error
SaveLocalBlockHead 记录区块高度和hash到本地
func (*SEROBlockScanner) SaveUnscanRecord ¶
func (bs *SEROBlockScanner) SaveUnscanRecord(record *UnscanRecord) error
SaveUnscanRecord 保存交易记录到钱包数据库
func (*SEROBlockScanner) SaveUnspent ¶
func (bs *SEROBlockScanner) SaveUnspent(utxo *Unspent, nilKeys []string) error
SaveUnspent 记录新的未花
func (*SEROBlockScanner) ScanBlock ¶
func (bs *SEROBlockScanner) ScanBlock(height uint64) error
ScanBlock 扫描指定高度区块
func (*SEROBlockScanner) ScanBlockTask ¶
func (bs *SEROBlockScanner) ScanBlockTask()
ScanBlockTask scan block task
func (*SEROBlockScanner) SetRescanBlockHeight ¶
func (bs *SEROBlockScanner) SetRescanBlockHeight(height uint64) error
SetRescanBlockHeight 重置区块链扫描高度
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) 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 ¶ added in v1.0.4
func (decoder *TransactionDecoder) GetRawTransactionFeeRate() (string, string, 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 TxID string Reason string }
UnscanRecord 扫描失败的区块及交易
func NewUnscanRecord ¶
func NewUnscanRecord(height uint64, txID, reason string) *UnscanRecord
NewUnscanRecord new UnscanRecord
type Unspent ¶
type Unspent struct { Root string `json:"root" storm:"id"` Height uint64 `json:"height" storm:"index"` Currency string `json:"currency"` Value string `json:"value"` Address string `json:"address" storm:"index"` TK string `json:"tk" storm:"index"` Sending bool `json:"sending"` }
Unspent 未花记录
type WalletConfig ¶
type WalletConfig struct { //币种 Symbol string //区块链数据文件 BlockchainFile string //钱包服务API ServerAPI string //默认配置内容 DefaultConfig string //曲线类型 CurveType uint32 //链ID ChainID string //固定汽油 FixGas int64 //数据目录 DataDir string // contains filtered or unexported fields }
func NewConfig ¶
func NewConfig(symbol string) *WalletConfig
type WalletManager ¶
type WalletManager struct { openwallet.AssetsAdapterBase Config *WalletConfig // 节点配置 Decoder *sero_addrdec.AddressDecoderV2 //地址编码器 TxDecoder openwallet.TransactionDecoder //交易单编码器 Log *log.OWLogger //日志工具 ContractDecoder openwallet.SmartContractDecoder //智能合约解析器 Blockscanner *SEROBlockScanner //区块扫描器 WalletClient *client.Client // 节点客户端 // contains filtered or unexported fields }
func NewWalletManager ¶
func NewWalletManager() *WalletManager
func (*WalletManager) BalanceModelType ¶
func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
BalanceModelType 余额模型类别
func (*WalletManager) CommitTx ¶
func (wm *WalletManager) CommitTx(txJSON string) (string, error)
CommitTx 广播交易
func (*WalletManager) CreateAccount ¶
func (wm *WalletManager) CreateAccount(alias string, key *hdkeystore.HDKey, newAccIndex uint64) (*openwallet.AssetsAccount, error)
创建账户 CreateAccount
func (*WalletManager) CreateAddress ¶
func (wm *WalletManager) CreateAddress(account *openwallet.AssetsAccount, newIndex uint64) (*openwallet.Address, error)
func (WalletManager) CreateFixAddress ¶ added in v1.0.12
func (wm WalletManager) CreateFixAddress(account *openwallet.AssetsAccount, rnd []byte, newIndex uint64) (*openwallet.Address, error)
func (*WalletManager) CreateRootAccount ¶ added in v1.0.12
func (wm *WalletManager) CreateRootAccount(alias string, key *hdkeystore.HDKey) (*openwallet.AssetsAccount, error)
创建账户 CreateRootAccount
func (*WalletManager) CreateWallet ¶
func (wm *WalletManager) CreateWallet(name, password, keydir string) (*hdkeystore.HDKey, string, error)
创建钱包 CreateWallet
func (*WalletManager) DecOut ¶
func (wm *WalletManager) DecOut(outs []Out, tkBytes []byte) ([]TDOut, error)
func (*WalletManager) EstimateFee ¶
func (wm *WalletManager) EstimateFee(feeRate decimal.Decimal) (decimal.Decimal, decimal.Decimal, error)
EstimateFee 预估手续费
func (*WalletManager) GenTxParam ¶
func (wm *WalletManager) GenTxParam( from, tk string, decimals int32, feesRate decimal.Decimal, usedUTXO []*Unspent, to []Out_O) (*gjson.Result, error)
GenTxParam 构建交易
func (*WalletManager) GetAddressDecoderV2 ¶
func (wm *WalletManager) GetAddressDecoderV2() openwallet.AddressDecoderV2
GetAddressDecode 地址解析器
func (*WalletManager) GetAssetsLogger ¶
func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
GetAssetsLogger 获取资产账户日志工具
func (*WalletManager) GetBlockByNumber ¶
func (wm *WalletManager) GetBlockByNumber(height uint64) (*BlockData, error)
func (*WalletManager) GetBlockHeight ¶
func (wm *WalletManager) GetBlockHeight() (uint64, error)
GetBlockHeight 获取区块链高度
func (*WalletManager) GetBlockScanner ¶
func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
GetBlockScanner 获取区块链
func (*WalletManager) GetBlocksInfo ¶
func (wm *WalletManager) GetBlocksInfo(height uint64) (*Block, error)
func (*WalletManager) GetSmartContractDecoder ¶
func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
GetSmartContractDecoder 获取智能合约解析器
func (*WalletManager) GetTransactionByHash ¶
func (wm *WalletManager) GetTransactionByHash(txid string) (*gjson.Result, error)
func (*WalletManager) GetTransactionDecoder ¶
func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
GetTransactionDecoder 交易单解析器
func (*WalletManager) InitAssetsConfig ¶
func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
InitAssetsConfig 初始化默认配置
func (*WalletManager) ListUnspent ¶
func (wm *WalletManager) ListUnspent(tk string, currency string, offset, limit int) ([]*Unspent, error)
ListUnspent 未花记录
func (*WalletManager) ListUnspentByAddress ¶
func (wm *WalletManager) ListUnspentByAddress(address, currency string, offset, limit int) ([]*Unspent, error)
ListUnspentByAddress 未花记录
func (*WalletManager) LoadAssetsConfig ¶
func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
LoadAssetsConfig 加载外部配置
func (*WalletManager) LocalCurrencyToId ¶
func (wm *WalletManager) LocalCurrencyToId(name string) (string, error)
func (*WalletManager) LocalIdToCurrency ¶
func (wm *WalletManager) LocalIdToCurrency(id string) (string, error)
func (*WalletManager) LocalPk2Pkr ¶
func (wm *WalletManager) LocalPk2Pkr(pk, rnd string) (string, error)
func (*WalletManager) LocalSeed2Sk ¶
func (wm *WalletManager) LocalSeed2Sk(seed string) (string, error)
func (*WalletManager) LocalSk2Tk ¶
func (wm *WalletManager) LocalSk2Tk(sk string) (string, error)
func (*WalletManager) LocalTk2Pk ¶
func (wm *WalletManager) LocalTk2Pk(tk string) (string, error)
func (*WalletManager) LockUnspent ¶
func (wm *WalletManager) LockUnspent(root string) error
LockUnspent 锁定发送中utxo
func (*WalletManager) SignTxWithSk ¶
SignTxWithSk 签名交易
func (*WalletManager) UnlockUnspent ¶ added in v1.0.7
func (wm *WalletManager) UnlockUnspent(currentHeight uint64) error
UnlockUnspent 解锁已超时发送的未花记录