Documentation ¶
Index ¶
- Constants
- func CheckRawTransaction(rawTx *openwallet.RawTransaction) error
- func DecodeAddress(addr string, isTestnet bool) (string, []byte, error)
- func EncodeAddress(hexStr string, isTestnet bool) (string, error)
- func InsertSignatureIntoRawTransaction(txHex string, signature string) (string, error)
- func ParseTransferEvent(data string) (string, *big.Int, error)
- type Account
- type AccountNet
- type AccountResource
- type AddrBalance
- type AddressDecoderStruct
- func (decoder *AddressDecoderStruct) PrivateKeyToWIF(priv []byte, isTestnet bool) (string, error)
- func (decoder *AddressDecoderStruct) PublicKeyToAddress(pub []byte, isTestnet bool) (string, error)
- func (decoder *AddressDecoderStruct) RedeemScriptToAddress(pubs [][]byte, required uint64, isTestnet bool) (string, error)
- func (decoder *AddressDecoderStruct) WIFToPrivateKey(wif string, isTestnet bool) ([]byte, error)
- type Block
- type Client
- type Contract
- type ContractDecoder
- type ContractInfo
- type ExtractResult
- type Result
- type Return
- type SaveResult
- type SolidityParam
- type Transaction
- type TransactionDecoder
- func (decoder *TransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- func (decoder *TransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (decoder *TransactionDecoder) CreateSimpleTransaction(wrapper openwallet.WalletDAI, rawTx *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) CreateTokenSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
- func (decoder *TransactionDecoder) CreateTokenTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) 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) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
- type TransactionExtention
- type TronBlockScanner
- func (bs *TronBlockScanner) BatchExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, txs []*Transaction) error
- func (bs *TronBlockScanner) DeleteUnscanRecord(height uint64) error
- func (bs *TronBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, trx *Transaction, ...) ExtractResult
- func (bs *TronBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
- func (bs *TronBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
- func (bs *TronBlockScanner) GetGlobalMaxBlockHeight() uint64
- func (bs *TronBlockScanner) GetLocalBlock(height uint64) (*Block, error)
- func (bs *TronBlockScanner) GetLocalNewBlock() (uint64, string, error)
- func (bs *TronBlockScanner) GetScannedBlockHeight() uint64
- func (bs *TronBlockScanner) GetSourceKeyByAddress(address string) (string, bool)
- func (bs *TronBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
- func (bs *TronBlockScanner) InitTronExtractResult(tx *Contract, result *ExtractResult, operate int64)
- func (bs *TronBlockScanner) RescanFailedRecord()
- func (bs *TronBlockScanner) Restart() error
- func (bs *TronBlockScanner) Run() error
- func (bs *TronBlockScanner) SaveLocalBlock(block *Block) error
- func (bs *TronBlockScanner) SaveLocalNewBlock(blockHeight uint64, blockHash string) error
- func (bs *TronBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
- func (bs *TronBlockScanner) ScanBlock(height uint64) error
- func (bs *TronBlockScanner) ScanBlockTask()
- func (bs *TronBlockScanner) SetRescanBlockHeight(height uint64) error
- func (bs *TronBlockScanner) Stop() error
- func (bs *TronBlockScanner) SupportBlockchainDAI() bool
- type UnscanRecord
- type WalletConfig
- type WalletManager
- func (wm *WalletManager) BackupWalletFlow() error
- func (wm *WalletManager) BroadcastTransaction(raw string) (string, error)
- func (wm *WalletManager) BroadcastTransaction1(raw string) error
- func (wm *WalletManager) CreateAccount(ownerAddress, accountAddress string) (txRaw *gjson.Result, err error)
- func (wm *WalletManager) CreateAddress(passValue string) (addr string, err error)
- func (wm *WalletManager) CreateAddressFlow() error
- func (wm *WalletManager) CreateAddressRef(key []byte, isPrivate bool) (addr string, err error)
- func (wm *WalletManager) CreateBatchAddress(name, password string, count uint64) (string, []*openwallet.Address, error)
- func (wm *WalletManager) CreateNewWallet(name, password string) (*openwallet.Wallet, string, error)
- func (wm *WalletManager) CreateTokenTransaction(toAddress, ownerAddress string, amount string, ...) (txRawHex string, err error)
- func (wm *WalletManager) CreateTransaction(toAddress, ownerAddress string, amount float64) (raw string, err error)
- func (wm *WalletManager) CreateTransactionRef(toAddress, ownerAddress string, amount string) (txRawHex string, err error)
- func (wm *WalletManager) CreateWalletFlow() error
- func (wm *WalletManager) CurveType() uint32
- func (wm *WalletManager) Decimal() int32
- func (wm *WalletManager) DeleteUnscanRecord(height uint64) error
- func (wm *WalletManager) FullName() string
- func (wm *WalletManager) GenerateAddress() (address map[string]string, err error)
- func (wm *WalletManager) GetAccount(address string) (account *openwallet.AssetsAccount, err error)
- func (wm *WalletManager) GetAccountNet(address string) (accountNet *AccountNet, err error)
- func (wm *WalletManager) GetAccountResource(address string) (*AccountResource, error)
- func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
- func (wm *WalletManager) GetAddressWithBalance(address ...*openwallet.Address) error
- func (wm *WalletManager) GetAddressesFromLocalDB(walletID string, offset, limit int) ([]*openwallet.Address, error)
- func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
- func (wm *WalletManager) GetBlockByID(blockID string) (block *Block, err error)
- func (wm *WalletManager) GetBlockByLatestNum(num uint64) (blocks []*Block, err error)
- func (wm *WalletManager) GetBlockByLimitNext(startNum, endNum uint64) (blocks []*Block, err error)
- func (wm *WalletManager) GetBlockByNum(num uint64) (block *Block, error error)
- func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
- func (wm *WalletManager) GetContractInfo(contractAddress string) (*ContractInfo, error)
- func (wm *WalletManager) GetCurrentBlock() (block *Block, err error)
- func (wm *WalletManager) GetNowBlock() (block *Block, err error)
- func (wm *WalletManager) GetPrivateKeyRef(walletID, password string, index uint64, serializes uint32) (string, error)
- func (this *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
- func (wm *WalletManager) GetTRC10Balance(address string, tokenID string) (*big.Int, error)
- func (wm *WalletManager) GetTRC20Balance(address string, contractAddress string) (*big.Int, error)
- func (wm *WalletManager) GetTRXAccount(address string) (account *Account, exist bool, err error)
- func (wm *WalletManager) GetTotalTransaction() (num uint64, err error)
- func (wm *WalletManager) GetTransaction(txid string, blockhash string, blockheight uint64, blocktime int64) (*Transaction, error)
- func (wm *WalletManager) GetTransactionBurnFee(txid string) (string, error)
- func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
- func (wm *WalletManager) GetTransactionFeeEstimated(from string, data string) (*txFeeInfo, error)
- func (wm *WalletManager) GetTransactionSign(transaction, privateKey string) (rawSinged []byte, err error)
- func (wm *WalletManager) GetWalletBalance(accountID string) string
- func (wm *WalletManager) GetWalletInfo(walletID string) (*openwallet.Wallet, error)
- func (wm *WalletManager) GetWalletList() error
- func (wm *WalletManager) GetWallets() ([]*openwallet.Wallet, error)
- func (wm *WalletManager) Getbalance(address string) (*AddrBalance, error)
- func (wm *WalletManager) ImportWatchOnlyAddress(address ...*openwallet.Address) error
- func (wm *WalletManager) InitConfigFlow() error
- func (wm *WalletManager) IsEnoughEnergyToTransferTRC20(address string, trxBalance *big.Int) (flag bool, energyRest int64, feeMini int64)
- func (wm *WalletManager) ListNodes() (nodes []string, err error)
- func (wm *WalletManager) ListWitnesses() (witnesses string, err error)
- func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
- func (wm *WalletManager) LoadConfig() error
- func (wm *WalletManager) RestoreWalletFlow() error
- func (wm *WalletManager) SendTransaction(walletID, to string, amount decimal.Decimal, password string, ...) ([]string, error)
- func (wm *WalletManager) ShowConfig() error
- func (wm *WalletManager) SignTransactionRef(hash string, privateKey string) (signedTxRaw string, err error)
- func (wm *WalletManager) SummaryFollow() error
- func (wm *WalletManager) SummaryWallets()
- func (wm *WalletManager) Symbol() string
- func (wm *WalletManager) TransferFlow() error
- func (wm *WalletManager) TriggerSmartContract(contractAddress string, function string, parameter string, feeLimit uint64, ...) (*TransactionExtention, error)
- func (wm *WalletManager) UpdateAccount(accountName, ownerAddress string) (tx *gjson.Result, err error)
- func (wm *WalletManager) ValidSignedTokenTransaction(txHex string) error
- func (wm *WalletManager) ValidSignedTransactionRef(txHex string) error
- func (wm *WalletManager) ValidateAddress(address string) (err error)
Constants ¶
const ( //RPCServerCore RPC服务,核心钱包 RPCServerCore = 0 //RPCServerExplorer RPC服务,insight-API RPCServerExplorer = 1 )
const ( // Symbol 币种 Symbol = "TRX" //MasterKey key for master MasterKey = "Troncoin seed" //CurveType to generate ChildKey by BIP32 CurveType = owcrypt.ECC_CURVE_SECP256K1 Decimals = 6 SUN int64 = 1 //最小单位 TRX int64 = SUN * 1000000 //1 TRX = 1000000 * sun GasPrice = SUN * 140 CreateAccountCost = SUN * 1100000 //1.1 TRX = 1100000 * sun )
const ( TRC10 = "trc10" TRC20 = "trc20" FeeLimit = 10000000 )
const ( TRC20_BALANCE_OF_METHOD = "balanceOf(address)" TRC20_TRANSFER_METHOD_ID = "a9059cbb" TRX_TRANSFER_EVENT_ID = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" )
const ( SOLIDITY_TYPE_ADDRESS = "address" SOLIDITY_TYPE_UINT256 = "uint256" SOLIDITY_TYPE_UINT160 = "uint160" )
const ( TransferContract = "TransferContract" TransferAssetContract = "TransferAssetContract" TriggerSmartContract = "TriggerSmartContract" )
交易单类型
const (
SUCCESS = "SUCCESS"
)
状态
Variables ¶
This section is empty.
Functions ¶
func CheckRawTransaction ¶
func CheckRawTransaction(rawTx *openwallet.RawTransaction) error
Types ¶
type Account ¶
type Account struct { AddressHex string Balance int64 FreeNetUsage int64 AssetV2 map[string]*big.Int FreeAssetNetUsageV2 map[string]int64 }
func NewAccount ¶
type AccountNet ¶
type AccountNet struct { FreeNetUsed int64 FreeNetLimit int64 NetUsed int64 NetLimit int64 AssetNetUsed map[string]int64 AssetNetLimit map[string]int64 TotalNetLimit int64 TotalNetWeight int64 }
func NewAccountNet ¶
func NewAccountNet(json *gjson.Result) *AccountNet
type AccountResource ¶
type AccountResource struct { FreeNetUsed int64 FreeNetLimit int64 NetUsed int64 NetLimit int64 EnergyUsed int64 EnergyLimit int64 StorageUsed int64 StorageLimit int64 }
func NewAccountResource ¶
func NewAccountResource(json *gjson.Result) *AccountResource
type AddrBalance ¶
type AddressDecoderStruct ¶
type AddressDecoderStruct struct {
// contains filtered or unexported fields
}
AddressDecoderStruct for Interface AddressDecoder
func NewAddressDecoder ¶
func NewAddressDecoder(wm *WalletManager) *AddressDecoderStruct
NewAddressDecoder 地址解析器
func (*AddressDecoderStruct) PrivateKeyToWIF ¶
func (decoder *AddressDecoderStruct) PrivateKeyToWIF(priv []byte, isTestnet bool) (string, error)
PrivateKeyToWIF 私钥转WIF
func (*AddressDecoderStruct) PublicKeyToAddress ¶
func (decoder *AddressDecoderStruct) PublicKeyToAddress(pub []byte, isTestnet bool) (string, error)
PublicKeyToAddress 公钥转地址
func (*AddressDecoderStruct) RedeemScriptToAddress ¶
func (decoder *AddressDecoderStruct) RedeemScriptToAddress(pubs [][]byte, required uint64, isTestnet bool) (string, error)
RedeemScriptToAddress 多重签名赎回脚本转地址
func (*AddressDecoderStruct) WIFToPrivateKey ¶
func (decoder *AddressDecoderStruct) WIFToPrivateKey(wif string, isTestnet bool) ([]byte, error)
WIFToPrivateKey WIF转私钥
type Block ¶
type Block struct { /* { "blockID":"000000000035e1c0f60afaa8387fd17fd9b84fe4381265ff084d739f814558ea", "block_header":{ "raw_data":{"number":3531200, "txTrieRoot":"9d98f6cbbde8302774ab87c003831333e132c89e00009cb1f7da35e1e59ae8ca", "witness_address":"41d1dbde8b8f71b48655bec4f6bb532a0142b88bc0", "parentHash":"000000000035e1bfb3b6f244e5316ce408aa8cea4c348eabe2545247f5a4600c", "version":3, "timestamp":1540545240000}, "witness_signature":"6ceedcacd8d0111b48eb4131484de3d13f27a2f4bd8156279d03d4208690158e20a641b77d900e026ee33adc328f9ec674f6483ea7b1ca5a27fa24d7fb23964100" }, "transactions":[ {"ret":[{"contractRet":"SUCCESS"}], "signature":["40aa520f01cebf12948615b9c5a5df5fe7d57e1a7f662d53907b4aa14f647a3a47be2a097fdb58159d0bee7eb1ff0a15ac738f24643fe5114cab8ec0d52cc04d01"], "txID":"ac005b0a195a130914821a6c28db1eec44b4ec3a2358388ceb6c87b677866f1f", "raw_data":{ "contract":[ {"parameter":{"value":{"amount":1,"asset_name":"48756f6269546f6b656e","owner_address":"416b201fb7b9f2b97bbdaf5e0920191229767c30ee","to_address":"412451d09536fca47760ea6513372bbbbef8583105"}, "type_url":"type.googleapis.com/protocol.TransferAssetContract"}, "type":"TransferAssetContract"} ], "ref_block_bytes":"e1be", "ref_block_hash":"8dbf5f0cf4c324f2", "expiration":1540545294000, "timestamp":1540545235358} }, ...] } */ Hash string // 这里采用 BlockID Previousblockhash string Height uint64 `storm:"id"` Version uint64 Time int64 Fork bool // contains filtered or unexported fields }
func (*Block) GetBlockHashID ¶
func (*Block) GetTransactions ¶
func (block *Block) GetTransactions() []*Transaction
type Client ¶
type Client struct { BaseURL string // AccessToken string Debug bool // contains filtered or unexported fields }
A Client is a Tron RPC client. It performs RPCs over HTTP using JSON request and responses. A Client must be configured with a secret token to authenticate with other Cores on the network.
type Contract ¶
type ContractDecoder ¶
type ContractDecoder struct { *openwallet.SmartContractDecoderBase // contains filtered or unexported fields }
func NewContractDecoder ¶
func NewContractDecoder(wm *WalletManager) *ContractDecoder
NewContractDecoder 智能合约解析器
func (*ContractDecoder) GetTokenBalanceByAddress ¶
func (decoder *ContractDecoder) GetTokenBalanceByAddress(contract openwallet.SmartContract, address ...string) ([]*openwallet.TokenBalance, error)
type ContractInfo ¶
type ContractInfo struct { Bytecode string Name string ConsumeUserResourcePercent uint64 ContractAddress string ABI string }
func NewContractInfo ¶
func NewContractInfo(json *gjson.Result) *ContractInfo
type ExtractResult ¶
type ExtractResult struct { TxID string BlockHeight uint64 Success bool // contains filtered or unexported fields }
ExtractResult 扫描完成的提取结果
type Return ¶
type SaveResult ¶
SaveResult 保存结果
type SolidityParam ¶
type SolidityParam struct { ParamType string ParamValue interface{} }
type Transaction ¶
type Transaction struct { /* { "ret": [ { "contractRet": "SUCCESS" } ], "signature": [ "b6fbefec182a1db9759104e3d5709343f25acc1866c77deb050d9bf0f6a5c3342237fbbf076377ea26d1a09edd46e599534a8499998814da0e9187e07260382001" ], "txID": "86b5a123b5cc50047532f1a55ed627f29012bba41e6590b0545f903289e7099a", "raw_data": { "contract": [ { "parameter": { "value": { "amount": 10000, "owner_address": "415bdf283199369adb124f39dda845ae02c5d3eb5d", "to_address": "41bb65606e20dbdd7f0cfe6a66ae2858a6534f2d45" }, "type_url": "type.googleapis.com/protocol.TransferContract" }, "type": "TransferContract" } ], "ref_block_bytes": "2298", "ref_block_hash": "26478922abba48a0", "expiration": 1551957595231 } } */ TxID string BlockHash string BlockHeight uint64 BlockTime int64 IsCoinBase bool Ret []*Result Contract []*Contract }
func NewTransaction ¶
type TransactionDecoder ¶
type TransactionDecoder struct { openwallet.TransactionDecoderBase // contains filtered or unexported fields }
TransactionDecoder for Interface TransactionDecode
func NewTransactionDecoder ¶
func NewTransactionDecoder(wm *WalletManager) *TransactionDecoder
NewTransactionDecoder 交易单解析器
func (*TransactionDecoder) CreateRawTransaction ¶
func (decoder *TransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
func (*TransactionDecoder) CreateSimpleSummaryRawTransaction ¶
func (decoder *TransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateSimpleSummaryRawTransaction 创建主币汇总交易
func (*TransactionDecoder) CreateSimpleTransaction ¶
func (decoder *TransactionDecoder) CreateSimpleTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
CreateRawTransaction 创建交易单
func (*TransactionDecoder) CreateSummaryRawTransaction ¶
func (decoder *TransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)
CreateSummaryRawTransaction 创建汇总交易,返回原始交易单数组
func (*TransactionDecoder) CreateSummaryRawTransactionWithError ¶
func (decoder *TransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateSummaryRawTransactionWithError 创建汇总交易,返回能原始交易单数组(包含带错误的原始交易单)
func (*TransactionDecoder) CreateTokenSummaryRawTransaction ¶
func (decoder *TransactionDecoder) CreateTokenSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)
CreateTokenSummaryRawTransaction 创建代币汇总交易
func (*TransactionDecoder) CreateTokenTransaction ¶
func (decoder *TransactionDecoder) CreateTokenTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
CreateTokenTransaction 创建代币交易单
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)
SubmitRawTransaction 广播交易单
func (*TransactionDecoder) VerifyRawTransaction ¶
func (decoder *TransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error
VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单
type TransactionExtention ¶
type TransactionExtention struct { Transaction gjson.Result `json:"transaction" ` Txid string `json:"txid"` ConstantResult []string `json:"constant_result"` Result *Return `json:"result"` }
func NewTransactionExtention ¶
func NewTransactionExtention(json *gjson.Result) *TransactionExtention
type TronBlockScanner ¶
type TronBlockScanner struct { *openwallet.BlockScannerBase CurrentBlockHeight uint64 //当前区块高度 RescanLastBlockCount uint64 //重扫上N个区块数量 // contains filtered or unexported fields }
TronBlockScanner tron的区块链扫描器
func NewTronBlockScanner ¶
func NewTronBlockScanner(wm *WalletManager) *TronBlockScanner
NewTronBlockScanner 创建区块链扫描器
func (*TronBlockScanner) BatchExtractTransaction ¶
func (bs *TronBlockScanner) BatchExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, txs []*Transaction) error
BatchExtractTransaction 批量提取交易单 bitcoin 1M的区块链可以容纳3000笔交易,批量多线程处理,速度更快
func (*TronBlockScanner) DeleteUnscanRecord ¶
func (bs *TronBlockScanner) DeleteUnscanRecord(height uint64) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*TronBlockScanner) ExtractTransaction ¶
func (bs *TronBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, blockTime int64, trx *Transaction, scanAddressFunc openwallet.BlockScanTargetFuncV2) ExtractResult
提取交易单
func (*TronBlockScanner) GetBalanceByAddress ¶
func (bs *TronBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)
GetAssetsAccountBalanceByAddress 查询账户相关地址的交易记录
func (*TronBlockScanner) GetCurrentBlockHeader ¶
func (bs *TronBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)
GetCurrentBlockHeader 获取当前区块高度
func (*TronBlockScanner) GetGlobalMaxBlockHeight ¶
func (bs *TronBlockScanner) GetGlobalMaxBlockHeight() uint64
func (*TronBlockScanner) GetLocalBlock ¶
func (bs *TronBlockScanner) GetLocalBlock(height uint64) (*Block, error)
GetLocalBlock 获取本地区块数据
func (*TronBlockScanner) GetLocalNewBlock ¶
func (bs *TronBlockScanner) GetLocalNewBlock() (uint64, string, error)
GetLocalNewBlock 获取本地记录的区块高度和hash
func (*TronBlockScanner) GetScannedBlockHeight ¶
func (bs *TronBlockScanner) GetScannedBlockHeight() uint64
GetScannedBlockHeight 获取已扫区块高度
func (*TronBlockScanner) GetSourceKeyByAddress ¶
func (bs *TronBlockScanner) GetSourceKeyByAddress(address string) (string, bool)
GetSourceKeyByAddress 获取地址对应的数据源标识
func (*TronBlockScanner) GetUnscanRecords ¶
func (bs *TronBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)
func (*TronBlockScanner) InitTronExtractResult ¶
func (bs *TronBlockScanner) InitTronExtractResult(tx *Contract, result *ExtractResult, operate int64)
InitTronExtractResult operate = 0: 输入输出提取,1: 输入提取,2:输出提取
func (*TronBlockScanner) RescanFailedRecord ¶
func (bs *TronBlockScanner) RescanFailedRecord()
rescanFailedRecord 重扫失败记录
func (*TronBlockScanner) SaveLocalBlock ¶
func (bs *TronBlockScanner) SaveLocalBlock(block *Block) error
SaveLocalBlock 记录本地新区块
func (*TronBlockScanner) SaveLocalNewBlock ¶
func (bs *TronBlockScanner) SaveLocalNewBlock(blockHeight uint64, blockHash string) error
SaveLocalNewBlock 记录区块高度和hash到本地
func (*TronBlockScanner) SaveUnscanRecord ¶
func (bs *TronBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error
SaveUnscanRecord 保存交易记录到钱包数据库
func (*TronBlockScanner) ScanBlock ¶
func (bs *TronBlockScanner) ScanBlock(height uint64) error
ScanBlock 扫描指定高度区块
func (*TronBlockScanner) ScanBlockTask ¶
func (bs *TronBlockScanner) ScanBlockTask()
ScanBlockTask 扫描任务
func (*TronBlockScanner) SetRescanBlockHeight ¶
func (bs *TronBlockScanner) SetRescanBlockHeight(height uint64) error
SetRescanBlockHeight 重置区块链扫描高度
func (*TronBlockScanner) SupportBlockchainDAI ¶
func (bs *TronBlockScanner) SupportBlockchainDAI() bool
SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional
type UnscanRecord ¶
type UnscanRecord struct { ID string `storm:"id"` // primary key BlockHeight uint64 TxID string Reason string }
UnscanRecords 扫描失败的区块及交易
func NewUnscanRecord ¶
func NewUnscanRecord(height uint64, txID, reason string) *UnscanRecord
type WalletConfig ¶
type WalletConfig struct { //币种 Symbol string MasterKey string //RPCUser RPC认证账户名 RPCUser string //RPCPassword RPC认证账户密码 RPCPassword string //证书目录 CertsDir string //rpc证书 CertFileName string //区块链数据文件 BlockchainFile string //是否测试网络 IsTestNet bool // 核心钱包是否只做监听 CoreWalletWatchOnly bool //最大的输入数量 MaxTxInputs int //钱包服务API ServerAPI string //钱包安装的路径 NodeInstallPath string //钱包数据文件目录 WalletDataPath string //汇总阀值 Threshold decimal.Decimal //汇总地址 SumAddress string //汇总执行间隔时间 CycleSeconds time.Duration //默认配置内容 DefaultConfig string //曲线类型 CurveType uint32 //小数位长度 CoinDecimal decimal.Decimal //后台数据源类型 RPCServerType int //FeeLimit 智能合约最大能量消耗限制,1 Energy = 140 SUN FeeLimit int64 //FeeMini 智能合约最小能量消耗起,1 Energy = 140 SUN FeeMini int64 //数据目录 DataDir string //Ignore the dust trade IgnoreDustTRX decimal.Decimal //是否扫描主币 ScanMainCoin bool //扫描合约列表 ScanContractList []string // contains filtered or unexported fields }
WalletConfig configs for Wallet
func (*WalletConfig) PrintConfig ¶
func (wc *WalletConfig) PrintConfig() error
PrintConfig Print config information
type WalletManager ¶
type WalletManager struct { openwallet.AssetsAdapterBase Config *WalletConfig //钱包管理配置 Storage *hdkeystore.HDKeystore //秘钥存取 FullnodeClient *Client // 全节点客户端 WalletClient *Client // 节点客户端 Log *log.OWLogger //日志工具 WalletsInSum map[string]*openwallet.Wallet //参与汇总的钱包 Blockscanner *TronBlockScanner //区块扫描器 AddrDecoder openwallet.AddressDecoder //地址编码器 TxDecoder openwallet.TransactionDecoder //交易单编码器 ContractDecoder openwallet.SmartContractDecoder // }
WalletManager struct
func (*WalletManager) BroadcastTransaction ¶
func (wm *WalletManager) BroadcastTransaction(raw string) (string, error)
func (*WalletManager) BroadcastTransaction1 ¶
func (wm *WalletManager) BroadcastTransaction1(raw string) error
BroadcastTransaction Done! Function:Broadcast the signed transaction
demo:curl -X POST http://127.0.0.1:8090/wallet/broadcasttransaction -d ‘ {“signature”:[“97c825b41c77de2a8bd65b3df55cd4c0df59c307c0187e42321dcc1cc455ddba583dd9502e17cfec5945b34cad0511985a6165999092a6dec84c2bdd97e649fc01”], ”txID”:”454f156bf1256587ff6ccdbc56e64ad0c51e4f8efea5490dcbc720ee606bc7b8”, ”raw_data”:{“contract”:[{ “parameter”:{ “value”:{“amount”:1000, ”owner_address”:”41e552f6487585c2b58bc2c9bb4492bc1f17132cd0”, ”to_address”: ”41d1e7a6bc354106cb410e65ff8b181c600ff14292”}, ”type_url”:”type.googleapis.com/protocol.TransferContract”}, ”type”:”TransferContract” }], ”ref_block_bytes”:”267e”, ”ref_block_hash”:”9a447d222e8de9f2”, ”expiration”:1530893064000, ”timestamp”:1530893006233} }’
Parameters:Signed Transaction contract data Return value:broadcast success or failure
func (*WalletManager) CreateAccount ¶
func (wm *WalletManager) CreateAccount(ownerAddress, accountAddress string) (txRaw *gjson.Result, err error)
CreateAccount Done! Function:Create an account. Uses an already activated account to create a new account demo:curl -X POST http://127.0.0.1:8090/wallet/createaccount -d ‘
{ “owner_address”:”41d1e7a6bc354106cb410e65ff8b181c600ff14292”, “account_address”: “41e552f6487585c2b58bc2c9bb4492bc1f17132cd0” }’
Parameters:
Owner_address is an activated account,converted to a hex String; account_address is the address of the new account, converted to a hex string, this address needs to be calculated in advance
Return value:Create account Transaction raw data
func (*WalletManager) CreateAddress ¶
func (wm *WalletManager) CreateAddress(passValue string) (addr string, err error)
CreateAddress Done! Function: Create address from a specified password string (NOT PRIVATE KEY) Demo: curl -X POST http://127.0.0.1:8090/wallet/createaddress -d ‘
{“value”: “7465737470617373776f7264” }’
Parameters:
value is the password, converted from ascii to hex
Return value:
value is the corresponding address for the password, encoded in hex. Convert it to base58 to use as the address.
Warning:
Please control risks when using this API. To ensure environmental security, please do not invoke APIs provided by other or invoke this very API on a public network.
func (*WalletManager) CreateAddressRef ¶
func (wm *WalletManager) CreateAddressRef(key []byte, isPrivate bool) (addr string, err error)
CreateAddressRef Done! Function: Create address from a specified private key string
func (*WalletManager) CreateBatchAddress ¶
func (wm *WalletManager) CreateBatchAddress(name, password string, count uint64) (string, []*openwallet.Address, error)
CreateBatchAddress 批量创建地址
func (*WalletManager) CreateNewWallet ¶
func (wm *WalletManager) CreateNewWallet(name, password string) (*openwallet.Wallet, string, error)
CreateNewWallet 创建钱包
func (*WalletManager) CreateTokenTransaction ¶
func (wm *WalletManager) CreateTokenTransaction(toAddress, ownerAddress string, amount string, contract openwallet.SmartContract) (txRawHex string, err error)
func (*WalletManager) CreateTransaction ¶
func (wm *WalletManager) CreateTransaction(toAddress, ownerAddress string, amount float64) (raw string, err error)
CreateTransaction Writing! Function:Creates a transaction of transfer. If the recipient address does not exist, a corresponding account will be created on the blockchain. demo: curl -X POST http://127.0.0.1:8090/wallet/createtransaction -d ‘
{“to_address”: “41e9d79cc47518930bc322d9bf7cddd260a0260a8d”, “owner_address”: “41D1E7A6BC354106CB410E65FF8B181C600FF14292”, “amount”: 1000 }’ P
Parameters:
To_address is the transfer address, converted to a hex string; owner_address is the transfer transfer address, converted to a hex string; amount is the transfer amount
Return value:
Transaction contract data
func (*WalletManager) CreateTransactionRef ¶
func (wm *WalletManager) CreateTransactionRef(toAddress, ownerAddress string, amount string) (txRawHex string, err error)
Deprecated
func (*WalletManager) DeleteUnscanRecord ¶
func (wm *WalletManager) DeleteUnscanRecord(height uint64) error
DeleteUnscanRecord 删除指定高度的未扫记录
func (*WalletManager) GenerateAddress ¶
func (wm *WalletManager) GenerateAddress() (address map[string]string, err error)
GenerateAddress Done! Function: Generates a random private key and address pair Demo:curl -X POST -k http://127.0.0.1:8090/wallet/generateaddress Parameters:
no parameters.
Return value:
value is the corresponding address for the password, encoded in hex. Convert it to base58 to use as the address.
Warning:
Please control risks when using this API. To ensure environmental security, please do not invoke APIs provided by other or invoke this very API on a public network.
func (*WalletManager) GetAccount ¶
func (wm *WalletManager) GetAccount(address string) (account *openwallet.AssetsAccount, err error)
deprecated GetAccount Done! Function:Query bandwidth information. Parameters:
Account address,converted to a base64 string
Return value:
func (*WalletManager) GetAccountNet ¶
func (wm *WalletManager) GetAccountNet(address string) (accountNet *AccountNet, err error)
GetAccountNet Done! Function:Query bandwidth information. demo: curl -X POST http://127.0.0.1:8090/wallet/getaccountnet -d ‘
{“address”: “4112E621D5577311998708F4D7B9F71F86DAE138B5”}’
Parameters:
Account address,converted to a hex string
Return value:
Bandwidth information for the account. If a field doesn’t appear, then the corresponding value is 0. {“freeNetUsed”: 557,”freeNetLimit”: 5000,”NetUsed”: 353,”NetLimit”: 5239157853,”TotalNetLimit”: 43200000000,”TotalNetWeight”: 41228}
func (*WalletManager) GetAccountResource ¶
func (wm *WalletManager) GetAccountResource(address string) (*AccountResource, error)
GetAccountResource
func (*WalletManager) GetAddressDecode ¶
func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder
GetAddressDecode 地址解析器
func (*WalletManager) GetAddressWithBalance ¶
func (wm *WalletManager) GetAddressWithBalance(address ...*openwallet.Address) error
GetAddressWithBalance 获取地址对应的余额
func (*WalletManager) GetAddressesFromLocalDB ¶
func (wm *WalletManager) GetAddressesFromLocalDB(walletID string, offset, limit int) ([]*openwallet.Address, error)
GetAddressesFromLocalDB 从本地数据库
func (*WalletManager) GetAssetsLogger ¶
func (wm *WalletManager) GetAssetsLogger() *log.OWLogger
GetAssetsLogger 获取资产账户日志工具
func (*WalletManager) GetBlockByID ¶
func (wm *WalletManager) GetBlockByID(blockID string) (block *Block, err error)
GetBlockByID Done! Function:Query block by ID
demo: curl -X POST http://127.0.0.1:8090/wallet/getblockbyid -d ‘ {“value”: “0000000000038809c59ee8409a3b6c051e369ef1096603c7ee723c16e2376c73”}’
Parameters:Block ID. Return value:Block Object
func (*WalletManager) GetBlockByLatestNum ¶
func (wm *WalletManager) GetBlockByLatestNum(num uint64) (blocks []*Block, err error)
GetBlockByLatestNum Done! Function:Query the latest blocks
demo: curl -X POST http://127.0.0.1:8090/wallet/getblockbylatestnum -d ‘ {“num”: 5}’
Parameters:The number of blocks to query Return value:A list of Block Objects
func (*WalletManager) GetBlockByLimitNext ¶
func (wm *WalletManager) GetBlockByLimitNext(startNum, endNum uint64) (blocks []*Block, err error)
GetBlockByLimitNext Done! Function:Query a range of blocks by block height
demo: curl -X POST http://127.0.0.1:8090/wallet/getblockbylimitnext -d ‘ {“startNum”: 1, “endNum”: 2}’
Parameters:
startNum:Starting block height, including this block endNum:Ending block height, excluding that block
Return value:A list of Block Objects
func (*WalletManager) GetBlockByNum ¶
func (wm *WalletManager) GetBlockByNum(num uint64) (block *Block, error error)
GetBlockByNum Done! Function:Query block by height
demo: curl -X POST http://127.0.0.1:8090/wallet/getblockbynum -d ‘ {“num” : 100}’
Parameters:
Num is the height of the block
Return value:specified Block object
func (*WalletManager) GetBlockScanner ¶
func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner
GetBlockScanner 获取区块链
func (*WalletManager) GetContractInfo ¶
func (wm *WalletManager) GetContractInfo(contractAddress string) (*ContractInfo, error)
GetContractInfo 获取智能合约信息
func (*WalletManager) GetCurrentBlock ¶
func (wm *WalletManager) GetCurrentBlock() (block *Block, err error)
func (*WalletManager) GetNowBlock ¶
func (wm *WalletManager) GetNowBlock() (block *Block, err error)
GetNowBlock Done! Function:Query the latest block
demo: curl -X POST http://127.0.0.1:8090/wallet/getnowblock
Parameters:None Return value:Latest block on full node
func (*WalletManager) GetPrivateKeyRef ¶
func (wm *WalletManager) GetPrivateKeyRef(walletID, password string, index uint64, serializes uint32) (string, error)
GetPrivateKeyRef 找到地址索引对应的私钥,返回私钥hex格式字符串
func (*WalletManager) GetSmartContractDecoder ¶
func (this *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder
func (*WalletManager) GetTRC10Balance ¶
GetTokenBalance 获取代币余额
func (*WalletManager) GetTRC20Balance ¶
GetTokenBalance 获取代币余额
func (*WalletManager) GetTRXAccount ¶
func (wm *WalletManager) GetTRXAccount(address string) (account *Account, exist bool, err error)
GetAccount Done! Function:Query bandwidth information. Parameters:
Account address,converted to a base64 string
Return value:
func (*WalletManager) GetTotalTransaction ¶
func (wm *WalletManager) GetTotalTransaction() (num uint64, err error)
GetTotalTransaction Done! Function:Count all transactions (number) on the network demo: curl -X POST http://127.0.0.1:8090/wallet/totaltransaction Parameters:Nones Return value:
Total number of transactions.
func (*WalletManager) GetTransaction ¶
func (wm *WalletManager) GetTransaction(txid string, blockhash string, blockheight uint64, blocktime int64) (*Transaction, error)
func
func (*WalletManager) GetTransactionBurnFee ¶
func (wm *WalletManager) GetTransactionBurnFee(txid string) (string, error)
func (*WalletManager) GetTransactionDecoder ¶
func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder
GetTransactionDecoder 交易单解析器
func (*WalletManager) GetTransactionFeeEstimated ¶
func (wm *WalletManager) GetTransactionFeeEstimated(from string, data string) (*txFeeInfo, error)
GetTransactionFeeEstimated 预计手续费
func (*WalletManager) GetTransactionSign ¶
func (wm *WalletManager) GetTransactionSign(transaction, privateKey string) (rawSinged []byte, err error)
Writing! No used! Function:Sign the transaction, the api has the risk of leaking the private key, please make sure to call the api in a secure environment
demo: curl -X POST http://127.0.0.1:8090/wallet/gettransactionsign -d ‘ { “transaction” : {“txID”:”454f156bf1256587ff6ccdbc56e64ad0c51e4f8efea5490dcbc720ee606bc7b8”, ”raw_data”:{ “contract”:[{“parameter”:{“value”:{“amount”:1000, ”owner_address”:”41e552f6487585c2b58bc2c9bb4492bc1f17132cd0”, ”to_address”:”41d1e7a6bc354106cb410e65ff8b181c600ff14292”}, ”type_url”:”type.googleapis.com/protocol.TransferContract”}, ”type”:”TransferContract”}], ”ref_block_bytes”:”267e”, ”ref_block_hash”:”9a447d222e8de9f2”, ”expiration”:1530893064000, ”timestamp”:1530893006233}} “privateKey” : “your private key”} }’
Parameters:
Transaction is a contract created by http api, privateKey is the user private key
Return value:Signed Transaction contract data
func (*WalletManager) GetWalletBalance ¶
func (wm *WalletManager) GetWalletBalance(accountID string) string
GetWalletBalance 获取钱包余额
func (*WalletManager) GetWalletInfo ¶
func (wm *WalletManager) GetWalletInfo(walletID string) (*openwallet.Wallet, error)
GetWalletInfo 获取钱包列表
func (*WalletManager) GetWalletList ¶
func (wm *WalletManager) GetWalletList() error
GetWalletList 获取钱包列表
func (*WalletManager) GetWallets ¶
func (wm *WalletManager) GetWallets() ([]*openwallet.Wallet, error)
GetWallets 获取钱包列表
func (*WalletManager) Getbalance ¶
func (wm *WalletManager) Getbalance(address string) (*AddrBalance, error)
deprecated
func (*WalletManager) ImportWatchOnlyAddress ¶
func (wm *WalletManager) ImportWatchOnlyAddress(address ...*openwallet.Address) error
ImportWatchOnlyAddress 导入观测地址
func (*WalletManager) IsEnoughEnergyToTransferTRC20 ¶
func (wm *WalletManager) IsEnoughEnergyToTransferTRC20(address string, trxBalance *big.Int) (flag bool, energyRest int64, feeMini int64)
IsEnoughEnergyToTransferTRC20 是否足够能量转账TRC20
func (*WalletManager) ListNodes ¶
func (wm *WalletManager) ListNodes() (nodes []string, err error)
ListNodes Writing! Function:
List the nodes which the api fullnode is connecting on the network
demo:
curl -X POST http://127.0.0.1:8090/wallet/listnodes
Parameters:None Return value:List of nodes
func (*WalletManager) ListWitnesses ¶
func (wm *WalletManager) ListWitnesses() (witnesses string, err error)
ListWitnesses Writing! Function:
Query the list of Super Representatives
demo:
curl -X POSThttp://127.0.0.1:8090/wallet/listwitnesses
Parameters:None Return value:List of all Super Representatives
func (*WalletManager) LoadAssetsConfig ¶
func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error
LoadAssetsConfig 加载外部配置
func (*WalletManager) RestoreWalletFlow ¶
func (wm *WalletManager) RestoreWalletFlow() error
RestoreWalletFlow 恢复钱包流程
func (*WalletManager) SendTransaction ¶
func (wm *WalletManager) SendTransaction(walletID, to string, amount decimal.Decimal, password string, feesInSender bool) ([]string, error)
SendTransaction 发送交易
func (*WalletManager) SignTransactionRef ¶
func (wm *WalletManager) SignTransactionRef(hash string, privateKey string) (signedTxRaw string, err error)
func (*WalletManager) SummaryFollow ¶
func (wm *WalletManager) SummaryFollow() error
SummaryFollow 汇总流程
func (*WalletManager) SummaryWallets ¶
func (wm *WalletManager) SummaryWallets()
SummaryWallets 执行汇总流程
func (*WalletManager) TriggerSmartContract ¶
func (wm *WalletManager) TriggerSmartContract( contractAddress string, function string, parameter string, feeLimit uint64, callValue uint64, ownerAddress string) (*TransactionExtention, error)
TriggerSmartContract 初始智能合约方法
func (*WalletManager) UpdateAccount ¶
func (wm *WalletManager) UpdateAccount(accountName, ownerAddress string) (tx *gjson.Result, err error)
UpdateAccount Done! Function:Modify account name demo:curl -X POSThttp://127.0.0.1:8090/wallet/updateaccount -d ‘
{ “account_name”: “0x7570646174654e616d6531353330383933343635353139” , ”owner_address”:”41d1e7a6bc354106cb410e65ff8b181c600ff14292” }’
Parameters:
account_name is the name of the account, converted into a hex string; owner_address is the account address of the name to be modified, converted to a hex string.
Return value:modified Transaction Object
func (*WalletManager) ValidSignedTokenTransaction ¶
func (wm *WalletManager) ValidSignedTokenTransaction(txHex string) error
func (*WalletManager) ValidSignedTransactionRef ¶
func (wm *WalletManager) ValidSignedTransactionRef(txHex string) error
Deprecated
func (*WalletManager) ValidateAddress ¶
func (wm *WalletManager) ValidateAddress(address string) (err error)
ValidateAddress Done! Function:validate address Demo: curl -X POST http://127.0.0.1:8090/wallet/validateaddress -d ‘
{“address”: “4189139CB1387AF85E3D24E212A008AC974967E561”}’
Parameters:
The address, should be in base58checksum, hexString or base64 format.
Return value: ture or false
Source Files ¶
- addr_decoder.go
- api.go
- blockscanner.go
- blockscanner_db.go
- config.go
- config_load.go
- contract.go
- manager.go
- manager_account.go
- manager_addr.go
- manager_addrRef.go
- manager_block.go
- manager_keyRef.go
- manager_tx.go
- manager_txRef.go
- manager_wallet.go
- manager_walletRef.go
- manager_witness.go
- models.go
- tron.go
- tx_decode.go