ethercoin

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Overview

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

* 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

View Source
const (
	//	BLOCK_CHAIN_DB     = "blockchain.db"
	BLOCK_CHAIN_BUCKET = "blockchain"
	ERC20TOKEN_DB      = "erc20Token.db"
)
View Source
const (
	Symbol       = "ETE"
	MasterKey    = "Ethercoin seed"
	TIME_POSTFIX = "20060102150405"
	CurveType    = owcrypt.ECC_CURVE_SECP256K1
)
View Source
const (
	ETE_GET_TOKEN_BALANCE_METHOD      = "0x70a08231"
	ETE_TRANSFER_TOKEN_BALANCE_METHOD = "0xa9059cbb"
	ETE_TRANSFER_EVENT_ID             = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
)
View Source
const (
	SOLIDITY_TYPE_ADDRESS = "address"
	SOLIDITY_TYPE_UINT256 = "uint256"
	SOLIDITY_TYPE_UINT160 = "uint160"
)
View Source
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
)
View Source
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
)
View Source
const (
	ADRESS_STATIS_OVERDATED_TIME = 30
)
View Source
const (
	//BLOCK_CHAIN_BUCKET = "blockchain" //区块链数据集合
	//periodOfTask      = 5 * time.Second //定时任务执行隔间
	MAX_EXTRACTING_SIZE = 15 //并发的扫描线程数

)

Variables

This section is empty.

Functions

func AppendOxToAddress

func AppendOxToAddress(addr string) string

func ConverEthDecimalToWei

func ConverEthDecimalToWei(amount decimal.Decimal) (*big.Int, error)

func ConverWeiStringToEthDecimal

func ConverWeiStringToEthDecimal(amount string) (decimal.Decimal, error)

func ConvertAmountToFloatDecimal

func ConvertAmountToFloatDecimal(amount string, decimals int) (decimal.Decimal, error)

func ConvertEthStringToWei

func ConvertEthStringToWei(amount string) (*big.Int, error)

func ConvertFloatStringToBigInt

func ConvertFloatStringToBigInt(amount string, decimals int) (*big.Int, error)

func ConvertToBigInt

func ConvertToBigInt(value string, base int) (*big.Int, error)

func ConvertToUint64

func ConvertToUint64(value string, base int) (uint64, error)

func OpenDB

func OpenDB(dbPath string, dbName string) (*storm.DB, error)

func VerifyRawTransaction

func VerifyRawTransaction(rawTx *openwallet.RawTransaction) error

Types

type AddrBalance

type AddrBalance struct {
	Address      string
	Balance      *big.Int
	TokenBalance *big.Int
	Index        int
}

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 AddrBalanceInf interface {
	SetTokenBalance(b *big.Int)
	GetAddress() string
	ValidTokenBalance() bool
}

type AddrVec

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

func (*AddrVec) Len

func (this *AddrVec) Len() int

func (*AddrVec) Less

func (this *AddrVec) Less(i, j int) bool

func (*AddrVec) Swap

func (this *AddrVec) Swap(i, j int)

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的时候进行初始化
}

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

type Client struct {
	BaseURL string
	Debug   bool
}

func (*Client) Call

func (c *Client) Call(method string, id int64, params []interface{}) (*gjson.Result, error)

func (*Client) ERC20GetAddressBalance

func (this *Client) ERC20GetAddressBalance(address string, contractAddr string) (*big.Int, error)

func (*Client) ERC20GetAddressBalance2

func (this *Client) ERC20GetAddressBalance2(address string, contractAddr string, sign string) (*big.Int, error)

func (*Client) EthGetBlockNumber

func (this *Client) EthGetBlockNumber() (uint64, error)

func (*Client) EthGetBlockSpecByBlockNum

func (this *Client) EthGetBlockSpecByBlockNum(blockNum uint64, showTransactionSpec bool) (*EthBlock, error)

func (*Client) EthGetTransactionByHash

func (this *Client) EthGetTransactionByHash(txid string) (*BlockTransaction, error)

func (*Client) EthGetTransactionReceipt

func (this *Client) EthGetTransactionReceipt(transactionId string) (*EthTransactionReceipt, error)

func (*Client) EthGetTxPoolContent

func (this *Client) EthGetTxPoolContent() (*TxpoolContent, error)

func (*Client) GetAddrBalance2

func (this *Client) GetAddrBalance2(address string, sign string) (*big.Int, error)

func (*Client) LockAddr

func (this *Client) LockAddr(address string) error

func (*Client) UnlockAddr

