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 * decoder file is part of the openwallet library. * * The openwallet library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The openwallet library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details.
Index ¶
- Constants
- Variables
- func CheckIsContract(Toaddr string) bool
- func CheckRawTransaction(rawTx *openwallet.RawTransaction) error
- func ConverWeiStringToNasDecimal(amount string) (decimal.Decimal, error)
- func ConvertNasStringToWei(amount string) (*big.Int, error)
- func ConvertToBigInt(value string) (*big.Int, error)
- func EncodeToTransactionRawHex(submit_tx *SubmitTransaction) (string, error)
- func EncodeTransaction(submit_tx *SubmitTransaction) (string, error)
- func NasAddrTobyte(addr string) ([]byte, error)
- func NewAddressDecoder(wm *WalletManager) *addressDecoder
- func NotenonceInDB(addr string, db *storm.DB) error
- func SignRawTransaction(PrivateKey []byte, txhash []byte) ([]byte, error)
- func SortAddrFromBalance(MixAddr []*openwallet.Address) []*openwallet.Address
- func VerifyRawTransaction(PubKey []byte, txhash []byte, signed []byte) uint16
- type AddrBalance
- type Block
- type BlockchainInfo
- type Client
- func (c *Client) CallGetGasPrice() string
- func (c *Client) CallGetTransactionReceipt(txid string) (*gjson.Result, error)
- func (c *Client) CallGetaccountstate(address string, query string) (string, error)
- func (c *Client) CallGetestimateGas(parameter *estimateGasParameter) (*gjson.Result, error)
- func (c *Client) CallGetnebstate(query string) (*gjson.Result, error)
- func (c *Client) CallGetsubscribe() (*gjson.Result, error)
- func (c *Client) CallSendRawTransaction(data string) (string, error)
- func (c *Client) CallgetBlockByHeightOrHash(input string, heightOrhash int) (*gjson.Result, error)
- func (c *Client) CheckNonce(key *Key) uint64
- type ExtractResult
- type Key
- type NASBlockScanner
- func (bs *NASBlockScanner) BatchExtractTransaction(blockHeight uint64, blockHash string, txs []string) error
- func (bs *NASBlockScanner) DeleteUnscanRecord(height uint64) error
- func (bs *NASBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, txid string, ...) ExtractResult
- func (bs *NASBlockScanner) ExtractTransactionData(txid string, scanTargetFunc openwallet.BlockScanTargetFunc) (map[string][]*openwallet.TxExtractData, error)
- func (bs *NASBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
- func (bs *NASBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *NASBlockScanner) GetLocalBlock(height uint64) (*Block, error)
- func (bs *NASBlockScanner) GetLocalBlockHead() (uint64, string, error)
- func (bs *NASBlockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *NASBlockScanner) GetScannedBlockHeight() uint64
- func (bs *NASBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
- func (bs *NASBlockScanner) InitNasExtractResult(tx *NasTransaction, result *ExtractResult, isFromAccount bool)
- func (bs *NASBlockScanner) RescanFailedRecord()
- func (bs *NASBlockScanner) SaveLocalBlock(blockHeader *Block) error
- func (bs *NASBlockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error
- func (bs *NASBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
- func (bs *NASBlockScanner) ScanBlock(height uint64) error
- func (bs *NASBlockScanner) ScanBlockTask()
- func (bs *NASBlockScanner) SetRescanBlockHeight(height uint64) error
- func (bs *NASBlockScanner) SupportBlockchainDAI() bool
- type NasTransaction
- type SaveResult
- type SubmitTransaction
- type TransactionDecoder
- func (decoder *TransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) CreateSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
- func (decoder *TransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
- func (decoder *TransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (decoder *TransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)
- func (decoder *TransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
- func (decoder *TransactionDecoder) SubmitSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
- func (decoder *TransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- type WalletConfig
- type WalletManager
- func (wm *WalletManager) AddWalletInSummary(wid string, wallet *openwallet.Wallet)
- func (wm *WalletManager) BackupWalletFlow() error
- func (wm *WalletManager) BsGetBalanceByAddress(addr string) (*openwallet.Balance, error)
- func (wm *WalletManager) ConfirmTxdecodeNonce(addr string, nonce_db uint64) uint64
- func (wm *WalletManager) CreateAddrFromPublic(key *hdkeystore.HDKey, start, index uint64) (*openwallet.Address, error)
- func (wm *WalletManager) CreateAddressFlow() error
- func (wm *WalletManager) CreateBatchAddress(walletId, password string, count uint64) (string, []*openwallet.Address, error)
- func (wm *WalletManager) CreateNewWallet(name, password string) (*openwallet.Wallet, string, error)
- func (wm *WalletManager) CreateRawTransaction(from, to, gasLimit, gasPrice, value string, nonce uint64) (*SubmitTransaction, error)
- func (wm *WalletManager) CreateWalletFlow() error
- func (wm *WalletManager) CreatestimateGasParameters(from string, to string, value *big.Int) (*estimateGasParameter, error)
- func (wm *WalletManager) CurveType() uint32
- func (wm *WalletManager) Decimal() int32
- func (wm *WalletManager) EstimateFeeRate() string
- func (wm *WalletManager) FullName() string
- func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
- func (wm *WalletManager) GetAddressWithBalance(address ...*openwallet.Address) error
- func (w *WalletManager) GetAssetsLogger() *log.OWLogger
- func (wm *WalletManager) GetBlockByHash(hash string) (*Block, error)
- func (wm *WalletManager) GetBlockByHeight(height string) (*Block, error)
- func (wm *WalletManager) GetBlockHashByHeight(height uint64) (string, error)
- func (wm *WalletManager) GetBlockHeight() (uint64, error)
- func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
- func (wm *WalletManager) GetChainID() (uint32, error)
- func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
- func (wm *WalletManager) GetTransaction(txid string, height uint64) (*NasTransaction, error)
- func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
- func (wm *WalletManager) GetWalletByID(walletID string) (*openwallet.Wallet, error)
- func (wm *WalletManager) GetWalletList() error
- func (wm *WalletManager) GetWallets() ([]*openwallet.Wallet, error)
- func (wm *WalletManager) Getestimatefee(from string, to string, value *big.Int) (*txFeeInfo, error)
- func (wm *WalletManager) ImportWatchOnlyAddress(address ...*openwallet.Address) error
- func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
- func (wm *WalletManager) InitConfigFlow() error
- func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
- func (wm *WalletManager) LoadConfig() error
- func (wm *WalletManager) RestoreWallet(keyFile, dbFile, password string) error
- func (w *WalletManager) RestoreWalletFlow() error
- func (wm *WalletManager) ShowConfig() error
- func (wm *WalletManager) SubmitRawTransaction(submit_data string) (string, error)
- func (wm *WalletManager) SummaryFollow() error
- func (wm *WalletManager) SummaryWallets()
- func (wm *WalletManager) Symbol() string
- func (wm *WalletManager) Transfer(key *Key, from, to, gasLimit, value string) (string, error)
- func (wm *WalletManager) TransferFlow() error
Constants ¶
const ( //币种 Symbol = "NAS" MasterKey = "Nas seed" CurveType = owcrypt.ECC_CURVE_SECP256K1 Gaslimit = "2000000" )
const ( TxPayloadBinaryType = "binary" TxPayloadDeployType = "deploy" TxPayloadCallType = "call" )
from nebulasio
Variables ¶
var ( //Smart Contract Address前缀 Contract_prefix = []byte{0x19, 0x58} )
var Nonce_Chain int
定义全局变量Nonce用于记录真正交易上链的nonce值和记录在DB中的nonce值
Functions ¶
func CheckRawTransaction ¶
func CheckRawTransaction(rawTx *openwallet.RawTransaction) error
func ConverWeiStringToNasDecimal ¶
ConverWeiStringToNasDecimal 字符串Wei转小数NAS
func ConvertNasStringToWei ¶
ConvertNasStringToWei 字符串NAS转Wei
func ConvertToBigInt ¶
ConvertToBigInt string转Big int
func EncodeToTransactionRawHex ¶
func EncodeToTransactionRawHex(submit_tx *SubmitTransaction) (string, error)
EncodeToTransactionRawHex
func EncodeTransaction ¶
func EncodeTransaction(submit_tx *SubmitTransaction) (string, error)
SubmitRawTransaction对签名结果进行编码
func NewAddressDecoder ¶
func NewAddressDecoder(wm *WalletManager) *addressDecoder
NewAddressDecoder 地址解析器
func NotenonceInDB ¶
将签名成功广播出去后的nonce值记录在对应address的DB中
func SignRawTransaction ¶
SignRawTransaction对交易hash进行签名
func SortAddrFromBalance ¶
func SortAddrFromBalance(MixAddr []*openwallet.Address) []*openwallet.Address
冒泡算法,对一个钱包下面的所有地址进行从大到小排序后供转账使用,提高效率
Types ¶
type AddrBalance ¶
type Block ¶
type Block struct { /* { "result": { "hash": "37c1afd37a7340fce54e4b32401e02b537ee7d7d8ff02796e85811a497b5660b", "parent_hash": "52f0f98a6f755fa1088b296cc461a7b266c06c284e2fd8f43003de460cc64398", "height": "1098023", "nonce": "0", "coinbase": "n1EzGmFsVepKduN1U5QFyhLqpzFvM9sRSmG", "timestamp": "1539314535", "chain_id": 1001, "state_root": "b481d6a6bddab87558d7b31f590bdaea1b30aaf9d11dee56d8a5f8a27dc79e6b", "txs_root": "d9f90ebe015f42651778764bbcae85558de36b696bc8ed45145735b70f6f7b08", "events_root": "540004b851de9a5da07b457076a6b398245b0886a10b5815991b38117ca62056", "consensus_root": { "timestamp": "1539314535", "proposer": "GVfjikwHkVvZrFz0l460IVAxpDi6hi9ILA0=", "dynasty_root": "Kst/n5bFEWA/FD8qPKn029Y8cE9dfEgp6VMuJp5AGfU=" }, "miner": "n1bFyMzjrjML5ax8ry7NQ4dWHHmnBU9ghXi", "randomSeed": "e306e461d9c9e7f343fe732347204e1865da008c9fec5658bbdfbf767ae2dca8", "randomProof": "f70bc1978048f54971e9dd6a529a94208248ae2f79590f7a17f73e0b708b9b54a15fe0f7e27ead9f0f8f63208811c2b61d1d1fda1959b825dc0d0739ef8ee98304e541261fcd1142700f715d0cd9c9267f8eab1accca1d9a12b37a63f335d00afa6f0850fd8a1902fa1e35aa1b73d9e9ac31a1aabfcff47671d30734187a8a4ee2", "is_finality": true, "transactions": [ { "hash": "08057a5635865bb8a90fa06e833b1171fdd2eaedb1dc673e44601122f1ff4519", "chainId": 1001, "from": "n1JdmmyhrrqBuESseZSbrBucnvugSewSMTE", "to": "n1wR7zue5zXjUEmQofcTZV8t1H61MbBdpj5", "value": "0", "nonce": "59", "timestamp": "1539314513", "type": "call", "data": "eyJGdW5jdGlvbiI6ImFkZCIsIkFyZ3MiOiJbXCJuMUpkbW15aHJycUJ1RVNzZVpTYnJCdWNudnVnU2V3U01URVwiLFwi5rWL6K+V77yabjFKZG1teWhycnFCdUVTc2VaU2JyQnVjbnZ1Z1Nld1NNVEVcIl0ifQ==", "gas_price": "1000000", "gas_limit": "200000", "contract_address": "", "status": 1, "gas_used": "20322", "execute_error": "", "execute_result": "\"\"", "block_height": "1098023" } ] } } */ Hash string Confirmations uint64 Merkleroot string Previousblockhash string Height uint64 `storm:"id"` Version uint64 Time uint64 Fork bool // contains filtered or unexported fields }
type BlockchainInfo ¶
type BlockchainInfo struct { Chain string `json:"chain"` Blocks uint64 `json:"blocks"` Headers uint64 `json:"headers"` Bestblockhash string `json:"bestblockhash"` Difficulty string `json:"difficulty"` Mediantime uint64 `json:"mediantime"` Verificationprogress string `json:"verificationprogress"` Chainwork string `json:"chainwork"` Pruned bool `json:"pruned"` }
BlockchainInfo 本地节点区块链信息
func NewBlockchainInfo ¶
func NewBlockchainInfo(json *gjson.Result) *BlockchainInfo
type Client ¶
func (*Client) CallGetTransactionReceipt ¶
func (*Client) CallGetaccountstate ¶
查询每个地址balance、nonce
func (*Client) CallGetestimateGas ¶
估算交易gas用量
func (*Client) CallGetnebstate ¶
查询区块链chain_id,testnet: mainnet:
func (*Client) CallGetsubscribe ¶
由于接口是keep-alive connection,目前暂不支持
func (*Client) CallSendRawTransaction ¶
发送广播签名后的交易单数据
func (*Client) CallgetBlockByHeightOrHash ¶
根据区块高度获取区块信息
type ExtractResult ¶
type ExtractResult struct { //Recharges []*openwallet.Recharge TxID string BlockHeight uint64 Success bool // contains filtered or unexported fields }
ExtractResult 扫描完成的提取结果
type NASBlockScanner ¶
type NASBlockScanner struct { *openwallet.BlockScannerBase CurrentBlockHeight uint64 //当前区块高度 IsScanMemPool bool //是否扫描交易池 RescanLastBlockCount uint64 //重扫上N个区块数量 // contains filtered or unexported fields }
NASBlockScanner nebulasio的区块链扫描器
func NewNASBlockScanner ¶
func NewNASBlockScanner(wm *WalletManager) *NASBlockScanner
NewNASBlockScanner 创建区块链扫描器
func (*NASBlockScanner) BatchExtractTransaction ¶
func (bs *NASBlockScanner) BatchExtractTransaction(blockHeight uint64, blockHash string, txs []string) error
BatchExtractTransaction 批量提取交易单 bitcoin 1M的区块链可以容纳3000笔交易,批量多线程处理,速度更快
func (*NASBlockScanner) DeleteUnscanRecord ¶ added in v1.2.0
func (bs *NASBlockScanner) DeleteUnscanRecord(height uint64) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*NASBlockScanner) ExtractTransaction ¶
func (bs *NASBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, txid string, scanAddressFunc openwallet.BlockScanAddressFunc) ExtractResult
ExtractTransaction 提取交易单
func (*NASBlockScanner) ExtractTransactionData ¶
func (bs *NASBlockScanner) ExtractTransactionData(txid string, scanTargetFunc openwallet.BlockScanTargetFunc) (map[string][]*openwallet.TxExtractData, error)
ExtractTransactionData 扫描一笔交易
func (*NASBlockScanner) GetBalanceByAddress ¶
func (bs *NASBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
GetAssetsAccountBalanceByAddress 查询账户相关地址的交易记录
func (*NASBlockScanner) GetCurrentBlockHeader ¶
func (bs *NASBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
GetCurrentBlockHeader 获取当前区块高度
func (*NASBlockScanner) GetLocalBlock ¶ added in v1.2.0
func (bs *NASBlockScanner) GetLocalBlock(height uint64) (*Block, error)
GetLocalBlock 获取本地区块数据
func (*NASBlockScanner) GetLocalBlockHead ¶ added in v1.2.0
func (bs *NASBlockScanner) GetLocalBlockHead() (uint64, string, error)
GetLocalBlockHead 获取本地记录的区块高度和hash
func (*NASBlockScanner) GetScannedBlockHeader ¶
func (bs *NASBlockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)
GetScannedBlockHeader 获取当前已扫区块高度
func (*NASBlockScanner) GetScannedBlockHeight ¶
func (bs *NASBlockScanner) GetScannedBlockHeight() uint64
GetScannedBlockHeight 获取已扫区块高度
func (*NASBlockScanner) GetUnscanRecords ¶ added in v1.2.0
func (bs *NASBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
func (*NASBlockScanner) InitNasExtractResult ¶
func (bs *NASBlockScanner) InitNasExtractResult(tx *NasTransaction, result *ExtractResult, isFromAccount bool)
func (*NASBlockScanner) RescanFailedRecord ¶
func (bs *NASBlockScanner) RescanFailedRecord()
//ScanTxMemPool 扫描交易内存池 func (bs *BTCBlockScanner) ScanTxMemPool() {
bs.wm.Log.Std.Info("block scanner scanning mempool ...") //提取未确认的交易单 txIDsInMemPool, err := bs.wm.GetTxIDsInMemPool() if err != nil { bs.wm.Log.Std.Info("block scanner can not get mempool data; unexpected error: %v", err) } err = bs.BatchExtractTransaction(0, "", txIDsInMemPool) if err != nil { bs.wm.Log.Std.Info("block scanner can not extractRechargeRecords; unexpected error: %v", err) }
}
rescanFailedRecord 重扫失败记录
func (*NASBlockScanner) SaveLocalBlock ¶ added in v1.2.0
func (bs *NASBlockScanner) SaveLocalBlock(blockHeader *Block) error
SaveLocalBlock 记录本地新区块
func (*NASBlockScanner) SaveLocalBlockHead ¶ added in v1.2.0
func (bs *NASBlockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error
SaveLocalBlockHead 记录区块高度和hash到本地
func (*NASBlockScanner) SaveUnscanRecord ¶
func (bs *NASBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
SaveUnscanRecord 保存交易记录到钱包数据库
func (*NASBlockScanner) ScanBlock ¶
func (bs *NASBlockScanner) ScanBlock(height uint64) error
ScanBlock 扫描指定高度区块
func (*NASBlockScanner) ScanBlockTask ¶
func (bs *NASBlockScanner) ScanBlockTask()
ScanBlockTask 扫描任务
func (*NASBlockScanner) SetRescanBlockHeight ¶
func (bs *NASBlockScanner) SetRescanBlockHeight(height uint64) error
SetRescanBlockHeight 重置区块链扫描高度
func (*NASBlockScanner) SupportBlockchainDAI ¶ added in v1.2.0
func (bs *NASBlockScanner) SupportBlockchainDAI() bool
SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional
type NasTransaction ¶
type NasTransaction struct { /* TxID string Size uint64 Version uint64 LockTime int64 Hex string BlockHash string BlockHeight uint64 Confirmations uint64 Blocktime int64 IsCoinBase bool Fees string Vins []*Vin Vouts []*Vout */ /* //nas { "hash": "c98c1c117442554a674262b6c566e8ba12b7397fdcbf09abb6f3bd06a1646b83", "chainId": 100, "from": "n1NM2eETQG5Es7cCc7sh29NJr9cP94QZcXR", "to": "n1Qzgp7TE4TNQTC9LQpEsuYZFbGU14cpDZk", "value": "17000000000000000000", "nonce": "39", "timestamp": "1", "type": "binary", "data": null, "gas_price": "1000000", "gas_limit": "2000000", "contract_address": "", "status": 1, "gas_used": "20000", "execute_error": "", "execute_result": "" } */ Hash string //txid ChainId uint64 From string To string Value decimal.Decimal Nonce string Timestamp string Type string Data string Gas_price string Gas_limit string Contract_address string Status uint64 Gas_used string Execute_error string Execute_result string SourceKey string //transaction scanning 的时候对其进行赋值 //交易对应的区块信息 BlockTime uint64 BlockHeight uint64 BlockHash string }
type SaveResult ¶
SaveResult 保存结果
type SubmitTransaction ¶
type SubmitTransaction struct { Hash []byte //交易hash From []byte To []byte Value []byte Nonce uint64 Timestamp int64 Data *corepb.Data ChainId uint32 GasPrice []byte GasLimit []byte Alg uint32 Sign []byte //交易hash签名结果 }
SubmitTransaction 存放最终广播出去的交易单信息
func DecodeRawHexToTransaction ¶
func DecodeRawHexToTransaction(rawHex string) (*SubmitTransaction, error)
DecodeRawHexToTransaction
func NewSubmitTransactionByProto ¶
func NewSubmitTransactionByProto(tx corepb.Transaction) *SubmitTransaction
NewSubmitTransactionByProto
func (*SubmitTransaction) ToProto ¶
func (tx *SubmitTransaction) ToProto() proto.Message
对签名结果按照官方进行编码
type TransactionDecoder ¶
type TransactionDecoder struct { openwallet.TransactionDecoderBase // contains filtered or unexported fields }
func NewTransactionDecoder ¶
func NewTransactionDecoder(wm *WalletManager) *TransactionDecoder
NewTransactionDecoder 交易单解析器
func (*TransactionDecoder) CreateRawTransaction ¶
func (decoder *TransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
CreateRawTransaction 创建交易单
func (*TransactionDecoder) CreateSimpleRawTransaction ¶
func (decoder *TransactionDecoder) CreateSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
func (*TransactionDecoder) CreateSimpleSummaryRawTransaction ¶
func (decoder *TransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
CreateSimpleSummaryRawTransaction 创建ETH汇总交易
func (*TransactionDecoder) CreateSummaryRawTransaction ¶
func (decoder *TransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
CreateSummaryRawTransaction 创建汇总交易,返回原始交易单数组
func (*TransactionDecoder) CreateSummaryRawTransactionWithError ¶ added in v1.1.1
func (decoder *TransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateSummaryRawTransactionWithError 创建汇总交易,返回能原始交易单数组(包含带错误的原始交易单)
func (*TransactionDecoder) GetRawTransactionFeeRate ¶
func (decoder *TransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)
GetRawTransactionFeeRate 获取交易单的费率
func (*TransactionDecoder) SignRawTransaction ¶
func (decoder *TransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
SignRawTransaction 签名交易单
func (*TransactionDecoder) SubmitRawTransaction ¶
func (decoder *TransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
SendRawTransaction 广播交易单
func (*TransactionDecoder) SubmitSimpleRawTransaction ¶
func (decoder *TransactionDecoder) SubmitSimpleRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)
func (*TransactionDecoder) VerifyRawTransaction ¶
func (decoder *TransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单
type WalletConfig ¶
type WalletConfig struct { //币种 Symbol string MasterKey string //钱包服务API ServerAPI string //gas limit GasLimit decimal.Decimal //钱包安装的路径 NodeInstallPath string //钱包数据文件目录 WalletDataPath string //汇总阀值 Threshold decimal.Decimal //汇总地址 SumAddress string //汇总执行间隔时间 CycleSeconds time.Duration //默认配置内容 DefaultConfig string //曲线类型 CurveType uint32 /***********扫描器**************/ //区块链数据文件 //BlockchainFile string //数据目录 DataDir string // contains filtered or unexported fields }
func NewConfig ¶
func NewConfig(symbol string, masterKey string) *WalletConfig
func (*WalletConfig) PrintConfig ¶
func (wc *WalletConfig) PrintConfig() error
printConfig Print config information
type WalletManager ¶
type WalletManager struct { openwallet.AssetsAdapterBase Storage *hdkeystore.HDKeystore //秘钥存取 WalletClient *Client // 节点客户端 Config *WalletConfig //钱包管理配置 WalletsInSum map[string]*openwallet.Wallet //参与汇总的钱包 Blockscanner *NASBlockScanner //区块扫描器 Decoder openwallet.AddressDecoder //地址编码器 TxDecoder openwallet.TransactionDecoder //交易单编码器 ContractDecoder openwallet.SmartContractDecoder //智能合约解析器 Log *log.OWLogger //日志工具 }
func NewWalletManager ¶
func NewWalletManager() *WalletManager
func (*WalletManager) AddWalletInSummary ¶
func (wm *WalletManager) AddWalletInSummary(wid string, wallet *openwallet.Wallet)
func (*WalletManager) BsGetBalanceByAddress ¶
func (wm *WalletManager) BsGetBalanceByAddress(addr string) (*openwallet.Balance, error)
BsGetBalanceByAddress区块扫描器获取余额
func (*WalletManager) ConfirmTxdecodeNonce ¶
func (wm *WalletManager) ConfirmTxdecodeNonce(addr string, nonce_db uint64) uint64
ConfirmTxdecodeNonce 确定txdecode nonce值
func (*WalletManager) CreateAddrFromPublic ¶
func (wm *WalletManager) CreateAddrFromPublic(key *hdkeystore.HDKey, start, index uint64) (*openwallet.Address, error)
CreateAddrFromPublic 创建地址
func (*WalletManager) CreateBatchAddress ¶
func (wm *WalletManager) CreateBatchAddress(walletId, password string, count uint64) (string, []*openwallet.Address, error)
func (*WalletManager) CreateNewWallet ¶
func (wm *WalletManager) CreateNewWallet(name, password string) (*openwallet.Wallet, string, error)
CreateNewWallet 创建钱包
func (*WalletManager) CreateRawTransaction ¶
func (wm *WalletManager) CreateRawTransaction(from, to, gasLimit, gasPrice, value string, nonce uint64) (*SubmitTransaction, error)
CreateRawTransaction创建交易单hash
func (*WalletManager) CreatestimateGasParameters ¶
func (wm *WalletManager) CreatestimateGasParameters(from string, to string, value *big.Int) (*estimateGasParameter, error)
构建gas估算入参
func (*WalletManager) CurveType ¶
func (wm *WalletManager) CurveType() uint32
实现 openwallet/assets.go 中AssetsAdapter接口中的SymbolInfo方法 CurveType 曲线类型
func (*WalletManager) EstimateFeeRate ¶
func (wm *WalletManager) EstimateFeeRate() string
func (*WalletManager) GetAddressDecode ¶
func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
实现 openwallet/assets.go 中AssetsAdapter接口中的GetAddressDecode方法 AddressDecode 地址解析器
func (*WalletManager) GetAddressWithBalance ¶
func (wm *WalletManager) GetAddressWithBalance(address ...*openwallet.Address) error
GetAddressWithBalance 获取多个地址余额,使用查账户和单地址
func (*WalletManager) GetAssetsLogger ¶
func (w *WalletManager) GetAssetsLogger() *log.OWLogger
GetAssetsLogger 获取资产账户日志工具
func (*WalletManager) GetBlockByHash ¶
func (wm *WalletManager) GetBlockByHash(hash string) (*Block, error)
GetBlockByHash 根据区块hash获得区块信息
func (*WalletManager) GetBlockByHeight ¶
func (wm *WalletManager) GetBlockByHeight(height string) (*Block, error)
GetBlockByHeight 根据区块高度获得区块信息
func (*WalletManager) GetBlockHashByHeight ¶
func (wm *WalletManager) GetBlockHashByHeight(height uint64) (string, error)
GetBlockHashByHeight 根据区块高度获得区块hash
func (*WalletManager) GetBlockHeight ¶
func (wm *WalletManager) GetBlockHeight() (uint64, error)
GetBlockHeight 获取区块链高度
func (*WalletManager) GetBlockScanner ¶
func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
实现 openwallet/assets.go 中AssetsAdapter接口中的GetBlockScanner方法 GetBlockScanner 获取区块链
func (*WalletManager) GetChainID ¶
func (wm *WalletManager) GetChainID() (uint32, error)
GetBlockHeight 获取区块链高度
func (*WalletManager) GetSmartContractDecoder ¶
func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
实现 openwallet/assets.go 中AssetsAdapter接口中的GetSmartContractDecoder方法*/
func (*WalletManager) GetTransaction ¶
func (wm *WalletManager) GetTransaction(txid string, height uint64) (*NasTransaction, error)
GetTransaction 获取交易单
func (*WalletManager) GetTransactionDecoder ¶
func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
实现 openwallet/assets.go 中AssetsAdapter接口中的GetTransactionDecoder方法 TransactionDecoder 交易单解析器
func (*WalletManager) GetWalletByID ¶
func (wm *WalletManager) GetWalletByID(walletID string) (*openwallet.Wallet, error)
GetWalletByID 获取钱包
func (*WalletManager) GetWalletList ¶
func (wm *WalletManager) GetWalletList() error
GetWalletList 获取钱包列表
func (*WalletManager) GetWallets ¶
func (wm *WalletManager) GetWallets() ([]*openwallet.Wallet, error)
GetWalletKeys 通过给定的文件路径加载keystore文件得到钱包列表
func (*WalletManager) Getestimatefee ¶
估算gas花费的Wei
func (*WalletManager) ImportWatchOnlyAddress ¶
func (wm *WalletManager) ImportWatchOnlyAddress(address ...*openwallet.Address) error
ImportWatchOnlyAddress 导入观测地址
func (*WalletManager) InitAssetsConfig ¶
func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)
InitAssetsConfig 初始化默认配置
func (*WalletManager) LoadAssetsConfig ¶
func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
LoadAssetsConfig 加载外部配置
func (*WalletManager) RestoreWallet ¶
func (wm *WalletManager) RestoreWallet(keyFile, dbFile, password string) error
RestoreWallet 恢复钱包
func (*WalletManager) RestoreWalletFlow ¶
func (w *WalletManager) RestoreWalletFlow() error
RestoreWalletFlow 恢复钱包
func (*WalletManager) SubmitRawTransaction ¶
func (wm *WalletManager) SubmitRawTransaction(submit_data string) (string, error)
SubmitRawTransaction对签名编码后的数据进行广播
func (*WalletManager) SummaryFollow ¶
func (wm *WalletManager) SummaryFollow() error
SummaryFollow 汇总流程
func (*WalletManager) Transfer ¶
func (wm *WalletManager) Transfer(key *Key, from, to, gasLimit, value string) (string, error)
发送交易
func (*WalletManager) TransferFlow ¶
func (wm *WalletManager) TransferFlow() error
SendTXFlow 发送交易 1NAS = 10^18 Wei