txcore

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: LGPL-3.0 Imports: 13 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

View Source
var ErrPQSchemeDisabled = errors.New("post-quantum signature scheme disabled on node")

ErrPQSchemeDisabled is returned by Send when the signer uses a post-quantum signature scheme that the connected node has not enabled.

Experimental: TIP-899 post-quantum support is a draft and may change.

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. Call it before signing: the permission ID is part of the signed digest, so changing it on a transaction that already carries signatures invalidates them and the node rejects it. transaction.Controller refuses that case (see WithPermissionID).

func CheckPQSchemes added in v0.27.0

func CheckPQSchemes(ctx context.Context, p PQProber, tx *core.Transaction, pending ...core.PQScheme) error

CheckPQSchemes asks p whether each distinct post-quantum scheme on tx.PqAuthSig, then each pending scheme, is enabled on the node, and returns an error wrapping ErrPQSchemeDisabled for one that is not. Before signing, pass the scheme you will sign with as pending; after signing outside Send, call it before BroadcastCtx. A pending scheme this SDK does not know wraps pqc.ErrUnsupportedScheme. With nothing to probe, p may be nil.

Experimental: TIP-899 is a draft and is live only on the Nile testnet.

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 PQProber added in v0.27.0

type PQProber interface {
	PQSchemeAllowedCtx(ctx context.Context, scheme core.PQScheme) (bool, error)
}

PQProber is implemented by broadcasters that can ask the node whether a TIP-899 post-quantum scheme is enabled, such as *client.GrpcClient.

Experimental: TIP-899 is a draft and is live only on the Nile testnet.

type PQSchemeSigner added in v0.27.0

type PQSchemeSigner interface {
	PQScheme() core.PQScheme
}

PQSchemeSigner is implemented by signers that sign with a TIP-899 post-quantum key, such as the one signer.NewPQSigner returns.

Experimental: TIP-899 is a draft and is live only on the Nile testnet.

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.

Experimental: if s is a PQSchemeSigner (as signer.NewPQSigner returns) and b is a PQProber (as *client.GrpcClient is), Send asks the node whether the scheme is enabled before signing. If it is not, Send returns an error wrapping ErrPQSchemeDisabled without signing or broadcasting. If either interface is missing, no probe is made and Send behaves as it does for any other signer; the node still rejects a disabled scheme at broadcast. A Broadcaster that wraps *client.GrpcClient must implement PQProber itself (usually by forwarding to the client) to keep the early check.

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