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.
* 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 ConverEthDecimalToWei(amount decimal.Decimal) (*big.Int, error)
- func ConverWeiStringToEthDecimal(amount string) (decimal.Decimal, error)
- func ConvertAmountToFloatDecimal(amount string, decimals int) (decimal.Decimal, error)
- func ConvertEthStringToWei(amount string) (*big.Int, error)
- func ConvertFloatStringToBigInt(amount string, decimals int) (*big.Int, error)
- func ConvertToBigInt(value string, base int) (*big.Int, error)
- func ConvertToUint64(value string, base int) (uint64, error)
- func OpenDB(dbPath string, dbName string) (*storm.DB, error)
- func VerifyRawTransaction(rawTx *openwallet.RawTransaction) error
- type AddrBalance
- type AddrBalanceInf
- type AddrVec
- 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 AddressTxStatistic
- type BlockHeader
- type BlockTransaction
- type Client
- func (c *Client) Call(method string, id int64, params []interface{}) (*gjson.Result, error)
- func (c *Client) Call2(method string, id int64, params []interface{}) (*gjson.Result, error)
- func (this *Client) ERC20GetAddressBalance(address string, contractAddr string) (*big.Int, error)
- func (this *Client) ERC20GetAddressBalance2(address string, contractAddr string, sign string) (*big.Int, error)
- func (this *Client) EthGetTransactionByHash(txid string) (*BlockTransaction, error)
- func (this *Client) EthGetTxPoolContent() (*TxpoolContent, error)
- func (this *Client) GetAddrBalance2(address string, sign string) (*big.Int, error)
- func (this *Client) LockAddr(address string) error
- func (this *Client) SerializationTransaction(from, to, amount, blockNum, addr string) (string, error)
- func (this *Client) UnlockAddr(address string, password string, secs int) error
- func (this *Client) WscGetBlockNumber() (uint64, error)
- func (this *Client) WscGetBlockSpecByBlockNum(blockNum uint64, showTransactionSpec bool) (*WscBlock, error)
- func (this *Client) WscGetTransactionReceipt(transactionId string) (*EthTransactionReceipt, error)
- type ERC20Token
- type EthContractDecoder
- type EthEvent
- type EthTransactionReceipt
- type EthTxExtPara
- type ExtractResult
- type Response
- type SaveResult
- type SolidityParam
- type TokenAddrVec
- type TransferEvent
- type TxpoolContent
- type WSCBLockScanner
- func (this *WSCBLockScanner) BatchExtractTransaction(txs []BlockTransaction) error
- func (bs *WSCBLockScanner) DeleteUnscanRecord(height uint64) error
- func (bs *WSCBLockScanner) DeleteUnscanRecordByID(id string) error
- func (this *WSCBLockScanner) ExtractTransactionData(txid string, scanTargetFunc openwallet.BlockScanTargetFunc) (map[string][]*openwallet.TxExtractData, error)
- func (this *WSCBLockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
- func (this *WSCBLockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
- func (this *WSCBLockScanner) GetGlobalMaxBlockHeight() uint64
- func (bs *WSCBLockScanner) GetLocalBlock(height uint64) (*WscBlock, error)
- func (bs *WSCBLockScanner) GetLocalBlockHead() (uint64, string, error)
- func (this *WSCBLockScanner) GetLocalNewBlock() (uint64, string, error)
- func (this *WSCBLockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)
- func (this *WSCBLockScanner) GetScannedBlockHeight() uint64
- func (this *WSCBLockScanner) GetTxPoolPendingTxs() ([]BlockTransaction, error)
- func (bs *WSCBLockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
- func (this *WSCBLockScanner) MakeFromExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)
- func (this *WSCBLockScanner) MakeSimpleToExtractData(tx *BlockTransaction) (string, []*openwallet.TxExtractData, error)
- func (this *WSCBLockScanner) MakeSimpleTxFromExtractData(tx *BlockTransaction) (string, []*openwallet.TxExtractData, error)
- func (this *WSCBLockScanner) MakeToExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)
- func (this *WSCBLockScanner) MakeTokenToExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)
- func (this *WSCBLockScanner) MakeTokenTxFromExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)
- func (this *WSCBLockScanner) RescanFailedTransactions() error
- func (bs *WSCBLockScanner) SaveLocalBlock(blockHeader *WscBlock) error
- func (bs *WSCBLockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error
- func (bs *WSCBLockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
- func (this *WSCBLockScanner) SaveUnscannedTransaction(tx *BlockTransaction, reason string) error
- func (this *WSCBLockScanner) ScanBlock(height uint64) error
- func (this *WSCBLockScanner) ScanBlockTask()
- func (this *WSCBLockScanner) ScanTxMemPool() error
- func (this *WSCBLockScanner) SetRescanBlockHeight(height uint64) error
- func (bs *WSCBLockScanner) SupportBlockchainDAI() bool
- func (this *WSCBLockScanner) TransactionScanning(tx *BlockTransaction) (*ExtractResult, error)
- func (this *WSCBLockScanner) UpdateTxByReceipt(tx *BlockTransaction) (map[string][]*TransferEvent, error)
- type Wallet
- func (this *Wallet) ClearAllTransactions(dbPath string)
- func (w *Wallet) DBFile(dbPath string) string
- func (this *Wallet) DeleteTransactionByHeight(dbPath string, height uint64) error
- func (this *Wallet) DumpWalletDB(dbPath string)
- func (w *Wallet) FileName() string
- func (this *Wallet) HDKey2(password string) (*hdkeystore.HDKey, error)
- func (w *Wallet) OpenDB(dbPath string) (*storm.DB, error)
- func (w *Wallet) OpenDbByPath(path string) (*storm.DB, error)
- func (this *Wallet) RestoreFromDb(dbPath string) error
- func (this *Wallet) SaveAddress(dbpath string, addr *Address) error
- func (this *Wallet) SaveTransactions(dbPath string, txs []BlockTransaction) error
- type WalletConfig
- type WalletManager
- func (this *WalletManager) AddWalletInSummary(wid string, wallet *Wallet)
- func (this *WalletManager) BackupWallet2(newBackupDir string, wallet *Wallet, password string) (string, error)
- func (this *WalletManager) BackupWalletToDefaultPath(wallet *Wallet, password string) (string, error)
- func (this *WalletManager) CreateWallet(name string, password string) (*Wallet, string, error)
- func (this *WalletManager) CurveType() uint32
- func (this *WalletManager) Decimal() int32
- func (this *WalletManager) FullName() string
- func (this *WalletManager) GetAddressDecode() openwallet.AddressDecoder
- func (this *WalletManager) GetAssetsLogger() *log.OWLogger
- func (this *WalletManager) GetBlockScanner() openwallet.BlockScanner
- func (this *WalletManager) GetConfig() WalletConfig
- func (this *WalletManager) GetERC20TokenList() ([]ERC20Token, error)
- func (this *WalletManager) GetERC20TokenTransactionFeeEstimated(from string, to string, data string) (*txFeeInfo, error)
- func (this *WalletManager) GetErc20TokenEvent(transactionID string) (map[string][]*TransferEvent, error)
- func (this *WalletManager) GetNonceForAddress(address string) (uint64, error)
- func (this *WalletManager) GetNonceForAddress2(address string) (uint64, error)
- func (this *WalletManager) GetSimpleTransactionFeeEstimated(from string, to string, amount *big.Int) (*txFeeInfo, error)
- func (this *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
- func (this *WalletManager) GetTokenBalanceByAddress(contractAddr string, addrs ...AddrBalanceInf) error
- func (this *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
- func (this *WalletManager) GetTransactionFeeEstimated(from string, to string, value *big.Int, data string) (*txFeeInfo, error)
- func (this *WalletManager) ImportWatchOnlyAddress(address ...*openwallet.Address) error
- func (this *WalletManager) InitAssetsConfig() (config.Configer, error)
- func (this *WalletManager) InitConfig()
- func (this *WalletManager) InitConfigFlow() error
- func (this *WalletManager) LoadAssetsConfig(c config.Configer) error
- func (this *WalletManager) PrintConfig() error
- func (this *WalletManager) RecoverUnscannedTransactions(unscannedTxs []*openwallet.UnscanRecord) ([]BlockTransaction, error)
- func (this *WalletManager) SaveERC20TokenConfig(config *ERC20Token) error
- func (this *WalletManager) SendTransactionToAddr(param map[string]interface{}) (string, error)
- func (wm *WalletManager) ShowConfig() error
- func (this *WalletManager) Symbol() string
- func (this *WalletManager) UnlockWallet(wallet *Wallet, password string) error
- func (this *WalletManager) WscSendRawTransaction(signedTx string) (string, error)
- type WscBlock
- type WscTransactionDecoder
- func (this *WscTransactionDecoder) CreateErc20TokenRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (this *WscTransactionDecoder) CreateErc20TokenSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (this *WscTransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (this *WscTransactionDecoder) CreateSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction, ...) error
- func (this *WscTransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (this *WscTransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
- func (this *WscTransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (this *WscTransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)
- func (this *WscTransactionDecoder) GetTransactionCount(address string) (uint64, error)
- func (this *WscTransactionDecoder) GetTransactionCount2(address string) (*AddressTxStatistic, uint64, error)
- func (this *WscTransactionDecoder) RemoveOutdatedAddrStatic()
- func (this *WscTransactionDecoder) RunClearAddrStatic()
- func (this *WscTransactionDecoder) SetTransactionCount(address string, transactionCount uint64) error
- func (this *WscTransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (this *WscTransactionDecoder) SubmitErc20TokenRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
- func (this *WscTransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
- func (this *WscTransactionDecoder) SubmitSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
- func (this *WscTransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
Constants ¶
const ( // BLOCK_CHAIN_DB = "blockchain.db" BLOCK_CHAIN_BUCKET = "blockchain" ERC20TOKEN_DB = "erc20Token.db" )
const ( Symbol = "WSC" ContractAddress = "0xbaeec028b1f9eda0b6b015a437999634c3dd114b" MasterKey = "Ethereum seed" TIME_POSTFIX = "20060102150405" CurveType = owcrypt.ECC_CURVE_SECP256K1 )
const ( ETH_GET_TOKEN_BALANCE_METHOD = "0x70a08231" ETH_TRANSFER_TOKEN_BALANCE_METHOD = "0xa9059cbb" ETH_TRANSFER_EVENT_ID = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" )
const ( SOLIDITY_TYPE_ADDRESS = "address" SOLIDITY_TYPE_UINT256 = "uint256" SOLIDITY_TYPE_UINT160 = "uint160" )
const ( WALLET_NOT_EXIST_ERR = "The wallet whose name is given not exist!" BACKUP_FILE_TYPE_ADDRESS = 0 BACKUP_FILE_TYPE_WALLET_KEY = 1 BACKUP_FILE_TYPE_WALLET_DB = 2 )
const ( TRANS_AMOUNT_UNIT_LIST = ` 1: wei 2: Kwei 3: Mwei 4: GWei 5: microether 6: milliether 7: ether ` TRANS_AMOUNT_UNIT_WEI = 1 TRANS_AMOUNT_UNIT_K_WEI = 2 TRANS_AMOUNT_UNIT_M_WEI = 3 TRANS_AMOUNT_UNIT_G_WEI = 4 TRANS_AMOUNT_UNIT_MICRO_ETHER = 5 TRANS_AMOUNT_UNIT_MILLIE_ETHER = 6 TRNAS_AMOUNT_UNIT_ETHER = 7 )
const (
ADRESS_STATIS_OVERDATED_TIME = 30
)
const ( //BLOCK_CHAIN_BUCKET = "blockchain" //区块链数据集合 //periodOfTask = 5 * time.Second //定时任务执行隔间 MAX_EXTRACTING_SIZE = 15 //并发的扫描线程数 )
Variables ¶
var (
Decimals = 8
)
Functions ¶
func AppendOxToAddress ¶
func VerifyRawTransaction ¶
func VerifyRawTransaction(rawTx *openwallet.RawTransaction) error
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 AddressTxStatistic ¶
type AddressTxStatistic struct { Address string TransactionCount *uint64 LastModifiedTime *time.Time Valid *int //如果valid指针指向的整形为0, 说明该地址已经被清理线程清理 AddressLocker *sync.Mutex }
func (*AddressTxStatistic) UpdateTime ¶
func (this *AddressTxStatistic) UpdateTime()
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的时候进行初始化 }
"result": { "dbHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "extraData": [], "gasLimit": "0x0", "gasUsed": "0x0", "hash": "0x99576e7567d258bd6426ddaf953ec0c953778b2f09a078423103c6555aa4362d", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "number": 1, "parentHash": "0x4f6394763c33c1709e5a72b202ad4d7a3b8152de3dc698cef6f675ecdaf20a3b", "receiptsRoot": "0x69a04fa6073e4fc0947bac7ee6990e788d1e2c5ec0fe6c2436d0892e7f3c09d2", "sealer": "0x2", "sealerList": [ "11e1be251ca08bb44f36fdeedfaeca40894ff80dfd80084607a75509edeaf2a9c6fee914f1e9efda571611cf4575a1577957edfd2baa9386bd63eb034868625f", "78a313b426c3de3267d72b53c044fa9fe70c2a27a00af7fea4a549a7d65210ed90512fc92b6194c14766366d434235c794289d66deff0796f15228e0e14a9191", "95b7ff064f91de76598f90bc059bec1834f0d9eeb0d05e1086d49af1f9c2f321062d011ee8b0df7644bd54c4f9ca3d8515a3129bbb9d0df8287c9fa69552887e", "b8acb51b9fe84f88d670646be36f31c52e67544ce56faf3dc8ea4cf1b0ebff0864c6b218fdcd9cf9891ebd414a995847911bd26a770f429300085f37e1131f36" ], "signatureList": [ { "index": "0x2", "signature": "0xae098aabc63a53b8dcb57da9a87f13aebf231bfe1704da88f125cee6b4b30ee0609d0720a97bed1900b96bc3e7a63584158340b5b7f802945241f61731f9358900" }, { "index": "0x0", "signature": "0x411cb93f816549eba82c3bf8c03fa637036dcdee65667b541d0da06a6eaea80d16e6ca52bf1b08f77b59a834bffbc124c492ea7a1601d0c4fb257d97dc97cea600" }, { "index": "0x3", "signature": "0xb5b41e49c0b2bf758322ecb5c86dc3a3a0f9b98891b5bbf50c8613a241f05f595ce40d0bb212b6faa32e98546754835b057b9be0b29b9d0c8ae8b38f7487b8d001" } ], "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x173ad8703d6", "transactionsRoot": "0xb563f70188512a085b5607cac0c35480336a566de736c83410a062c9acc785ad" }
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.BlockScanAddressFunc Status uint64 }
func (*BlockTransaction) GetAmountEthString ¶
func (this *BlockTransaction) GetAmountEthString() (string, error)
func (*BlockTransaction) GetTxFeeEthString ¶
func (this *BlockTransaction) GetTxFeeEthString() (string, error)
type Client ¶
func (*Client) ERC20GetAddressBalance ¶
func (*Client) ERC20GetAddressBalance2 ¶
func (*Client) EthGetTransactionByHash ¶
func (this *Client) EthGetTransactionByHash(txid string) (*BlockTransaction, error)
func (*Client) EthGetTxPoolContent ¶
func (this *Client) EthGetTxPoolContent() (*TxpoolContent, error)
func (*Client) GetAddrBalance2 ¶
func (*Client) SerializationTransaction ¶
func (*Client) UnlockAddr ¶
func (*Client) WscGetBlockNumber ¶
func (*Client) WscGetBlockSpecByBlockNum ¶
func (*Client) WscGetTransactionReceipt ¶
func (this *Client) WscGetTransactionReceipt(transactionId string) (*EthTransactionReceipt, error)
type ERC20Token ¶
type EthContractDecoder ¶
type EthContractDecoder struct { *openwallet.SmartContractDecoderBase // contains filtered or unexported fields }
func (*EthContractDecoder) GetTokenBalanceByAddress ¶
func (this *EthContractDecoder) GetTokenBalanceByAddress(contract openwallet.SmartContract, address ...string) ([]*openwallet.TokenBalance, error)
type EthTransactionReceipt ¶
type EthTransactionReceipt struct { Logs []EthEvent `json:"logs"` GasUsed string `json:"gasUsed"` Status string `json:"status"` }
func (*EthTransactionReceipt) ParseTransferEvent ¶
func (this *EthTransactionReceipt) ParseTransferEvent() map[string][]*TransferEvent
type EthTxExtPara ¶
func NewEthTxExtPara ¶
func NewEthTxExtPara(j gjson.Result) *EthTxExtPara
type ExtractResult ¶
type ExtractResult struct { //Recharges []*openwallet.Recharge TxID string BlockHeight uint64 Success bool // contains filtered or unexported fields }
ExtractResult 扫描完成的提取结果
type SaveResult ¶
SaveResult 保存结果
type SolidityParam ¶
type SolidityParam struct { ParamType string ParamValue interface{} }
type TokenAddrVec ¶
type TokenAddrVec struct {
// contains filtered or unexported fields
}
func (*TokenAddrVec) Len ¶
func (this *TokenAddrVec) Len() int
func (*TokenAddrVec) Less ¶
func (this *TokenAddrVec) Less(i, j int) bool
func (*TokenAddrVec) Swap ¶
func (this *TokenAddrVec) Swap(i, j int)
type TransferEvent ¶
type TxpoolContent ¶
type TxpoolContent struct {
Pending map[string]map[string]BlockTransaction `json:"pending"`
}
func (*TxpoolContent) GetPendingTxCountForAddr ¶
func (this *TxpoolContent) GetPendingTxCountForAddr(addr string) int
func (*TxpoolContent) GetSequentTxNonce ¶
type WSCBLockScanner ¶
type WSCBLockScanner struct { *openwallet.BlockScannerBase CurrentBlockHeight uint64 //当前区块高度 IsScanMemPool bool //是否扫描交易池 RescanLastBlockCount uint64 //重扫上N个区块数量 // contains filtered or unexported fields }
func NewETHBlockScanner ¶
func NewETHBlockScanner(wm *WalletManager) *WSCBLockScanner
NewBTCBlockScanner 创建区块链扫描器
func (*WSCBLockScanner) BatchExtractTransaction ¶
func (this *WSCBLockScanner) BatchExtractTransaction(txs []BlockTransaction) error
BatchExtractTransaction 批量提取交易单 bitcoin 1M的区块链可以容纳3000笔交易,批量多线程处理,速度更快
func (*WSCBLockScanner) DeleteUnscanRecord ¶
func (bs *WSCBLockScanner) DeleteUnscanRecord(height uint64) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*WSCBLockScanner) DeleteUnscanRecordByID ¶
func (bs *WSCBLockScanner) DeleteUnscanRecordByID(id string) error
DeleteUnscanRecordByID 删除指定的未扫记录
func (*WSCBLockScanner) ExtractTransactionData ¶
func (this *WSCBLockScanner) ExtractTransactionData(txid string, scanTargetFunc openwallet.BlockScanTargetFunc) (map[string][]*openwallet.TxExtractData, error)
ExtractTransactionData 扫描一笔交易
func (*WSCBLockScanner) GetBalanceByAddress ¶
func (this *WSCBLockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
func (*WSCBLockScanner) GetCurrentBlockHeader ¶
func (this *WSCBLockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
GetCurrentBlockHeader 获取当前区块高度
func (*WSCBLockScanner) GetGlobalMaxBlockHeight ¶
func (this *WSCBLockScanner) GetGlobalMaxBlockHeight() uint64
func (*WSCBLockScanner) GetLocalBlock ¶
func (bs *WSCBLockScanner) GetLocalBlock(height uint64) (*WscBlock, error)
GetLocalBlock 获取本地区块数据
func (*WSCBLockScanner) GetLocalBlockHead ¶
func (bs *WSCBLockScanner) GetLocalBlockHead() (uint64, string, error)
GetLocalBlockHead 获取本地记录的区块高度和hash
func (*WSCBLockScanner) GetLocalNewBlock ¶
func (this *WSCBLockScanner) GetLocalNewBlock() (uint64, string, error)
GetLocalNewBlock 获取本地记录的区块高度和hash
func (*WSCBLockScanner) GetScannedBlockHeader ¶
func (this *WSCBLockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)
GetScannedBlockHeader 获取当前已扫区块高度
func (*WSCBLockScanner) GetScannedBlockHeight ¶
func (this *WSCBLockScanner) GetScannedBlockHeight() uint64
GetScannedBlockHeight 获取已扫区块高度
func (*WSCBLockScanner) GetTxPoolPendingTxs ¶
func (this *WSCBLockScanner) GetTxPoolPendingTxs() ([]BlockTransaction, error)
func (*WSCBLockScanner) GetUnscanRecords ¶
func (bs *WSCBLockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
func (*WSCBLockScanner) MakeFromExtractData ¶
func (this *WSCBLockScanner) MakeFromExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)
func (*WSCBLockScanner) MakeSimpleToExtractData ¶
func (this *WSCBLockScanner) MakeSimpleToExtractData(tx *BlockTransaction) (string, []*openwallet.TxExtractData, error)
func (*WSCBLockScanner) MakeSimpleTxFromExtractData ¶
func (this *WSCBLockScanner) MakeSimpleTxFromExtractData(tx *BlockTransaction) (string, []*openwallet.TxExtractData, error)
func (*WSCBLockScanner) MakeToExtractData ¶
func (this *WSCBLockScanner) MakeToExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)
func (*WSCBLockScanner) MakeTokenToExtractData ¶
func (this *WSCBLockScanner) MakeTokenToExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)
func (*WSCBLockScanner) MakeTokenTxFromExtractData ¶
func (this *WSCBLockScanner) MakeTokenTxFromExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)
func (*WSCBLockScanner) RescanFailedTransactions ¶
func (this *WSCBLockScanner) RescanFailedTransactions() error
func (*WSCBLockScanner) SaveLocalBlock ¶
func (bs *WSCBLockScanner) SaveLocalBlock(blockHeader *WscBlock) error
SaveLocalBlock 记录本地新区块
func (*WSCBLockScanner) SaveLocalBlockHead ¶
func (bs *WSCBLockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error
SaveLocalBlockHead 记录区块高度和hash到本地
func (*WSCBLockScanner) SaveUnscanRecord ¶
func (bs *WSCBLockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
SaveUnscanRecord 保存交易记录到钱包数据库
func (*WSCBLockScanner) SaveUnscannedTransaction ¶
func (this *WSCBLockScanner) SaveUnscannedTransaction(tx *BlockTransaction, reason string) error
func (*WSCBLockScanner) ScanBlock ¶
func (this *WSCBLockScanner) ScanBlock(height uint64) error
func (*WSCBLockScanner) ScanBlockTask ¶
func (this *WSCBLockScanner) ScanBlockTask()
func (*WSCBLockScanner) ScanTxMemPool ¶
func (this *WSCBLockScanner) ScanTxMemPool() error
func (*WSCBLockScanner) SetRescanBlockHeight ¶
func (this *WSCBLockScanner) SetRescanBlockHeight(height uint64) error
SetRescanBlockHeight 重置区块链扫描高度
func (*WSCBLockScanner) SupportBlockchainDAI ¶
func (bs *WSCBLockScanner) SupportBlockchainDAI() bool
SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional
func (*WSCBLockScanner) TransactionScanning ¶
func (this *WSCBLockScanner) TransactionScanning(tx *BlockTransaction) (*ExtractResult, error)
func (*WSCBLockScanner) UpdateTxByReceipt ¶
func (this *WSCBLockScanner) UpdateTxByReceipt(tx *BlockTransaction) (map[string][]*TransferEvent, error)
type Wallet ¶
type Wallet struct { WalletID string `json:"rootid" storm:"id"` Alias string `json:"alias"` Password string `json:"password"` RootPub string `json:"rootpub"` RootPath string KeyFile string HdPath string PublicKey string AddressCount uint64 // contains filtered or unexported fields }
func GetWalletKey ¶
func GetWalletKeys ¶
func (*Wallet) ClearAllTransactions ¶
func (*Wallet) DeleteTransactionByHeight ¶
func (*Wallet) DumpWalletDB ¶
func (*Wallet) HDKey2 ¶
func (this *Wallet) HDKey2(password string) (*hdkeystore.HDKey, error)
HDKey 获取钱包密钥,需要密码
func (*Wallet) RestoreFromDb ¶
func (*Wallet) SaveTransactions ¶
func (this *Wallet) SaveTransactions(dbPath string, txs []BlockTransaction) error
type WalletConfig ¶
type WalletConfig struct { //币种 Symbol string MasterKey string RootDir string //RPC认证账户名 //RpcUser string //RPC认证账户密码 //RpcPassword string //证书目录 //CertsDir string //钥匙备份路径 KeyDir string //地址导出路径 AddressDir string //配置文件路径 ConfigFilePath string //配置文件名 ConfigFileName string //rpc证书 //CertFileName string //区块链数据文件 //BlockchainFile string //是否测试网络 IsTestNet bool // 核心钱包是否只做监听 //CoreWalletWatchOnly bool //最大的输入数量 //MaxTxInputs int //本地数据库文件路径 DbPath string //备份路径 BackupDir string //钱包服务API ServerAPI string //钱包安装的路径 //NodeInstallPath string //钱包数据文件目录 //WalletDataPath string //汇总阀值 //ThreaholdStr string Threshold *big.Int `json:"-"` //汇总地址 SumAddress string //汇总执行间隔时间 CycleSeconds uint64 //time.Duration //默认配置内容 // DefaultConfig string //曲线类型 CurveType uint32 //小数位长度 // CoinDecimal decimal.Decimal `json:"-"` EthereumKeyPath string //是否完全依靠本地维护nonce LocalNonce bool ChainID uint64 //数据目录 DataDir string //固定gasLimit值 FixGasLimit *big.Int }
func NewConfig ¶
func NewConfig(symbol string) *WalletConfig
func (*WalletConfig) LoadConfig ¶
func (this *WalletConfig) LoadConfig(configFilePath string, configFileName string) (*WalletConfig, error)
type WalletManager ¶
type WalletManager struct { openwallet.AssetsAdapterBase Storage *hdkeystore.HDKeystore //秘钥存取 WalletClient *Client // 节点客户端 Config *WalletConfig //钱包管理配置 WalletsInSum map[string]*openwallet.Wallet //参与汇总的钱包 Blockscanner openwallet.BlockScanner //区块扫描器 Decoder openwallet.AddressDecoder //地址编码器 TxDecoder openwallet.TransactionDecoder //交易单编码器 WalletInSumOld map[string]*Wallet ContractDecoder openwallet.SmartContractDecoder // //StorageOld *keystore.HDKeystore ConfigPath string RootPath string DefaultConfig string Log *log.OWLogger //日志工具 // contains filtered or unexported fields }
func NewWalletManager ¶
func NewWalletManager() *WalletManager
func (*WalletManager) AddWalletInSummary ¶
func (this *WalletManager) AddWalletInSummary(wid string, wallet *Wallet)
AddWalletInSummary 添加汇总钱包账户
func (*WalletManager) BackupWallet2 ¶
func (*WalletManager) BackupWalletToDefaultPath ¶
func (this *WalletManager) BackupWalletToDefaultPath(wallet *Wallet, password string) (string, error)
func (*WalletManager) CreateWallet ¶
func (*WalletManager) GetAddressDecode ¶
func (this *WalletManager) GetAddressDecode() openwallet.AddressDecoder
GetAddressDecode 地址解析器
func (*WalletManager) GetAssetsLogger ¶
func (this *WalletManager) GetAssetsLogger() *log.OWLogger
GetAssetsLogger 获取资产账户日志工具
func (*WalletManager) GetBlockScanner ¶
func (this *WalletManager) GetBlockScanner() openwallet.BlockScanner
GetBlockScanner 获取区块链
func (*WalletManager) GetConfig ¶
func (this *WalletManager) GetConfig() WalletConfig
func (*WalletManager) GetERC20TokenList ¶
func (this *WalletManager) GetERC20TokenList() ([]ERC20Token, error)
func (*WalletManager) GetERC20TokenTransactionFeeEstimated ¶
func (this *WalletManager) GetERC20TokenTransactionFeeEstimated(from string, to string, data string) (*txFeeInfo, error)
func (*WalletManager) GetErc20TokenEvent ¶
func (this *WalletManager) GetErc20TokenEvent(transactionID string) (map[string][]*TransferEvent, error)
func (*WalletManager) GetNonceForAddress ¶
func (this *WalletManager) GetNonceForAddress(address string) (uint64, error)
func (*WalletManager) GetNonceForAddress2 ¶
func (this *WalletManager) GetNonceForAddress2(address string) (uint64, error)
func (*WalletManager) GetSimpleTransactionFeeEstimated ¶
func (*WalletManager) GetSmartContractDecoder ¶
func (this *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
func (*WalletManager) GetTokenBalanceByAddress ¶
func (this *WalletManager) GetTokenBalanceByAddress(contractAddr string, addrs ...AddrBalanceInf) error
func (*WalletManager) GetTransactionDecoder ¶
func (this *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
GetTransactionDecoder 交易单解析器
func (*WalletManager) GetTransactionFeeEstimated ¶
func (*WalletManager) ImportWatchOnlyAddress ¶
func (this *WalletManager) ImportWatchOnlyAddress(address ...*openwallet.Address) error
ImportWatchOnlyAddress 导入观测地址
func (*WalletManager) InitAssetsConfig ¶
func (this *WalletManager) InitAssetsConfig() (config.Configer, error)
InitAssetsConfig 初始化默认配置
func (*WalletManager) LoadAssetsConfig ¶
func (this *WalletManager) LoadAssetsConfig(c config.Configer) error
func (*WalletManager) PrintConfig ¶
func (this *WalletManager) PrintConfig() error
func (*WalletManager) RecoverUnscannedTransactions ¶
func (this *WalletManager) RecoverUnscannedTransactions(unscannedTxs []*openwallet.UnscanRecord) ([]BlockTransaction, error)
func (*WalletManager) SaveERC20TokenConfig ¶
func (this *WalletManager) SaveERC20TokenConfig(config *ERC20Token) error
func (*WalletManager) SendTransactionToAddr ¶
func (this *WalletManager) SendTransactionToAddr(param map[string]interface{}) (string, error)
func (*WalletManager) UnlockWallet ¶
func (this *WalletManager) UnlockWallet(wallet *Wallet, password string) error
func (*WalletManager) WscSendRawTransaction ¶
func (this *WalletManager) WscSendRawTransaction(signedTx string) (string, error)
type WscBlock ¶
type WscBlock struct { BlockHeader Transactions []BlockTransaction `json:"transactions"` }
func (*WscBlock) CreateOpenWalletBlockHeader ¶
func (this *WscBlock) CreateOpenWalletBlockHeader() *openwallet.BlockHeader
type WscTransactionDecoder ¶
type WscTransactionDecoder struct { openwallet.TransactionDecoderBase AddrTxStatisMap *sync.Map // contains filtered or unexported fields }
func NewTransactionDecoder ¶
func NewTransactionDecoder(wm *WalletManager) *WscTransactionDecoder
NewTransactionDecoder 交易单解析器
func (*WscTransactionDecoder) CreateErc20TokenRawTransaction ¶
func (this *WscTransactionDecoder) CreateErc20TokenRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
func (*WscTransactionDecoder) CreateErc20TokenSummaryRawTransaction ¶
func (this *WscTransactionDecoder) CreateErc20TokenSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateErc20TokenSummaryRawTransaction 创建ERC20Token汇总交易
func (*WscTransactionDecoder) CreateRawTransaction ¶
func (this *WscTransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
CreateRawTransaction 创建交易单
func (*WscTransactionDecoder) CreateSimpleRawTransaction ¶
func (this *WscTransactionDecoder) CreateSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction, tmpNonce *uint64) error
func (*WscTransactionDecoder) CreateSimpleSummaryRawTransaction ¶
func (this *WscTransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateSimpleSummaryRawTransaction 创建ETH汇总交易
func (*WscTransactionDecoder) CreateSummaryRawTransaction ¶
func (this *WscTransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
CreateSummaryRawTransaction 创建汇总交易,返回原始交易单数组
func (*WscTransactionDecoder) CreateSummaryRawTransactionWithError ¶
func (this *WscTransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateSummaryRawTransactionWithError 创建汇总交易,返回能原始交易单数组(包含带错误的原始交易单)
func (*WscTransactionDecoder) GetRawTransactionFeeRate ¶
func (this *WscTransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)
func (*WscTransactionDecoder) GetTransactionCount ¶
func (this *WscTransactionDecoder) GetTransactionCount(address string) (uint64, error)
func (*WscTransactionDecoder) GetTransactionCount2 ¶
func (this *WscTransactionDecoder) GetTransactionCount2(address string) (*AddressTxStatistic, uint64, error)
func (*WscTransactionDecoder) RemoveOutdatedAddrStatic ¶
func (this *WscTransactionDecoder) RemoveOutdatedAddrStatic()
func (*WscTransactionDecoder) RunClearAddrStatic ¶
func (this *WscTransactionDecoder) RunClearAddrStatic()
func (*WscTransactionDecoder) SetTransactionCount ¶
func (this *WscTransactionDecoder) SetTransactionCount(address string, transactionCount uint64) error
func (*WscTransactionDecoder) SignRawTransaction ¶
func (this *WscTransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
SignRawTransaction 签名交易单
func (*WscTransactionDecoder) SubmitErc20TokenRawTransaction ¶
func (this *WscTransactionDecoder) SubmitErc20TokenRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
func (*WscTransactionDecoder) SubmitRawTransaction ¶
func (this *WscTransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
SendRawTransaction 广播交易单
func (*WscTransactionDecoder) SubmitSimpleRawTransaction ¶
func (this *WscTransactionDecoder) SubmitSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
func (*WscTransactionDecoder) VerifyRawTransaction ¶
func (this *WscTransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单