txcore

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package txcore provides shared transaction signing, broadcasting, and confirmation logic used by both txbuilder and contract packages.

Index

Constants

View Source
const DefaultPollInterval = 2 * time.Second

DefaultPollInterval is the default interval between confirmation checks.

Variables

This section is empty.

Functions

func ApplyMemo

func ApplyMemo(tx *api.TransactionExtention, memo string)

ApplyMemo sets the memo on the transaction.

func ApplyPermissionID

func ApplyPermissionID(tx *api.TransactionExtention, id int32)

ApplyPermissionID sets the permission ID on all contracts in the transaction.

func RecomputeTxID

func RecomputeTxID(tx *api.TransactionExtention) error

RecomputeTxID recomputes the transaction ID after mutations.

func TransactionID

func TransactionID(tx *core.Transaction) (string, error)

TransactionID computes the hex-encoded SHA-256 hash of the marshalled RawData, which is the canonical TRON transaction ID.

Types

type Broadcaster

type Broadcaster interface {
	BroadcastCtx(ctx context.Context, tx *core.Transaction) (*api.Return, error)
	GetTransactionInfoByIDCtx(ctx context.Context, id string) (*core.TransactionInfo, error)
}

Broadcaster abstracts the gRPC calls needed for sending and confirming transactions.

type Receipt

type Receipt = txresult.Receipt

Receipt is an alias for the shared receipt type.

func Send

Send signs and broadcasts a transaction, returning a Receipt.

Note: When result.Code != 0 (broadcast rejected), Send returns a nil Go error but sets receipt.Error. Callers MUST check receipt.Error in addition to the returned error.

func SendAndConfirm

func SendAndConfirm(ctx context.Context, b Broadcaster, s signer.Signer, tx *core.Transaction, pollInterval time.Duration) (*Receipt, error)

SendAndConfirm sends a transaction and polls until confirmed or the context is cancelled.

func WaitForConfirmation

func WaitForConfirmation(ctx context.Context, b Broadcaster, receipt *Receipt, pollInterval time.Duration) (*Receipt, error)

WaitForConfirmation polls for transaction confirmation.

Jump to

Keyboard shortcuts

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