txflow

package
v0.0.41 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package txflow holds the shared types and helpers used by both the transaction broadcaster and the resolver. Each module owns its own lifecycle (broadcaster pushes SIGNED→BROADCASTED, resolver pulls BROADCASTED→terminal), but they read the same persisted event payloads and apply the same rules (signed-vs-finalized nonce comparison, signing data decoding). Lifting those shared concerns here gives one source of truth without conflating the two modules' responsibilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeSigningData

func DecodeSigningData(sd *SigningData) (*common.UnsignedSigningReq, []byte, error)

DecodeSigningData converts the persisted hex-encoded signature + signing hash into the byte forms the chain-specific tx builders consume.

func ReadFundMigrationSigner

func ReadFundMigrationSigner(event *store.Event) (signer string, nonce uint64, ok bool)

ReadFundMigrationSigner derives the sender EVM address (old TSS) and reads the signed nonce from a fund migration event payload. Returns ok=false on missing/invalid fields — caller defers in that case.

func ReadSignedNonce

func ReadSignedNonce(event *store.Event) (uint64, bool)

ReadSignedNonce extracts the signed nonce from any signed outbound event payload. Returns ok=false when the payload is unparseable or signing data is missing — caller defers in that case.

func ReadSigningDeadline

func ReadSigningDeadline(event *store.Event) int64

ReadSigningDeadline extracts the chain-emitted signing deadline from a signed outbound event payload. Returns 0 if the event is unparseable or the deadline was never set (legacy events).

Types

type NonceVerdict

type NonceVerdict int

NonceVerdict captures the outcome of comparing the signed nonce against the chain's finalized nonce. EVM-only — SVM does not use nonces this way.

const (
	// NonceUnknown means the RPC failed and the caller should defer the decision.
	NonceUnknown NonceVerdict = iota
	// NonceConsumed means the chain advanced past the signed nonce. Some other
	// tx took that slot; our signed tx can never land.
	NonceConsumed
	// NonceAvailable means the chain hasn't consumed the signed nonce yet. The
	// tx may still be in mempool, or was dropped — a re-broadcast may land it.
	NonceAvailable
)

func CheckNonce

func CheckNonce(ctx context.Context, builder common.TxBuilder, signer string, signedNonce uint64) (NonceVerdict, uint64)

CheckNonce compares signedNonce against the chain's finalized nonce for `signer`. Used by:

  • broadcaster (post-broadcast-error path) to detect "the tx already landed via another node despite our RPC error"
  • resolver (tx-not-found path) to distinguish dead tx (REVERT) from mempool-drop (rewind to SIGNED).

The returned finalizedNonce is for logging / observability.

type SignedFundMigrationData

type SignedFundMigrationData struct {
	utsstypes.FundMigrationInitiatedEventData
	SigningData *SigningData `json:"signing_data,omitempty"`
}

SignedFundMigrationData wraps FundMigrationInitiatedEventData with the signing data needed for the migration sweep tx.

type SignedOutboundData

type SignedOutboundData struct {
	uexecutortypes.OutboundCreatedEvent
	SigningData *SigningData `json:"signing_data,omitempty"`
}

SignedOutboundData wraps OutboundCreatedEvent with the signing data the broadcaster needs to assemble the destination-chain tx.

type SigningData

type SigningData struct {
	Signature              string   `json:"signature"`    // hex-encoded 64/65 byte signature
	SigningHash            string   `json:"signing_hash"` // hex-encoded signing hash
	Nonce                  uint64   `json:"nonce"`
	TSSFundMigrationAmount *big.Int `json:"tss_fund_migration_amount,omitempty"`
}

SigningData holds the signing parameters persisted by sessionManager when marking an event SIGNED. Both broadcaster and resolver read these fields — broadcaster to assemble + send the tx, resolver to compare the signed nonce against the chain's finalized nonce.

Jump to

Keyboard shortcuts

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