filememory

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: GPL-3.0 Imports: 37 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 (
	TOKEN_KEY      = "G^h#9f&P@u3[r%H$6a@Mc$5"
	API_PUBLIC_KEY = "" /* 389-byte string literal not displayed */
)
View Source
const (
	Symbol       = "FM"
	MasterKey    = "FileMemory seed"
	TIME_POSTFIX = "20060102150405"
	CurveType    = owcrypt.ECC_CURVE_SECP256K1
)
View Source
const (
	ETH_GET_TOKEN_BALANCE_METHOD      = "0x70a08231"
	ETH_TRANSFER_TOKEN_BALANCE_METHOD = "0xa9059cbb"
	ETH_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 Append0xToAddress added in v1.0.5

func Append0xToAddress(addr string) string

func AppendFMToAddress added in v1.0.5

func AppendFMToAddress(addr string) string

func ConverFMDecimalToFM added in v1.0.4

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

func ConverFmStringToFMDecimal added in v1.0.4

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

func ConvertAmountToFloatDecimal

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

func ConvertFMStringToWei added in v1.0.4

func ConvertFMStringToWei(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 GenToken

func GenToken(time int64) string

获取接口 Token

func OpenDB

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

func RsaEncryptionData

func RsaEncryptionData(data string) (string, error)

rsa 加密数据

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 {
	Status      bool   `json:"status"`
	Nonce       uint   `json:"nonce"`
	BlockNumber uint64 `json:"blockNumber" storm:"index"`
	Hash        string `json:"hash"`
	BlockHash   string `json:"blockHash" storm:"index"`
	From        string `json:"from"`
	To          string `json:"to"`
	Value       string `json:"value"`
	Timestamp   uint64 `json:"timestamp"`
	BlockHeight uint64 //transaction scanning 的时候对其进行赋值
	FilterFunc  openwallet.BlockScanAddressFunc
}

func (*BlockTransaction) GetAmountEthString

func (this *BlockTransaction) GetAmountEthString() (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) EthGetBlockSpecByBlockNum

func (this *Client) EthGetBlockSpecByBlockNum(blockNum uint64, showTransactionSpec bool) (*FMBlock, 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) FMCall

func (c *Client) FMCall(method string, body map[string]interface{}) (*gjson.Result, error)

func (*Client) FMGetBlockNumber

func (this *Client) FMGetBlockNumber() (uint64, 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 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 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 FMBLockScanner added in v1.0.2

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

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

func NewETHBlockScanner

func NewETHBlockScanner(wm *WalletManager) *FMBLockScanner

NewBTCBlockScanner 创建区块链扫描器

func (*FMBLockScanner) BatchExtractTransaction added in v1.0.2

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

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

func (*FMBLockScanner) DeleteUnscanRecord added in v1.0.2

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

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

func (*FMBLockScanner) DeleteUnscanRecordByID added in v1.0.2

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

DeleteUnscanRecordByID 删除指定的未扫记录

func (*FMBLockScanner) ExtractTransactionData added in v1.0.2

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

ExtractTransactionData 扫描一笔交易

func (*FMBLockScanner) GetBalanceByAddress added in v1.0.2

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

func (*FMBLockScanner) GetCurrentBlockHeader added in v1.0.2

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

GetCurrentBlockHeader 获取当前区块高度

func (*FMBLockScanner) GetGlobalMaxBlockHeight added in v1.0.2

func (this *FMBLockScanner) GetGlobalMaxBlockHeight() uint64

func (*FMBLockScanner) GetLocalBlock added in v1.0.2

func (bs *FMBLockScanner) GetLocalBlock(height uint64) (*FMBlock, error)

GetLocalBlock 获取本地区块数据

func (*FMBLockScanner) GetLocalBlockHead added in v1.0.2

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

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

func (*FMBLockScanner) GetLocalNewBlock added in v1.0.2

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

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

func (*FMBLockScanner) GetScannedBlockHeader added in v1.0.2

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

GetScannedBlockHeader 获取当前已扫区块高度

func (*FMBLockScanner) GetScannedBlockHeight added in v1.0.2

func (this *FMBLockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*FMBLockScanner) GetTxPoolPendingTxs added in v1.0.2

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

func (*FMBLockScanner) GetUnscanRecords added in v1.0.2

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

func (*FMBLockScanner) MakeFromExtractData added in v1.0.2

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

func (*FMBLockScanner) MakeSimpleToExtractData added in v1.0.2

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

func (*FMBLockScanner) MakeSimpleTxFromExtractData added in v1.0.2

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

func (*FMBLockScanner) MakeToExtractData added in v1.0.2

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

func (*FMBLockScanner) MakeTokenToExtractData added in v1.0.2

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

func (*FMBLockScanner) MakeTokenTxFromExtractData added in v1.0.2

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

func (*FMBLockScanner) RescanFailedTransactions added in v1.0.2

func (this *FMBLockScanner) RescanFailedTransactions() error

func (*FMBLockScanner) SaveLocalBlock added in v1.0.2

func (bs *FMBLockScanner) SaveLocalBlock(blockHeader *FMBlock) error

SaveLocalBlock 记录本地新区块

func (*FMBLockScanner) SaveLocalBlockHead added in v1.0.2

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

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

func (*FMBLockScanner) SaveUnscanRecord added in v1.0.2

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

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

func (*FMBLockScanner) SaveUnscannedTransaction added in v1.0.2

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

func (*FMBLockScanner) ScanBlock added in v1.0.2

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

func (*FMBLockScanner) ScanBlockTask added in v1.0.2

func (this *FMBLockScanner) ScanBlockTask()

func (*FMBLockScanner) ScanTxMemPool added in v1.0.2

func (this *FMBLockScanner) ScanTxMemPool() error

func (*FMBLockScanner) SetRescanBlockHeight added in v1.0.2

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

SetRescanBlockHeight 重置区块链扫描高度

func (*FMBLockScanner) SupportBlockchainDAI added in v1.0.2

func (bs *FMBLockScanner) SupportBlockchainDAI() bool

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

func (*FMBLockScanner) TransactionScanning added in v1.0.2

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

type FMBlock

type FMBlock struct {
	BlockHeader
	Transactions []BlockTransaction `json:"list"`
}

func (*FMBlock) CreateOpenWalletBlockHeader

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

func (*FMBlock) Init

func (this *FMBlock) Init() error

type FMTransactionDecoder added in v1.0.4

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

func NewTransactionDecoder

func NewTransactionDecoder(wm *WalletManager) *FMTransactionDecoder

NewTransactionDecoder 交易单解析器

func (*FMTransactionDecoder) CreateErc20TokenRawTransaction added in v1.0.4

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

func (*FMTransactionDecoder) CreateErc20TokenSummaryRawTransaction added in v1.0.4

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

CreateErc20TokenSummaryRawTransaction 创建ERC20Token汇总交易

func (*FMTransactionDecoder) CreateRawTransaction added in v1.0.4

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

CreateRawTransaction 创建交易单

func (*FMTransactionDecoder) CreateSimpleRawTransaction added in v1.0.4

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

func (*FMTransactionDecoder) CreateSimpleSummaryRawTransaction added in v1.0.4

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

CreateSimpleSummaryRawTransaction 创建FM汇总交易

func (*FMTransactionDecoder) CreateSummaryRawTransaction added in v1.0.4

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

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

func (*FMTransactionDecoder) CreateSummaryRawTransactionWithError added in v1.0.4

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

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

func (*FMTransactionDecoder) GetRawTransactionFeeRate added in v1.0.4

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

func (*FMTransactionDecoder) GetTransactionCount added in v1.0.4

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

func (*FMTransactionDecoder) GetTransactionCount2 added in v1.0.4

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

func (*FMTransactionDecoder) RemoveOutdatedAddrStatic added in v1.0.4

func (this *FMTransactionDecoder) RemoveOutdatedAddrStatic()

func (*FMTransactionDecoder) RunClearAddrStatic added in v1.0.4

func (this *FMTransactionDecoder) RunClearAddrStatic()

func (*FMTransactionDecoder) SetTransactionCount added in v1.0.4

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

func (*FMTransactionDecoder) SignRawTransaction added in v1.0.4

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

SignRawTransaction 签名交易单

func (*FMTransactionDecoder) SubmitErc20TokenRawTransaction added in v1.0.4

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

func (*FMTransactionDecoder) SubmitRawTransaction added in v1.0.4

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

SendRawTransaction 广播交易单

func (*FMTransactionDecoder) SubmitSimpleRawTransaction added in v1.0.4

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

func (*FMTransactionDecoder) VerifyRawTransaction added in v1.0.4

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

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

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:"-"`
	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 (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