func (this *Client) UnlockAddr(address string, password string, secs int) error

type ERC20Token

type ERC20Token struct {
	Address  string `json:"address" storm:"id"`
	Symbol   string `json:"symbol" storm:"index"`
	Name     string `json:"name"`
	Decimals int    `json:"decimals"`
	// contains filtered or unexported fields
}

type ETEBLockScanner

type ETEBLockScanner struct {
	*openwallet.BlockScannerBase
	CurrentBlockHeight uint64 //当前区块高度

	IsScanMemPool        bool   //是否扫描交易池
	RescanLastBlockCount uint64 //重扫上N个区块数量
	// contains filtered or unexported fields
}

func NewETEBlockScanner

func NewETEBlockScanner(wm *WalletManager) *ETEBLockScanner

NewBTCBlockScanner 创建区块链扫描器

func (*ETEBLockScanner) BatchExtractTransaction

func (this *ETEBLockScanner) BatchExtractTransaction(txs []BlockTransaction) error

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

func (*ETEBLockScanner) DeleteUnscanRecord

func (bs *ETEBLockScanner) DeleteUnscanRecord(height uint64) error

DeleteUnscanRecord 删除指定高度的未扫记录

func (*ETEBLockScanner) DeleteUnscanRecordByID

func (bs *ETEBLockScanner) DeleteUnscanRecordByID(id string) error

DeleteUnscanRecordByID 删除指定的未扫记录

func (*ETEBLockScanner) ExtractTransactionData

func (this *ETEBLockScanner) ExtractTransactionData(txid string, scanTargetFunc openwallet.BlockScanTargetFunc) (map[string][]*openwallet.TxExtractData, error)

ExtractTransactionData 扫描一笔交易

func (*ETEBLockScanner) GetBalanceByAddress

func (this *ETEBLockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)

func (*ETEBLockScanner) GetCurrentBlockHeader

func (this *ETEBLockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)

GetCurrentBlockHeader 获取当前区块高度

func (*ETEBLockScanner) GetGlobalMaxBlockHeight

func (this *ETEBLockScanner) GetGlobalMaxBlockHeight() uint64

func (*ETEBLockScanner) GetLocalBlock

func (bs *ETEBLockScanner) GetLocalBlock(height uint64) (*EthBlock, error)

GetLocalBlock 获取本地区块数据

func (*ETEBLockScanner) GetLocalBlockHead

func (bs *ETEBLockScanner) GetLocalBlockHead() (uint64, string, error)

GetLocalBlockHead 获取本地记录的区块高度和hash

func (*ETEBLockScanner) GetLocalNewBlock

func (this *ETEBLockScanner) GetLocalNewBlock() (uint64, string, error)

GetLocalNewBlock 获取本地记录的区块高度和hash

func (*ETEBLockScanner) GetScannedBlockHeader

func (this *ETEBLockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)

GetScannedBlockHeader 获取当前已扫区块高度

func (*ETEBLockScanner) GetScannedBlockHeight

func (this *ETEBLockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*ETEBLockScanner) GetTxPoolPendingTxs

func (this *ETEBLockScanner) GetTxPoolPendingTxs() ([]BlockTransaction, error)

func (*ETEBLockScanner) GetUnscanRecords

func (bs *ETEBLockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)

func (*ETEBLockScanner) MakeFromExtractData

func (this *ETEBLockScanner) MakeFromExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)

func (*ETEBLockScanner) MakeSimpleToExtractData

func (this *ETEBLockScanner) MakeSimpleToExtractData(tx *BlockTransaction) (string, []*openwallet.TxExtractData, error)

func (*ETEBLockScanner) MakeSimpleTxFromExtractData

func (this *ETEBLockScanner) MakeSimpleTxFromExtractData(tx *BlockTransaction) (string, []*openwallet.TxExtractData, error)

func (*ETEBLockScanner) MakeToExtractData

func (this *ETEBLockScanner) MakeToExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)

func (*ETEBLockScanner) MakeTokenToExtractData

func (this *ETEBLockScanner) MakeTokenToExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)

func (*ETEBLockScanner) MakeTokenTxFromExtractData

func (this *ETEBLockScanner) MakeTokenTxFromExtractData(tx *BlockTransaction, tokenEvent *TransferEvent) (string, []*openwallet.TxExtractData, error)

func (*ETEBLockScanner) RescanFailedTransactions

func (this *ETEBLockScanner) RescanFailedTransactions() error

func (*ETEBLockScanner) SaveLocalBlock

func (bs *ETEBLockScanner) SaveLocalBlock(blockHeader *EthBlock) error

