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.
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.
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.
* 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
- Variables
- func AppendOxToAddress(addr string) string
- func CustomAddressDecode(address string) string
- func CustomAddressEncode(address string) string
- type AddrBalance
- type AddrBalanceInf
- type Address
- 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 AddressSet
- type BlockHeader
- type BlockScanner
- func (bs *BlockScanner) BatchExtractTransaction(height uint64, txs []*BlockTransaction) error
- func (bs *BlockScanner) DeleteUnscanRecord(height uint64) error
- func (bs *BlockScanner) DeleteUnscanRecordByID(id string) error
- func (bs *BlockScanner) ExtractTransaction(tx *BlockTransaction) ExtractResult
- func (bs *BlockScanner) ExtractTransactionAndReceiptData(txid string, scanTargetFunc openwallet.BlockScanTargetFuncV2) (map[string][]*openwallet.TxExtractData, ...)
- 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) GetBlockchainSyncStatus() (*openwallet.BlockchainSyncStatus, error)
- func (bs *BlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *BlockScanner) GetGlobalMaxBlockHeight() uint64
- func (bs *BlockScanner) GetLocalBlock(height uint64) (*EthBlock, error)
- func (bs *BlockScanner) GetLocalBlockHead() (uint64, string, error)
- func (bs *BlockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *BlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
- func (bs *BlockScanner) RescanFailedRecord()
- func (bs *BlockScanner) SaveLocalBlock(blockHeader *EthBlock) error
- func (bs *BlockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error
- func (bs *BlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
- func (bs *BlockScanner) SaveUnscannedTransaction(blockHeight uint64, reason string) error
- func (bs *BlockScanner) ScanBlock(height uint64) error
- func (bs *BlockScanner) ScanBlockTask()
- func (bs *BlockScanner) SetRescanBlockHeight(height uint64) error
- func (bs *BlockScanner) SupportBlockchainDAI() bool
- func (bs *BlockScanner) UpdateTxByReceipt(tx *BlockTransaction) error
- type BlockTransaction
- type CallMsg
- type CallResult
- type ERC20Token
- type EthBlock
- type EthContractDecoder
- func (decoder *EthContractDecoder) CallSmartContractABI(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) (*openwallet.SmartContractCallResult, *openwallet.Error)
- func (decoder *EthContractDecoder) CreateSmartContractRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) *openwallet.Error
- func (decoder *EthContractDecoder) EncodeRawTransactionCallMsg(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) (*CallMsg, *abi.ABI, *openwallet.Error)
- func (decoder *EthContractDecoder) GetAssetsAccountDefAddress(wrapper openwallet.WalletDAI, accountID string) (*openwallet.Address, *openwallet.Error)
- func (decoder *EthContractDecoder) GetTokenBalanceByAddress(contract openwallet.SmartContract, address ...string) ([]*openwallet.TokenBalance, error)
- func (decoder *EthContractDecoder) GetTokenMetadata(contract string) (*openwallet.SmartContract, error)
- func (decoder *EthContractDecoder) SubmitSmartContractRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) (*openwallet.SmartContractReceipt, *openwallet.Error)
- func (decoder *EthContractDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) error
- type EthEvent
- type EthTransactionDecoder
- func (decoder *EthTransactionDecoder) CreateErc20TokenRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *EthTransactionDecoder) CreateErc20TokenSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (decoder *EthTransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *EthTransactionDecoder) CreateSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction, ...) error
- func (decoder *EthTransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (decoder *EthTransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
- func (decoder *EthTransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (decoder *EthTransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)
- func (decoder *EthTransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *EthTransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
- func (decoder *EthTransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- type ExtractResult
- type NFTContractDecoder
- func (decoder *NFTContractDecoder) GetMetaDataOfNFT(nft *openwallet.NFT) (*openwallet.NFTMetaData, *openwallet.Error)
- func (decoder *NFTContractDecoder) GetNFTBalanceByAddress(nft *openwallet.NFT, owner string) (*openwallet.NFTBalance, *openwallet.Error)
- func (decoder *NFTContractDecoder) GetNFTBalanceByAddressBatch(nft []*openwallet.NFT, owner []string) ([]*openwallet.NFTBalance, *openwallet.Error)
- func (decoder *NFTContractDecoder) GetNFTOwnerByTokenID(nft *openwallet.NFT) (*openwallet.NFTOwner, *openwallet.Error)
- func (decoder *NFTContractDecoder) GetNFTTransfer(event *openwallet.SmartContractEvent) (*openwallet.NFTTransfer, *openwallet.Error)
- type SaveResult
- type TransactionReceipt
- type TransferEvent
- type WalletConfig
- type WalletManager
- func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
- func (wm *WalletManager) CallABI(contractAddr string, abiInstance abi.ABI, abiParam ...string) (map[string]interface{}, *openwallet.Error)
- func (wm *WalletManager) CurveType() uint32
- func (wm *WalletManager) Decimal() int32
- func (wm *WalletManager) DecodeABIResult(abiInstance abi.ABI, method string, dataHex string) (map[string]interface{}, string, error)
- func (wm *WalletManager) DecodeReceiptLogResult(abiInstance abi.ABI, log types.Log) (map[string]interface{}, string, string, error)
- func (wm *WalletManager) ERC20GetAddressBalance(address string, contractAddr string) (*big.Int, error)
- func (wm *WalletManager) EncodeABIParam(abiInstance abi.ABI, abiParam ...string) ([]byte, error)
- func (wm *WalletManager) EthCall(callMsg CallMsg, sign string) (string, error)
- func (wm *WalletManager) FullName() string
- func (wm *WalletManager) GetAddrBalance(address string, sign string) (*big.Int, error)
- func (wm *WalletManager) GetAddressDecoderV2() openwallet.AddressDecoderV2
- func (wm *WalletManager) GetAddressNonce(wrapper openwallet.WalletDAI, address string) uint64
- func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
- func (wm *WalletManager) GetBlockByMoralis(blockNum uint64) (*EthBlock, error)
- func (wm *WalletManager) GetBlockByNum(blockNum uint64, showTransactionSpec bool) (*EthBlock, error)
- func (wm *WalletManager) GetBlockNumber() (uint64, error)
- func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
- func (wm *WalletManager) GetBlockchainSyncStatus() (*openwallet.BlockchainSyncStatus, error)
- func (wm *WalletManager) GetETHBlockByNum(blockNum uint64, showTransactionSpec bool) (*EthBlock, error)
- func (wm *WalletManager) GetGasEstimated(from string, to string, value *big.Int, data []byte) (*big.Int, error)
- func (wm *WalletManager) GetGasPrice() (*big.Int, error)
- func (wm *WalletManager) GetNFTContractDecoder() openwallet.NFTContractDecoder
- func (wm *WalletManager) GetQNBlockWithReceipts(blockNum uint64) (*EthBlock, error)
- func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
- func (wm *WalletManager) GetTransactionByHash(txid string) (*BlockTransaction, error)
- func (wm *WalletManager) GetTransactionCount(addr string) (uint64, error)
- func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
- func (wm *WalletManager) GetTransactionFeeEstimated(from string, to string, value *big.Int, data []byte) (*txFeeInfo, error)
- func (wm *WalletManager) GetTransactionReceipt(transactionId string) (*TransactionReceipt, error)
- func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
- func (wm *WalletManager) IsContract(address string) (bool, error)
- func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
- func (wm *WalletManager) LoadContractInfo(addr string) *openwallet.SmartContract
- func (wm *WalletManager) QNFetchNFTCollectionDetails(contracts []string) (*gjson.Result, error)
- func (wm *WalletManager) RecoverUnscannedTransactions(unscannedTxs []*openwallet.UnscanRecord) ([]*BlockTransaction, error)
- func (wm *WalletManager) SendRawTransaction(signedTx string) (string, error)
- func (wm *WalletManager) SetNetworkChainID() (uint64, error)
- func (wm *WalletManager) SupportsInterface(contractAddr string) string
- func (wm *WalletManager) Symbol() string
- func (wm *WalletManager) UpdateAddressNonce(wrapper openwallet.WalletDAI, address string, nonce uint64)
Constants ¶
const ( Symbol = "QUORUM" CurveType = owcrypt.ECC_CURVE_SECP256K1 )
const ( ERC20_ABI_JSON = `` /* 3885-byte string literal not displayed */ ERC721_ABI_JSON = `` /* 4515-byte string literal not displayed */ ERC1155_ABI_JSON = `` /* 4007-byte string literal not displayed */ )
const ( //BLOCK_CHAIN_BUCKET = "blockchain" //区块链数据集合 //periodOfTask = 5 * time.Second //定时任务执行隔间 MAX_EXTRACTING_SIZE = 20 //并发的扫描线程数 )
Variables ¶
var (
ERC20_ABI, _ = abi.JSON(strings.NewReader(ERC20_ABI_JSON))
ERC721_ABI, _ = abi.JSON(strings.NewReader(ERC721_ABI_JSON))
ERC1155_ABI, _ = abi.JSON(strings.NewReader(ERC1155_ABI_JSON))
)
Functions ¶
func AppendOxToAddress ¶
func CustomAddressDecode ¶ added in v1.1.0
func CustomAddressEncode ¶ added in v1.1.0
Types ¶
type AddrBalance ¶
func (*AddrBalance) GetAddress ¶
func (this *AddrBalance) GetAddress() string
func (*AddrBalance) SetTokenBalance ¶
func (this *AddrBalance) SetTokenBalance(b *big.Int)
func (*AddrBalance) ValidTokenBalance ¶
func (this *AddrBalance) ValidTokenBalance() bool
type AddrBalanceInf ¶
type Address ¶
type Address struct { Address string `json:"address" storm:"id"` Account string `json:"account" storm:"index"` HDPath string `json:"hdpath"` Index int PublicKey string TxCount uint64 CreatedAt time.Time // contains filtered or unexported fields }
func (*Address) CalcHexPrivKey ¶
func (this *Address) CalcHexPrivKey(masterKey *hdkeystore.HDKey) (string, error)
func (*Address) CalcPrivKey ¶
func (this *Address) CalcPrivKey(masterKey *hdkeystore.HDKey) ([]byte, error)
type AddressDecoder ¶
type AddressDecoder struct{}
AddressDecoder 地址解析器
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 AddressSet ¶ added in v1.8.4
func NewAddressSet ¶ added in v1.8.4
func NewAddressSet() *AddressSet
func (*AddressSet) Add ¶ added in v1.8.4
func (s *AddressSet) Add(item string)
func (*AddressSet) Clear ¶ added in v1.8.4
func (s *AddressSet) Clear()
func (*AddressSet) Has ¶ added in v1.8.4
func (s *AddressSet) Has(item string) bool
func (*AddressSet) IsEmpty ¶ added in v1.8.4
func (s *AddressSet) IsEmpty() bool
func (*AddressSet) Len ¶ added in v1.8.4
func (s *AddressSet) Len() int
func (*AddressSet) List ¶ added in v1.8.4
func (s *AddressSet) List() []string
func (*AddressSet) Remove ¶ added in v1.8.4
func (s *AddressSet) Remove(item string)
type BlockHeader ¶
type BlockHeader struct { BlockNumber string `json:"number" storm:"id"` BlockHash string `json:"hash"` GasLimit string `json:"gasLimit"` GasUsed string `json:"gasUsed"` Miner string `json:"miner"` Difficulty string `json:"difficulty"` TotalDifficulty string `json:"totalDifficulty"` PreviousHash string `json:"parentHash"` BlockHeight uint64 //RecoverBlockHeader的时候进行初始化 }
type BlockScanner ¶
type BlockScanner struct { *openwallet.BlockScannerBase CurrentBlockHeight uint64 //当前区块高度 IsScanMemPool bool //是否扫描交易池 RescanLastBlockCount uint64 //重扫上N个区块数量 sync.RWMutex // contains filtered or unexported fields }
func NewBlockScanner ¶
func NewBlockScanner(wm *WalletManager) *BlockScanner
NewBTCBlockScanner 创建区块链扫描器
func (*BlockScanner) BatchExtractTransaction ¶
func (bs *BlockScanner) BatchExtractTransaction(height uint64, txs []*BlockTransaction) error
BatchExtractTransaction 批量提取交易单
func (*BlockScanner) DeleteUnscanRecord ¶
func (bs *BlockScanner) DeleteUnscanRecord(height uint64) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*BlockScanner) DeleteUnscanRecordByID ¶
func (bs *BlockScanner) DeleteUnscanRecordByID(id string) error
DeleteUnscanRecordByID 删除指定的未扫记录
func (*BlockScanner) ExtractTransaction ¶
func (bs *BlockScanner) ExtractTransaction(tx *BlockTransaction) ExtractResult
ExtractTransaction 提取交易单
func (*BlockScanner) ExtractTransactionAndReceiptData ¶
func (bs *BlockScanner) ExtractTransactionAndReceiptData(txid string, scanTargetFunc openwallet.BlockScanTargetFuncV2) (map[string][]*openwallet.TxExtractData, map[string]*openwallet.SmartContractReceipt, error)
ExtractTransactionAndReceiptData 提取交易单及交易回执数据 @required
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) GetBlockchainSyncStatus ¶ added in v1.7.0
func (bs *BlockScanner) GetBlockchainSyncStatus() (*openwallet.BlockchainSyncStatus, error)
GetBlockchainSyncStatus 获取当前区块链同步状态 @optional
func (*BlockScanner) GetCurrentBlockHeader ¶
func (bs *BlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
GetCurrentBlockHeader 获取当前区块高度
func (*BlockScanner) GetGlobalMaxBlockHeight ¶
func (bs *BlockScanner) GetGlobalMaxBlockHeight() uint64
func (*BlockScanner) GetLocalBlock ¶
func (bs *BlockScanner) GetLocalBlock(height uint64) (*EthBlock, error)
GetLocalBlock 获取本地区块数据
func (*BlockScanner) GetLocalBlockHead ¶
func (bs *BlockScanner) GetLocalBlockHead() (uint64, string, error)
GetLocalBlockHead 获取本地记录的区块高度和hash
func (*BlockScanner) GetScannedBlockHeader ¶
func (bs *BlockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)
GetScannedBlockHeader 获取当前已扫区块高度
func (*BlockScanner) GetUnscanRecords ¶
func (bs *BlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
func (*BlockScanner) RescanFailedRecord ¶
func (bs *BlockScanner) RescanFailedRecord()
rescanFailedRecord 重扫失败记录
func (*BlockScanner) SaveLocalBlock ¶
func (bs *BlockScanner) SaveLocalBlock(blockHeader *EthBlock) error
SaveLocalBlock 记录本地新区块
func (*BlockScanner) SaveLocalBlockHead ¶
func (bs *BlockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error
SaveLocalBlockHead 记录区块高度和hash到本地
func (*BlockScanner) SaveUnscanRecord ¶
func (bs *BlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
SaveUnscanRecord 保存交易记录到钱包数据库
func (*BlockScanner) SaveUnscannedTransaction ¶
func (bs *BlockScanner) SaveUnscannedTransaction(blockHeight uint64, reason string) error
func (*BlockScanner) ScanBlock ¶
func (bs *BlockScanner) ScanBlock(height uint64) error
func (*BlockScanner) ScanBlockTask ¶
func (bs *BlockScanner) ScanBlockTask()
func (*BlockScanner) SetRescanBlockHeight ¶
func (bs *BlockScanner) SetRescanBlockHeight(height uint64) error
SetRescanBlockHeight 重置区块链扫描高度
func (*BlockScanner) SupportBlockchainDAI ¶
func (bs *BlockScanner) SupportBlockchainDAI() bool
SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional
func (*BlockScanner) UpdateTxByReceipt ¶
func (bs *BlockScanner) UpdateTxByReceipt(tx *BlockTransaction) error
UpdateTxByReceipt
type BlockTransaction ¶
type BlockTransaction struct { Hash string `json:"hash" storm:"id"` BlockNumber string `json:"blockNumber" storm:"index"` BlockHash string `json:"blockHash" storm:"index"` From string `json:"from"` To string `json:"to"` Gas string `json:"gas"` GasPrice string `json:"gasPrice"` Value string `json:"value"` Data string `json:"input"` TransactionIndex string `json:"transactionIndex"` Timestamp string `json:"timestamp"` BlockHeight uint64 //transaction scanning 的时候对其进行赋值 FilterFunc openwallet.BlockScanTargetFuncV2 Status uint64 `json:"-"` Receipt *TransactionReceipt Decimal int32 IsInternal bool //是否内部原生币交易 }
func (*BlockTransaction) GetAmountEthString ¶
func (this *BlockTransaction) GetAmountEthString() string
func (*BlockTransaction) GetTxFeeEthString ¶
func (this *BlockTransaction) GetTxFeeEthString() string
type CallMsg ¶
type CallMsg struct { To ethcom.Address `json:"to"` From ethcom.Address `json:"from"` Nonce uint64 `json:"nonce"` Value *big.Int `json:"value"` GasLimit uint64 `json:"gasLimit"` Gas uint64 `json:"gas"` GasPrice *big.Int `json:"gasPrice"` Data []byte `json:"data"` }
func (*CallMsg) MarshalJSON ¶ added in v1.3.9
func (*CallMsg) UnmarshalJSON ¶ added in v1.3.9
type CallResult ¶
type CallResult map[string]interface{}
func (CallResult) MarshalJSON ¶
func (r CallResult) MarshalJSON() ([]byte, error)
type ERC20Token ¶
type EthBlock ¶
type EthBlock struct { BlockHeader Transactions []*BlockTransaction `json:"transactions"` }
func (*EthBlock) CreateOpenWalletBlockHeader ¶
func (block *EthBlock) CreateOpenWalletBlockHeader() *openwallet.BlockHeader
type EthContractDecoder ¶
type EthContractDecoder struct { *openwallet.SmartContractDecoderBase // contains filtered or unexported fields }
func (*EthContractDecoder) CallSmartContractABI ¶
func (decoder *EthContractDecoder) CallSmartContractABI(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) (*openwallet.SmartContractCallResult, *openwallet.Error)
调用合约ABI方法
func (*EthContractDecoder) CreateSmartContractRawTransaction ¶
func (decoder *EthContractDecoder) CreateSmartContractRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) *openwallet.Error
创建原始交易单
func (*EthContractDecoder) EncodeRawTransactionCallMsg ¶
func (decoder *EthContractDecoder) EncodeRawTransactionCallMsg(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) (*CallMsg, *abi.ABI, *openwallet.Error)
func (*EthContractDecoder) GetAssetsAccountDefAddress ¶
func (decoder *EthContractDecoder) GetAssetsAccountDefAddress(wrapper openwallet.WalletDAI, accountID string) (*openwallet.Address, *openwallet.Error)
func (*EthContractDecoder) GetTokenBalanceByAddress ¶
func (decoder *EthContractDecoder) GetTokenBalanceByAddress(contract openwallet.SmartContract, address ...string) ([]*openwallet.TokenBalance, error)
func (*EthContractDecoder) GetTokenMetadata ¶ added in v1.8.2
func (decoder *EthContractDecoder) GetTokenMetadata(contract string) (*openwallet.SmartContract, error)
GetTokenMetadata 根据合约地址查询token元数据
func (*EthContractDecoder) SubmitSmartContractRawTransaction ¶
func (decoder *EthContractDecoder) SubmitSmartContractRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) (*openwallet.SmartContractReceipt, *openwallet.Error)
SubmitRawTransaction 广播交易单
func (*EthContractDecoder) VerifyRawTransaction ¶
func (decoder *EthContractDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.SmartContractRawTransaction) error
VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单
type EthTransactionDecoder ¶
type EthTransactionDecoder struct { openwallet.TransactionDecoderBase // contains filtered or unexported fields }
func NewTransactionDecoder ¶
func NewTransactionDecoder(wm *WalletManager) *EthTransactionDecoder
NewTransactionDecoder 交易单解析器
func (*EthTransactionDecoder) CreateErc20TokenRawTransaction ¶
func (decoder *EthTransactionDecoder) CreateErc20TokenRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
func (*EthTransactionDecoder) CreateErc20TokenSummaryRawTransaction ¶
func (decoder *EthTransactionDecoder) CreateErc20TokenSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateErc20TokenSummaryRawTransaction 创建ERC20Token汇总交易
func (*EthTransactionDecoder) CreateRawTransaction ¶
func (decoder *EthTransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
CreateRawTransaction 创建交易单
func (*EthTransactionDecoder) CreateSimpleRawTransaction ¶
func (decoder *EthTransactionDecoder) CreateSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction, tmpNonce *uint64) error
func (*EthTransactionDecoder) CreateSimpleSummaryRawTransaction ¶
func (decoder *EthTransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateSimpleSummaryRawTransaction 创建QUORUM汇总交易
func (*EthTransactionDecoder) CreateSummaryRawTransaction ¶
func (decoder *EthTransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
CreateSummaryRawTransaction 创建汇总交易,返回原始交易单数组
func (*EthTransactionDecoder) CreateSummaryRawTransactionWithError ¶
func (decoder *EthTransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateSummaryRawTransactionWithError 创建汇总交易,返回能原始交易单数组(包含带错误的原始交易单)
func (*EthTransactionDecoder) GetRawTransactionFeeRate ¶
func (decoder *EthTransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)
func (*EthTransactionDecoder) SignRawTransaction ¶
func (decoder *EthTransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
SignRawTransaction 签名交易单
func (*EthTransactionDecoder) SubmitRawTransaction ¶
func (decoder *EthTransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
SubmitRawTransaction 广播交易单
func (*EthTransactionDecoder) VerifyRawTransaction ¶
func (decoder *EthTransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单
type ExtractResult ¶
type ExtractResult struct { TxID string BlockHeight uint64 Success bool // contains filtered or unexported fields }
ExtractResult 扫描完成的提取结果
type NFTContractDecoder ¶ added in v1.6.0
type NFTContractDecoder struct { *openwallet.NFTContractDecoderBase // contains filtered or unexported fields }
func (*NFTContractDecoder) GetMetaDataOfNFT ¶ added in v1.6.0
func (decoder *NFTContractDecoder) GetMetaDataOfNFT(nft *openwallet.NFT) (*openwallet.NFTMetaData, *openwallet.Error)
GetMetaDataOfNFT 查询NFT的MetaData
func (*NFTContractDecoder) GetNFTBalanceByAddress ¶ added in v1.6.0
func (decoder *NFTContractDecoder) GetNFTBalanceByAddress(nft *openwallet.NFT, owner string) (*openwallet.NFTBalance, *openwallet.Error)
GetNFTBalanceByAddress 查询地址NFT余额列表 NFT.TokenID为空则查询合约下拥有者所NFT数量。
func (*NFTContractDecoder) GetNFTBalanceByAddressBatch ¶ added in v1.6.0
func (decoder *NFTContractDecoder) GetNFTBalanceByAddressBatch(nft []*openwallet.NFT, owner []string) ([]*openwallet.NFTBalance, *openwallet.Error)
GetNFTBalanceByAddressBatch 查询地址NFT余额列表
func (*NFTContractDecoder) GetNFTOwnerByTokenID ¶ added in v1.6.0
func (decoder *NFTContractDecoder) GetNFTOwnerByTokenID(nft *openwallet.NFT) (*openwallet.NFTOwner, *openwallet.Error)
GetNFTOwnerByTokenID 查询地址token的拥有者
func (*NFTContractDecoder) GetNFTTransfer ¶ added in v1.6.0
func (decoder *NFTContractDecoder) GetNFTTransfer(event *openwallet.SmartContractEvent) (*openwallet.NFTTransfer, *openwallet.Error)
GetNFTTransfer 从event解析NFT转账信息
type SaveResult ¶
SaveResult 保存结果
type TransactionReceipt ¶
func (*TransactionReceipt) ParseTransferEvent ¶
func (receipt *TransactionReceipt) ParseTransferEvent() map[string][]*TransferEvent
type TransferEvent ¶
type WalletConfig ¶
type WalletConfig struct { //币种 Symbol string //本地数据库文件路径 DBPath string //钱包服务API ServerAPI string //曲线类型 CurveType uint32 //网络ID ChainID uint64 //数据目录 DataDir string //固定gasLimit值 FixGasLimit *big.Int //固定gasPrice值 FixGasPrice *big.Int //补偿gasPrice值 OffsetsGasPrice *big.Int //nonce计算方式, 0: auto-increment nonce, 1: latest nonce NonceComputeMode int64 //Broadcast node RPC API BroadcastAPI string // Use QuickNode Single Flight RPC UseQNSingleFlightRPC int64 // Detect unknown contracts DetectUnknownContracts int64 // 是否用Moralis解析区块 UseMoralisAPIParseBlock int64 }
func NewConfig ¶
func NewConfig(symbol string) *WalletConfig
type WalletManager ¶
type WalletManager struct { openwallet.AssetsAdapterBase RawClient *ethclient.Client //原生ETH客户端 WalletClient *quorum_rpc.Client // 节点客户端 BroadcastClient *quorum_rpc.Client // 节点客户端 Config *WalletConfig //钱包管理配置 Blockscanner openwallet.BlockScanner //区块扫描器 Decoder openwallet.AddressDecoderV2 //地址编码器 TxDecoder openwallet.TransactionDecoder //交易单编码器 ContractDecoder openwallet.SmartContractDecoder //智能合约解释器 NFTContractDecoder openwallet.NFTContractDecoder //NFT智能合约解释器 Log *log.OWLogger //日志工具 CustomAddressEncodeFunc func(address string) string //自定义地址转换算法 CustomAddressDecodeFunc func(address string) string //自定义地址转换算法 MoralisSDK *quorum_moralis.MoralisSDK //MoralisSDK }
func NewWalletManager ¶
func NewWalletManager() *WalletManager
func NewWalletManagerWithSymbol ¶ added in v1.6.4
func NewWalletManagerWithSymbol(symbol string) *WalletManager
func (*WalletManager) BalanceModelType ¶
func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType
func (*WalletManager) CallABI ¶ added in v1.6.1
func (wm *WalletManager) CallABI(contractAddr string, abiInstance abi.ABI, abiParam ...string) (map[string]interface{}, *openwallet.Error)
func (*WalletManager) DecodeABIResult ¶
func (wm *WalletManager) DecodeABIResult(abiInstance abi.ABI, method string, dataHex string) (map[string]interface{}, string, error)
DecodeABIResult 解码ABI结果
func (*WalletManager) DecodeReceiptLogResult ¶
func (wm *WalletManager) DecodeReceiptLogResult(abiInstance abi.ABI, log types.Log) (map[string]interface{}, string, string, error)
DecodeReceiptLogResult 解码回执日志结果
func (*WalletManager) ERC20GetAddressBalance ¶
func (wm *WalletManager) ERC20GetAddressBalance(address string, contractAddr string) (*big.Int, error)
ERC20GetAddressBalance
func (*WalletManager) EncodeABIParam ¶
EncodeABIParam 编码API调用参数
func (*WalletManager) EthCall ¶
func (wm *WalletManager) EthCall(callMsg CallMsg, sign string) (string, error)
func (*WalletManager) GetAddrBalance ¶
GetAddrBalance
func (*WalletManager) GetAddressDecoderV2 ¶
func (wm *WalletManager) GetAddressDecoderV2() openwallet.AddressDecoderV2
AddressDecode 地址解析器
func (*WalletManager) GetAddressNonce ¶
func (wm *WalletManager) GetAddressNonce(wrapper openwallet.WalletDAI, address string) uint64
GetAddressNonce
func (*WalletManager) GetAssetsLogger ¶
func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
GetAssetsLogger 获取资产账户日志工具
func (*WalletManager) GetBlockByMoralis ¶ added in v1.9.0
func (wm *WalletManager) GetBlockByMoralis(blockNum uint64) (*EthBlock, error)
GetBlockByMoralis
func (*WalletManager) GetBlockByNum ¶
func (wm *WalletManager) GetBlockByNum(blockNum uint64, showTransactionSpec bool) (*EthBlock, error)
func (*WalletManager) GetBlockNumber ¶
func (wm *WalletManager) GetBlockNumber() (uint64, error)
GetBlockNumber
func (*WalletManager) GetBlockScanner ¶
func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
GetBlockScanner 获取区块链
func (*WalletManager) GetBlockchainSyncStatus ¶ added in v1.7.0
func (wm *WalletManager) GetBlockchainSyncStatus() (*openwallet.BlockchainSyncStatus, error)
func (*WalletManager) GetETHBlockByNum ¶ added in v1.8.0
func (wm *WalletManager) GetETHBlockByNum(blockNum uint64, showTransactionSpec bool) (*EthBlock, error)
func (*WalletManager) GetGasEstimated ¶
func (wm *WalletManager) GetGasEstimated(from string, to string, value *big.Int, data []byte) (*big.Int, error)
GetGasEstimated
func (*WalletManager) GetGasPrice ¶
func (wm *WalletManager) GetGasPrice() (*big.Int, error)
func (*WalletManager) GetNFTContractDecoder ¶ added in v1.6.0
func (wm *WalletManager) GetNFTContractDecoder() openwallet.NFTContractDecoder
GetNFTContractDecoder 获取NFT智能合约解析器 @optional
func (*WalletManager) GetQNBlockWithReceipts ¶ added in v1.8.0
func (wm *WalletManager) GetQNBlockWithReceipts(blockNum uint64) (*EthBlock, error)
GetQNBlockWithReceipts
func (*WalletManager) GetSmartContractDecoder ¶
func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
GetSmartContractDecoder 获取智能合约解析器
func (*WalletManager) GetTransactionByHash ¶
func (wm *WalletManager) GetTransactionByHash(txid string) (*BlockTransaction, error)
func (*WalletManager) GetTransactionCount ¶
func (wm *WalletManager) GetTransactionCount(addr string) (uint64, error)
func (*WalletManager) GetTransactionDecoder ¶
func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
TransactionDecoder 交易单解析器
func (*WalletManager) GetTransactionFeeEstimated ¶
func (*WalletManager) GetTransactionReceipt ¶
func (wm *WalletManager) GetTransactionReceipt(transactionId string) (*TransactionReceipt, error)
func (*WalletManager) InitAssetsConfig ¶
func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
InitAssetsConfig 初始化默认配置
func (*WalletManager) IsContract ¶
func (wm *WalletManager) IsContract(address string) (bool, error)
IsContract 是否合约
func (*WalletManager) LoadAssetsConfig ¶
func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
LoadAssetsConfig 加载外部配置
func (*WalletManager) LoadContractInfo ¶ added in v1.6.1
func (wm *WalletManager) LoadContractInfo(addr string) *openwallet.SmartContract
LoadContractInfo 通过地址加载合约信息
func (*WalletManager) QNFetchNFTCollectionDetails ¶ added in v1.8.4
func (wm *WalletManager) QNFetchNFTCollectionDetails(contracts []string) (*gjson.Result, error)
func (*WalletManager) RecoverUnscannedTransactions ¶
func (wm *WalletManager) RecoverUnscannedTransactions(unscannedTxs []*openwallet.UnscanRecord) ([]*BlockTransaction, error)
func (*WalletManager) SendRawTransaction ¶
func (wm *WalletManager) SendRawTransaction(signedTx string) (string, error)
SendRawTransaction
func (*WalletManager) SetNetworkChainID ¶
func (wm *WalletManager) SetNetworkChainID() (uint64, error)
func (*WalletManager) SupportsInterface ¶ added in v1.6.1
func (wm *WalletManager) SupportsInterface(contractAddr string) string
func (*WalletManager) UpdateAddressNonce ¶
func (wm *WalletManager) UpdateAddressNonce(wrapper openwallet.WalletDAI, address string, nonce uint64)
UpdateAddressNonce