keytoken

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: GPL-3.0 Imports: 32 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 (
	KTOPrefix = "Kto"
	KTOLen    = 47
)
View Source
const (
	Symbol       = "NKTO"
	MasterKey    = "KeyToken seed"
	TIME_POSTFIX = "20060102150405"
	CurveType    = owcrypt.ECC_CURVE_ED25519
)
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"
)
View Source
const (
	Decimals = 11
)

1KTO = 100000000000

View Source
const (
	//BLOCK_CHAIN_BUCKET = "blockchain" //区块链数据集合
	//periodOfTask      = 5 * time.Second //定时任务执行隔间
	MAX_EXTRACTING_SIZE = 20 //并发的扫描线程数
)

Variables

View Source
var (
	KTO_mainnetAddressP2PKH = addressEncoder.AddressType{"base58", addressEncoder.BTCAlphabet, "doubleSHA256", "h160", 20, []byte{0x3f}, nil}
)

Functions

func ConverKStringToKtoDecimal

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

将最小单位的余额转换为 KTO 单位 接收 string 参数

func ConverKtoDecimalToK

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

将 KTO 转换为最小单位的值 接收 decimal 参数

func ConvertAmountToFloatDecimal

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

最小单位余额转换为 KTO 单位

func ConvertFloatStringToBigInt

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

将 KTO 转换为最小单位

func ConvertKTOStringToK

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

将 KTO 转换为最小单位

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

func NewBlockHeader

func NewBlockHeader(msg *message.RespBlock) *BlockHeader

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 ParseToBlockTransaction

func ParseToBlockTransaction(msg *message.RespTxByHash) *BlockTransaction

func ParseToBlockTransactions

func ParseToBlockTransactions(msg *message.RespBlock) []BlockTransaction

func (*BlockTransaction) GetAmountEthString

func (this *BlockTransaction) GetAmountEthString() (string, error)

func (*BlockTransaction) GetTxFeeEthString

func (this *BlockTransaction) GetTxFeeEthString() (string, error)

type Client

type Client struct {
	Debug         bool
	GreeterClient message.GreeterClient
}

func (*Client) GetAddrBalance

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

获取地址余额

func (*Client) GetMaxBlockNumber

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

获取链上最大区块号

func (*Client) GetTxByHash

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

以txid获取交易详情

func (*Client) KtoGetBlockByNum