SaveLocalBlock 记录本地新区块

func (*ETEBLockScanner) SaveLocalBlockHead

func (bs *ETEBLockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error

SaveLocalBlockHead 记录区块高度和hash到本地

func (*ETEBLockScanner) SaveUnscanRecord

func (bs *ETEBLockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error

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

func (*ETEBLockScanner) SaveUnscannedTransaction

func (this *ETEBLockScanner) SaveUnscannedTransaction(tx *BlockTransaction, reason string) error

func (*ETEBLockScanner) ScanBlock

func (this *ETEBLockScanner) ScanBlock(height uint64) error

func (*ETEBLockScanner) ScanBlockTask

func (this *ETEBLockScanner) ScanBlockTask()

func (*ETEBLockScanner) ScanTxMemPool

func (this *ETEBLockScanner) ScanTxMemPool() error

func (*ETEBLockScanner) SetRescanBlockHeight

func (this *ETEBLockScanner) SetRescanBlockHeight(height uint64) error

SetRescanBlockHeight 重置区块链扫描高度

func (*ETEBLockScanner) SupportBlockchainDAI

func (bs *ETEBLockScanner) SupportBlockchainDAI() bool

SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional

func (*ETEBLockScanner) TransactionScanning

func (this *ETEBLockScanner) TransactionScanning(tx *BlockTransaction) (*ExtractResult, error)

func (*ETEBLockScanner) UpdateTxByReceipt

func (this *ETEBLockScanner) UpdateTxByReceipt(tx *BlockTransaction) (map[string][]*TransferEvent, error)

type EthBlock

type EthBlock struct {
	BlockHeader
	Transactions []BlockTransaction `json:"transactions"`
}

func (*EthBlock) CreateOpenWalletBlockHeader

func (this *EthBlock) CreateOpenWalletBlockHeader() *openwallet.BlockHeader

func (*EthBlock) Init

func (this *EthBlock) Init() error

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 EthEvent

type EthEvent struct {
	Address string   `json:"address"`
	Topics  []string `json:"topics"`
	Data    string   `josn:"data"`
	//BlockNumber string
	LogIndex string `json:"logIndex"`
	Removed  bool   `json:"removed"`
}

type EthTransactionDecoder

type EthTransactionDecoder struct {
	openwallet.TransactionDecoderBase
	AddrTxStatisMap *sync.Map
	// contains filtered or unexported fields
}

func NewTransactionDecoder

func NewTransactionDecoder(wm *WalletManager) *EthTransactionDecoder

NewTransactionDecoder 交易单解析器

func (*EthTransactionDecoder) CreateErc20TokenRawTransaction

func (this *EthTransactionDecoder) CreateErc20TokenRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

func (*EthTransactionDecoder) CreateErc20TokenSummaryRawTransaction

func (this *EthTransactionDecoder) CreateErc20TokenSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)

CreateErc20TokenSummaryRawTransaction 创建ERC20Token汇总交易

func (*EthTransactionDecoder) CreateRawTransaction

func (this *EthTransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

CreateRawTransaction 创建交易单

func (*EthTransactionDecoder) CreateSimpleRawTransaction

func (this *EthTransactionDecoder) CreateSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction, tmpNonce *uint64) error

func (*EthTransactionDecoder) CreateSimpleSummaryRawTransaction

func (this *EthTransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)

CreateSimpleSummaryRawTransaction 创建ETE汇总交易

func (*EthTransactionDecoder) CreateSummaryRawTransaction

func (this *EthTransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)

CreateSummaryRawTransaction 创建汇总交易,返回原始交易单数组

func (*EthTransactionDecoder) CreateSummaryRawTransactionWithError

func (this *EthTransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)

CreateSummaryRawTransactionWithError 创建汇总交易,返回能原始交易单数组(包含带错误的原始交易单)

func (*EthTransactionDecoder) GetRawTransactionFeeRate

func (this *EthTransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)

func (*EthTransactionDecoder) GetTransactionCount

func (this *EthTransactionDecoder) GetTransactionCount(address string) (uint64, error)

func (*EthTransactionDecoder) GetTransactionCount2

func (this *EthTransactionDecoder) GetTransactionCount2(address string) (*AddressTxStatistic, uint64, error)

func (*EthTransactionDecoder) RemoveOutdatedAddrStatic

func (this *EthTransactionDecoder) RemoveOutdatedAddrStatic()

func (*EthTransactionDecoder) RunClearAddrStatic

func (this *EthTransactionDecoder) RunClearAddrStatic()

func (*EthTransactionDecoder) SetTransactionCount

func (this *EthTransactionDecoder) SetTransactionCount(address string, transactionCount uint64) error

func (*EthTransactionDecoder) SignRawTransaction

func (this *EthTransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

SignRawTransaction 签名交易单

func (*EthTransactionDecoder) SubmitErc20TokenRawTransaction

func (this *EthTransactionDecoder) SubmitErc20TokenRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)

func (*EthTransactionDecoder) SubmitRawTransaction

func (this *EthTransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)

SendRawTransaction 广播交易单

func (*EthTransactionDecoder) SubmitSimpleRawTransaction

func (this *EthTransactionDecoder) SubmitSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)

