ethtx

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0, MIT Imports: 12 Imported by: 0

Documentation

Overview

EIP-1559 Ethereum transaction codec for the Filecoin FEVM write path (lantern#45 Stage 3). Decodes a signed raw EIP-1559 tx (0x02-prefixed RLP) into its fields, recovers the sender, and converts it to a Filecoin SignedMessage with a SigTypeDelegated signature — the exact shape MpoolPush / the gossipsub /fil/msgs topic expect.

Ported in shape (NOT by import) from Lotus chain/types/ethtypes, which pulls in filecoin-ffi via the chain build and is therefore unusable here. We support EIP-1559 only: that's what FEVM / curio-core sends. Legacy + EIP-2930 are explicitly rejected.

CGO-free.

Minimal RLP codec for EIP-1559 Ethereum transactions (lantern#45 Stage 3). Ported in shape from go-ethereum / Lotus ethtypes RLP, kept deliberately narrow: we only need to decode/encode the flat structures an EIP-1559 tx uses (byte strings + a single top-level list, with one empty nested list for the access list). No structs, no recursion beyond one level of nesting, no streaming.

CGO-free, no go-ethereum dependency.

Index

Constants

View Source
const (
	// EIP1559TxType is the type byte prefixing an EIP-1559 tx envelope.
	EIP1559TxType = 0x02
)

Variables

This section is empty.

Functions

func DecodeRLP

func DecodeRLP(data []byte) (interface{}, error)

DecodeRLP decodes a single RLP item from data. Returns []byte for a string item or []interface{} for a list. Errors if there is trailing data after the first complete item (callers decode exactly one tx).

func EncodeRLP

func EncodeRLP(val interface{}) ([]byte, error)

EncodeRLP encodes a value that is either []byte or []interface{} (whose elements are themselves RLP-encodable) into RLP bytes.

Types

type Eth1559Tx

type Eth1559Tx struct {
	ChainID              uint64
	Nonce                uint64
	To                   *[20]byte // nil => contract creation (EAM CreateExternal)
	Value                big.Int
	MaxFeePerGas         big.Int
	MaxPriorityFeePerGas big.Int
	GasLimit             uint64
	Input                []byte

	// Signature components (set when decoding a signed tx).
	V big.Int
	R big.Int
	S big.Int
}

Eth1559Tx is the decoded form of an EIP-1559 transaction.

func ParseSignedEIP1559

func ParseSignedEIP1559(data []byte) (*Eth1559Tx, error)

ParseSignedEIP1559 decodes a signed raw EIP-1559 tx (the bytes a client passes to eth_sendRawTransaction, with or without a 0x prefix already stripped by the caller).

func (*Eth1559Tx) EncodeSigned

func (tx *Eth1559Tx) EncodeSigned() ([]byte, error)

EncodeSigned returns the full signed EIP-1559 envelope (type byte || signed RLP) — the bytes a client would pass to eth_sendRawTransaction. Exported so callers (and tests) can construct raw txs without a wallet.

func (*Eth1559Tx) Sender

func (tx *Eth1559Tx) Sender() ([20]byte, error)

Sender recovers the eth sender address (20 bytes) from the signature.

func (*Eth1559Tx) SenderFilecoin

func (tx *Eth1559Tx) SenderFilecoin() (address.Address, error)

SenderFilecoin returns the sender as its f4/EAM delegated Filecoin address.

func (*Eth1559Tx) SetSignature

func (tx *Eth1559Tx) SetSignature(sig []byte) error

SetSignature fills V/R/S from a 65-byte [R||S||V] recoverable signature (the shape go-crypto.Sign returns).

func (*Eth1559Tx) SigningHash

func (tx *Eth1559Tx) SigningHash() ([]byte, error)

SigningHash exposes the keccak256 hash that must be signed to produce a valid signature for this tx (the preimage ecrecover runs against).

func (*Eth1559Tx) ToSignedFilecoinMessage

func (tx *Eth1559Tx) ToSignedFilecoinMessage() (*types.SignedMessage, error)

ToSignedFilecoinMessage converts the decoded+verified tx into the Filecoin SignedMessage shape MpoolPush expects: an unsigned Message (from = recovered sender) plus a SigTypeDelegated signature carrying the 65-byte r||s||v.

func (*Eth1559Tx) TxHash

func (tx *Eth1559Tx) TxHash() ([32]byte, error)

TxHash returns the eth transaction hash = keccak256 of the full signed envelope (type byte || signed RLP). This is what eth_sendRawTransaction returns to the client.

Jump to

Keyboard shortcuts

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