func (this *Client) KtoGetBlockByNum(blockNum uint64) (*KtoBlock, 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 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 KTOBLockScanner

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

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

func NewKTOBlockScanner added in v1.0.2

func NewKTOBlockScanner(wm *WalletManager) *KTOBLockScanner

NewBTCBlockScanner 创建区块链扫描器

func (*KTOBLockScanner) BatchExtractTransaction

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

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

func (*KTOBLockScanner) DeleteUnscanRecord

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

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

func (*KTOBLockScanner) DeleteUnscanRecordByID

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

DeleteUnscanRecordByID 删除指定的未扫记录

func (*KTOBLockScanner) ExtractTransactionData

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

ExtractTransactionData 扫描一笔交易

func (*KTOBLockScanner) GetBalanceByAddress

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

func (*KTOBLockScanner) GetCurrentBlockHeader

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

GetCurrentBlockHeader 获取当前区块高度

func (*KTOBLockScanner) GetGlobalMaxBlockHeight

func (this *KTOBLockScanner) GetGlobalMaxBlockHeight() uint64

func (*KTOBLockScanner) GetLocalBlock

func (bs *KTOBLockScanner) GetLocalBlock(height uint64) (*KtoBlock, error)

GetLocalBlock 获取本地区块数据

func (*KTOBLockScanner) GetLocalBlockHead

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

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

func (*KTOBLockScanner) GetLocalNewBlock

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

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

func (*KTOBLockScanner) GetScannedBlockHeader

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

GetScannedBlockHeader 获取当前已扫区块高度

func (*KTOBLockScanner) GetScannedBlockHeight

func (this *KTOBLockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*KTOBLockScanner) GetUnscanRecords

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

func (*KTOBLockScanner) MakeFromExtractData

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

func (*KTOBLockScanner) MakeSimpleToExtractData

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

func (*KTOBLockScanner) MakeSimpleTxFromExtractData

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

func (*KTOBLockScanner) MakeToExtractData

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

func (*KTOBLockScanner) MakeTokenToExtractData

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

func (*KTOBLockScanner) MakeTokenTxFromExtractData

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

func (*KTOBLockScanner) RescanFailedTransactions

func (this *KTOBLockScanner) RescanFailedTransactions() error

func (*KTOBLockScanner) SaveLocalBlock

func (bs *KTOBLockScanner) SaveLocalBlock(blockHeader *KtoBlock) error

SaveLocalBlock 记录本地新区块

func (*KTOBLockScanner) SaveLocalBlockHead

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

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

func (*KTOBLockScanner) SaveUnscanRecord

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

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

func (*KTOBLockScanner) SaveUnscannedTransaction

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

func (*KTOBLockScanner) ScanBlock

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

func (*KTOBLockScanner) ScanBlockTask

func (this *KTOBLockScanner) ScanBlockTask()

func (*KTOBLockScanner) SetRescanBlockHeight

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

SetRescanBlockHeight 重置区块链扫描高度

func (*KTOBLockScanner) SupportBlockchainDAI

func (bs *KTOBLockScanner) SupportBlockchainDAI() bool

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

func (*KTOBLockScanner) TransactionScanning

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

type KtoBlock added in v1.1.0

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

func (*KtoBlock) CreateOpenWalletBlockHeader added in v1.1.0

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

func (*KtoBlock) Init added in v1.1.0

func (this *KtoBlock) Init() error

type KtoEvent added in v1.1.0

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

type KtoTransactionDecoder added in v1.0.2

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

func NewTransactionDecoder

func NewTransactionDecoder(wm *WalletManager) *KtoTransactionDecoder

NewTransactionDecoder 交易单解析器

func (*KtoTransactionDecoder) CreateRawTransaction added in v1.0.2

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

CreateRawTransaction 创建交易单

func (*KtoTransactionDecoder) CreateSimpleRawTransaction added in v1.0.2

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

func (*KtoTransactionDecoder) CreateSimpleSummaryRawTransaction added in v1.0.2

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

CreateSimpleSummaryRawTransaction 创建ETH汇总交易

func (*KtoTransactionDecoder) CreateSummaryRawTransaction added in v1.0.2

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

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

func (*KtoTransactionDecoder) CreateSummaryRawTransactionWithError added in v1.0.2

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

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

func (*KtoTransactionDecoder) GetRawTransactionFeeRate added in v1.0.2

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

func (*KtoTransactionDecoder) GetTransactionCount added in v1.0.2

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

func (*KtoTransactionDecoder) GetTransactionCount2 added in v1.0.2

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

func (*KtoTransactionDecoder) RemoveOutdatedAddrStatic added in v1.0.2

func (this *KtoTransactionDecoder) RemoveOutdatedAddrStatic()

func (*KtoTransactionDecoder) RunClearAddrStatic added in v1.0.2

func (this *KtoTransactionDecoder) RunClearAddrStatic()

func (*KtoTransactionDecoder) SetTransactionCount added in v1.0.2

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

func (*KtoTransactionDecoder) SignRawTransaction added in v1.0.2

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

SignRawTransaction 签名交易单

func (*KtoTransactionDecoder) SubmitRawTransaction added in v1.0.2

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

SendRawTransaction 广播交易单

func (*KtoTransactionDecoder) SubmitSimpleRawTransaction added in v1.0.2

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

func (*KtoTransactionDecoder) VerifyRawTransaction added in v1.0.2

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

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

type KtoTransactionReceipt added in v1.1.0

type KtoTransactionReceipt struct {
	Logs    []KtoEvent `json:"logs"`
	GasUsed string     `json:"gasUsed"`
	Status  string     `json:"status"`
}

func (*KtoTransactionReceipt) ParseTransferEvent added in v1.1.0

func (this *KtoTransactionReceipt) ParseTransferEvent() map[string][]*TransferEvent

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 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
	ServerRpcUrl 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) 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) GetERC20TokenTransactionFeeEstimated

func (this *WalletManager) GetERC20TokenTransactionFeeEstimated(from string, to string, data string) (*txFeeInfo, 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) 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) KtoSendRawTransaction

func (this *WalletManager) KtoSendRawTransaction(from, to string, amount, nonce uint64, time int64, hash, signature []byte) (string, 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) 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