func (*EthTransactionDecoder) VerifyRawTransaction

func (this *EthTransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单

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

type EthTxExtPara struct {
	Data     string `json:"data"`
	GasLimit string `json:"gasLimit"`
}

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 Response

type Response struct {
	Id      int         `json:"id"`
	Version string      `json:"jsonrpc"`
	Result  interface{} `json:"result"`
}

type SaveResult

type SaveResult struct {
	TxID        string
	BlockHeight uint64
	Success     bool
}

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 TransferEvent struct {
	ContractAddress string
	TokenFrom       string
	TokenTo         string
	Value           string
}

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

func (this *TxpoolContent) GetSequentTxNonce(addr string) (uint64, uint64, uint64, 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 GetWalletKey(fileWitoutProfix string) (*Wallet, error)

func GetWalletKeys

func GetWalletKeys(dir string) ([]*Wallet, error)

func (*Wallet) ClearAllTransactions

func (this *Wallet) ClearAllTransactions(dbPath string)

func (*Wallet) DBFile

func (w *Wallet) DBFile(dbPath string) string

DBFile 数据库文件

func (*Wallet) DeleteTransactionByHeight

func (this *Wallet) DeleteTransactionByHeight(dbPath string, height uint64) error

func (*Wallet) DumpWalletDB

func (this *Wallet) DumpWalletDB(dbPath string)

func (*Wallet) FileName

func (w *Wallet) FileName() string

FileName 该钱包定义的文件名规则

func (*Wallet) HDKey2

func (this *Wallet) HDKey2(password string) (*hdkeystore.HDKey, error)

HDKey 获取钱包密钥,需要密码

func (*Wallet) OpenDB

func (w *Wallet) OpenDB(dbPath string) (*storm.DB, error)

openDB 打开钱包数据库

func (*Wallet) OpenDbByPath

func (w *Wallet) OpenDbByPath(path string) (*storm.DB, error)

func (*Wallet) RestoreFromDb

func (this *Wallet) RestoreFromDb(dbPath string) error

func (*Wallet) SaveAddress

func (this *Wallet) SaveAddress(dbpath string, addr *Address) error

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:"-"`
	EthercoinKeyPath 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 (this *WalletManager) BackupWallet2(newBackupDir string, wallet *Wallet,
	password string) (string, error)

func (*WalletManager) BackupWalletToDefaultPath

func (this *WalletManager) BackupWalletToDefaultPath(wallet *Wallet, password string) (string, error)

func (*WalletManager) CreateWallet

func (this *WalletManager) CreateWallet(name string, password string) (*Wallet, string, error)

func (*WalletManager) CurveType

func (this *WalletManager) CurveType() uint32

CurveType 曲线类型

func (*WalletManager) Decimal

func (this *WalletManager) Decimal() int32

小数位精度

func (*WalletManager) EthSendRawTransaction

func (this *WalletManager) EthSendRawTransaction(signedTx string) (string, error)

func (*WalletManager) FullName

func (this *WalletManager) FullName() string

FullName 币种全名

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 (this *WalletManager) GetSimpleTransactionFeeEstimated(from string, to string, amount *big.Int) (*txFeeInfo, error)

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 (this *WalletManager) GetTransactionFeeEstimated(from string, to string, value *big.Int, data string) (*txFeeInfo, error)

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

func (this *WalletManager) InitConfig()

initConfig 初始化配置文件

func (*WalletManager) InitConfigFlow

func (this *WalletManager) InitConfigFlow() error

初始化配置流程

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

func (wm *WalletManager) ShowConfig() error

查看配置信息

func (*WalletManager) Symbol

func (this *WalletManager) Symbol() string

SymbolID 币种标识

func (*WalletManager) UnlockWallet

func (this *WalletManager) UnlockWallet(wallet *Wallet, password string) error

Jump to

Keyboard shortcuts

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