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 ¶
- func DecodeSigningData(sd *SigningData) (*common.UnsignedSigningReq, []byte, error)
- func ReadFundMigrationSigner(event *store.Event) (signer string, nonce uint64, ok bool)
- func ReadSignedNonce(event *store.Event) (uint64, bool)
- func ReadSigningDeadline(event *store.Event) int64
- func RecoverOutboundSigner(event *store.Event) (signer string, nonce uint64, ok bool)
- type NonceVerdict
- type SignedFundMigrationData
- type SignedOutboundData
- type SigningData
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 ¶
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, and the caller defers in that case.
func ReadSignedNonce ¶
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 ¶
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).
func RecoverOutboundSigner ¶ added in v0.0.48
RecoverOutboundSigner returns the EVM address that actually signed a SIGNED or BROADCASTED outbound, recovered from the persisted signature and signing hash.
Nonces are per-EOA, so a nonce check is only meaningful against the key that signed. Outbound SigningData carries no key id, and after a TSS rotation the current key is a different EOA with an unrelated nonce sequence — comparing a K1-signed nonce against K2's would report "consumed" while K1's nonce is still free. Recovering from the signature binds the check to the right key without persisting anything new, so events signed before this existed are covered too.
Returns ok=false when the signer cannot be established, which callers must treat as "defer", never as evidence the transaction did not execute.
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"`
}
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.