go_tronsdk

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeoutSeconds       = 30
	DefaultGetTxIntervalSeconds = 5
)
View Source
const (
	MaxCommitteeSize           = 27
	ConfirmedSize              = 19
	MaintenanceTimeIntervalKey = "getMaintenanceTimeInterval"
)
View Source
const (
	JsonContentType = "application/json"
)

Variables

View Source
var (
	ErrInvalidTx          = errors.New("invalid transaction")
	ErrNotTriggerContract = errors.New("not trigger contract")
	ErrTxNotFound         = errors.New("transation not found")
	ErrTxResultNotFound   = errors.New("transaction result not found")
)

Functions

func ByteToPublicKey

func ByteToPublicKey(pub []byte) (*ecdsa.PublicKey, error)

func BytesToPrivateKey

func BytesToPrivateKey(priv []byte) (*ecdsa.PrivateKey, error)

func HashMessage added in v0.2.0

func HashMessage(m proto.Message) ([]byte, error)

func ParseContractTxResult added in v0.2.0

func ParseContractTxResult(tx *core.Transaction, runErr error) (fee int64, err error)

Types

type HTTPError

type HTTPError struct {
	StatusCode int
	Status     string
	Body       []byte
}

func (HTTPError) Error

func (err HTTPError) Error() string

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient(basePath string, timeoutSeconds int64) *HttpClient

func (*HttpClient) Close

func (c *HttpClient) Close()

func (*HttpClient) GetNextMaintenanceTime

func (c *HttpClient) GetNextMaintenanceTime(cctx context.Context) (time.Time, error)

type Receipt added in v0.2.0

type Receipt struct {
	BlockNum           int64
	Timestamp          int64
	TxId               []byte
	From               []byte
	To                 []byte
	Input              []byte
	Output             []byte
	EnergyUsage        int64
	EnergyPenaltyTotal int64
	EnergyTotal        int64
	EnergyFee          int64
	OriginEnergyUsage  int64
	NetUsage           int64
	NetFee             int64
	Logs               []*core.TransactionInfo_Log
	Succeed            bool
	Err                error
}

type TronClient

type TronClient struct {
	GetTxInterval time.Duration
	// contains filtered or unexported fields
}

func NewTronClient

func NewTronClient(cctx context.Context, httpurl, grpcurl, ethurl string,
	timeoutSeconds, getTxIntervalSeconds int64) (tc *TronClient, errr error)

func (*TronClient) CallContract added in v0.2.0

func (c *TronClient) CallContract(cctx context.Context, from, contract address.Address, data []byte) (*api.TransactionExtention, error)

func (*TronClient) ChainId added in v0.2.0

func (c *TronClient) ChainId() *big.Int

func (*TronClient) Close

func (c *TronClient) Close() (err error)

func (*TronClient) FilterLogs

func (c *TronClient) FilterLogs(cctx context.Context, from, to int64, addr []byte, topicss ...[][]byte) ([]types.Log, error)

[from, to]

func (*TronClient) GetAccount added in v0.2.0

func (c *TronClient) GetAccount(cctx context.Context, addr []byte) (*core.Account, error)

func (*TronClient) GetBlock added in v0.2.0

func (c *TronClient) GetBlock(cctx context.Context, num int64) (*api.BlockExtention, error)

func (*TronClient) GetBlockHeader

func (c *TronClient) GetBlockHeader(cctx context.Context, num int64) (*api.BlockExtention, error)

func (*TronClient) GetBlocks

func (c *TronClient) GetBlocks(cctx context.Context, start, end int64) ([]*api.BlockExtention, error)

[start, end)

func (*TronClient) GetContract added in v0.2.0

func (c *TronClient) GetContract(cctx context.Context, addr []byte) (*core.SmartContract, error)

func (*TronClient) GetMaintenanceTimeInterval

func (c *TronClient) GetMaintenanceTimeInterval(cctx context.Context) (time.Duration, error)

func (*TronClient) GetNextMaintenanceTime

func (c *TronClient) GetNextMaintenanceTime(cctx context.Context) (time.Time, error)

func (*TronClient) GetNowBlock

func (c *TronClient) GetNowBlock(cctx context.Context) (*api.BlockExtention, error)

func (*TronClient) GetTransactionById

func (c *TronClient) GetTransactionById(cctx context.Context, txHash []byte) (*core.Transaction, error)

func (*TronClient) GetTransactionInfoById added in v0.2.0

func (c *TronClient) GetTransactionInfoById(cctx context.Context, txHash []byte) (*core.TransactionInfo, error)

func (*TronClient) ListCommittees

func (c *TronClient) ListCommittees(ctx context.Context) ([]*WitnessPerm, error)

func (*TronClient) ParseReturn added in v0.2.0

func (c *TronClient) ParseReturn(ret *api.Return) error

func (*TronClient) String

func (c *TronClient) String() string

func (*TronClient) TriggerContract

func (c *TronClient) TriggerContract(cctx context.Context, feeLimit int64,
	fromPriv []byte, contract address.Address, value int64, data []byte) (*api.TransactionExtention, error)

func (*TronClient) TriggerContractResult

func (c *TronClient) TriggerContractResult(cctx context.Context, txId []byte) (*core.Transaction, error)

func (*TronClient) TryTxByHash

func (c *TronClient) TryTxByHash(cctx context.Context, txId []byte) (*core.Transaction, error)

func (*TronClient) WitnessPermissions

func (c *TronClient) WitnessPermissions(ctx context.Context, addr address.Address) (*WitnessPerm, error)

type Tx added in v0.2.0

type Tx core.Transaction

func (*Tx) IsTriggerSmartContract added in v0.2.0

func (t *Tx) IsTriggerSmartContract() (*core.TriggerSmartContract, error)

func (*Tx) MerkleHash added in v0.2.0

func (t *Tx) MerkleHash() ([]byte, error)

func (*Tx) ToResult added in v0.2.0

func (t *Tx) ToResult(mustSuccess ...bool) (fee int64, err error)

ToResult mustSuccess default as false, which means Transaction_Result_DEFAULT result is ok. set to true, ContractRet must be Transaction_Result_UCCESS

type TxEx added in v0.2.0

func (*TxEx) ToResult added in v0.2.0

func (txx *TxEx) ToResult(mustSuccess ...bool) (energy int64, output []byte, err error)

type TxInfo added in v0.2.0

type TxInfo core.TransactionInfo

func (*TxInfo) ToReceipt added in v0.2.0

func (i *TxInfo) ToReceipt() (*Receipt, error)

type TxReturn added in v0.2.0

type TxReturn api.Return

func (*TxReturn) Err added in v0.2.0

func (ret *TxReturn) Err() error

type WitnessPerm

type WitnessPerm struct {
	OwnerAddr   address.Address
	WitnessAddr address.Address
}

func (*WitnessPerm) WitnessPermAddr

func (p *WitnessPerm) WitnessPermAddr() address.Address

Jump to

Keyboard shortcuts

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