trx

package
v0.0.0-...-450f598 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//TrxPrefix .
	TrxPrefix = "TRX"
)

Variables

This section is empty.

Functions

func Address2Hex

func Address2Hex(address string) string

Address2Hex .

func Hex2Address

func Hex2Address(hexStr string) (string, error)

Hex2Address .

Types

type Account

type Account struct {
	AccountName string         `json:"account_name"`
	Address     string         `json:"address"`
	Balance     uint64         `json:"balance"`
	Asset       []AccountAsset `json:"assetV2"`
}

Account .

type AccountAsset

type AccountAsset struct {
	Key   string `json:"key"`
	Value uint64 `json:"value"`
}

AccountAsset .

type Block

type Block struct {
	BlockID      string               `json:"blockID"`
	BlockHeader  BlockHeader          `json:"block_header"`
	Transactions []TransactionReceipt `json:"transactions"`
}

Block .

type BlockHeader

type BlockHeader struct {
	RawData          BlockRawData `json:"raw_data"`
	WitnessSignature string       `json:"witness_signature"`
}

BlockHeader .

type BlockRawData

type BlockRawData struct {
	Number         int64  `json:"number"`
	TxTrieRoot     string `json:"txTrieRoot"`
	WitnessAddress string `json:"witness_address"`
	ParentHash     string `json:"parentHash"`
	Version        uint   `json:"version"`
	Timestamp      uint64 `json:"timestamp"`
}

BlockRawData .

type Client

type Client interface {
	GetAccount(address string) (*Account, error)
	GetBalance(addr string, asset string) (uint64, error)
	CreateTransaction(from, to, asset string, amount uint32) (*CreateTransactionResponse, error)
	// Transfer(keyManager KeyManager, transfers []Transfer) (*TxCommitResult, error)
	// GetTokens() ([]Token, error)
	GetTransactionReceipt(txid string) (*TransactionReceipt, error)
	GetTransactionFee(txid string) (*Fee, error)
	GetBlockByNumber(height uint32) (*Block, error)
	BestBlockNumber() (uint32, error)
	SendRawTransaction(tx []byte) (string, error)
}

Client .

func New

func New(apiURL string) Client

New .

type CreateTransactionResponse

type CreateTransactionResponse struct {
	Visible    bool     `json:"visible"`
	TxID       string   `json:"txID"`
	RawData    RawData  `json:"raw_data"`
	RawDataHex string   `json:"raw_data_hex"`
	Signature  []string `json:"signature"`
}

CreateTransactionResponse .

type Fee

type Fee struct {
	TxID           string `json:"id"`
	Fee            uint64 `json:"fee"`
	BlockNumber    uint64 `json:"blockNumber"`
	BlockTimeStamp uint64 `json:"blockTimeStamp"`
}

Fee .

type Parameter

type Parameter struct {
	Value   ParameterValue `json:"value"`
	TypeURL string         `json:"type_url"`
}

Parameter .

type ParameterValue

type ParameterValue struct {
	OwnerAddress    string `json:"owner_address"`
	Amount          uint64 `json:"amount"`           //transaction receipt interface 含有
	AssetName       string `json:"asset_name"`       //transaction receipt interface 含有
	ToAddress       string `json:"to_address"`       //transaction receipt interface 含有
	Data            string `json:"data"`             //block interface 含有
	ContractAddress string `json:"contract_address"` //block interface 含有
}

ParameterValue .

type RawData

type RawData struct {
	Contract      []RawDataContractInfo `json:"contract"`
	RefBlockBytes string                `json:"ref_block_bytes"`
	RefBlockHash  string                `json:"ref_block_hash"`
	Expiration    uint64                `json:"expiration"`
	Timestamp     uint64                `json:"timestamp"`
}

RawData .

type RawDataContractInfo

type RawDataContractInfo struct {
	Parameter Parameter `json:"parameter"`
	Type      string    `json:"type"`
}

RawDataContractInfo .

type RetInfo

type RetInfo struct {
	ContractRet string `json:"contractRet"`
}

RetInfo .

type Transaction

type Transaction struct {
	ParameterValue
	TxID   string `json:"tx_id"`
	State  string `json:"state"`
	TxType string `json:"tx_type"`
}

Transaction .

type TransactionReceipt

type TransactionReceipt struct {
	Ret        []RetInfo `json:"ret"`
	Signature  []string  `json:"signature"`
	TxID       string    `json:"txID"`
	RawDataHex string    `json:"raw_data_hex"`
	RawData    RawData   `json:"raw_data"`
}

TransactionReceipt .

Jump to

Keyboard shortcuts

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