Documentation ¶
Index ¶
- Constants
- Variables
- func DeriveChainId(v *uint256.Int) *uint256.Int
- func Sender(signer Signer, tx *Transaction) (types.Address, error)
- type AccessList
- type AccessListTx
- type AccessTuple
- type DynamicFeeTx
- type EIP155Signer
- func (s EIP155Signer) ChainID() *big.Int
- func (s EIP155Signer) Equal(s2 Signer) bool
- func (s EIP155Signer) Hash(tx *Transaction) types.Hash
- func (s EIP155Signer) Sender(tx *Transaction) (types.Address, error)
- func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error)
- type FrontierSigner
- func (s FrontierSigner) ChainID() *big.Int
- func (s FrontierSigner) Equal(s2 Signer) bool
- func (fs FrontierSigner) Hash(tx *Transaction) types.Hash
- func (fs FrontierSigner) Sender(tx *Transaction) (types.Address, error)
- func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
- type HomesteadSigner
- type LegacyTx
- type Message
- func (m Message) AccessList() AccessList
- func (m Message) CheckNonce() bool
- func (m Message) Data() []byte
- func (m Message) FeeCap() *uint256.Int
- func (m Message) From() types.Address
- func (m Message) Gas() uint64
- func (m Message) GasPrice() *uint256.Int
- func (m Message) IsFree() bool
- func (m Message) Nonce() uint64
- func (m *Message) SetCheckNonce(checkNonce bool)
- func (m *Message) SetIsFree(isFree bool)
- func (m Message) Tip() *uint256.Int
- func (m Message) To() *types.Address
- func (m Message) Value() *uint256.Int
- type SakuragiTx
- type Signer
- type Transaction
- func FromProtoMessage(message proto.Message) (*Transaction, error)
- func NewContractCreation(nonce uint64, amount *uint256.Int, gasLimit uint64, gasPrice *uint256.Int, ...) *Transaction
- func NewTransaction(nonce uint64, from types.Address, to *types.Address, amount *uint256.Int, ...) *Transaction
- func NewTx(inner TxData) *Transaction
- func SignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) (*Transaction, error)
- func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)
- func (tx *Transaction) AccessList() AccessList
- func (tx *Transaction) AsMessage(s Signer, baseFee *uint256.Int) (Message, error)
- func (tx *Transaction) ChainId() *uint256.Int
- func (tx *Transaction) Cost() *uint256.Int
- func (tx *Transaction) Data() []byte
- func (tx *Transaction) EffectiveGasTip(baseFee *uint256.Int) (*uint256.Int, error)
- func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *uint256.Int) int
- func (tx *Transaction) EffectiveGasTipIntCmp(other *uint256.Int, baseFee *uint256.Int) int
- func (tx *Transaction) EffectiveGasTipValue(baseFee *uint256.Int) *uint256.Int
- func (tx *Transaction) From() *types.Address
- func (tx *Transaction) Gas() uint64
- func (tx *Transaction) GasFeeCap() *uint256.Int
- func (tx *Transaction) GasFeeCapCmp(other *Transaction) int
- func (tx *Transaction) GasFeeCapIntCmp(other *uint256.Int) int
- func (tx *Transaction) GasPrice() *uint256.Int
- func (tx *Transaction) GasTipCap() *uint256.Int
- func (tx *Transaction) GasTipCapCmp(other *Transaction) int
- func (tx *Transaction) GasTipCapIntCmp(other *uint256.Int) int
- func (tx *Transaction) Hash() types.Hash
- func (tx Transaction) Marshal() ([]byte, error)
- func (tx *Transaction) MarshalTo(data []byte) (n int, err error)
- func (tx *Transaction) Nonce() uint64
- func (tx *Transaction) Protected() bool
- func (tx *Transaction) RawSignatureValues() (v, r, s *uint256.Int)
- func (tx *Transaction) SetFrom(addr types.Address)
- func (tx *Transaction) SetNonce(nonce uint64)
- func (tx *Transaction) Sign() []byte
- func (tx *Transaction) To() *types.Address
- func (tx *Transaction) ToProtoMessage() proto.Message
- func (tx *Transaction) Type() uint8
- func (tx *Transaction) Unmarshal(data []byte) error
- func (tx *Transaction) Value() *uint256.Int
- func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error)
- func (tx *Transaction) WithSignatureValues(v, r, s *uint256.Int) (*Transaction, error)
- type Transactions
- type TxData
Constants ¶
const ( LegacyTxType = iota AccessListTxType DynamicFeeTxType )
Transaction types.
Variables ¶
var ( ErrGasFeeCapTooLow = fmt.Errorf("fee cap less than base fee") ErrUnmarshalHash = fmt.Errorf("hash verify falied") )
Functions ¶
func DeriveChainId ¶
deriveChainID derives the chain id from the given v parameter
func Sender ¶
func Sender(signer Signer, tx *Transaction) (types.Address, error)
Sender returns the address derived from the signature (V, R, S) using secp256k1 elliptic curve and an error if it failed deriving or upon an incorrect signature.
Sender may cache the address, allowing it to be used regardless of signing method. The cache is invalidated if the cached signer does not match the signer used in the current call.
Types ¶
type AccessList ¶
type AccessList []AccessTuple
func (AccessList) StorageKeys ¶
func (al AccessList) StorageKeys() int
StorageKeys returns the total number of storage keys in the access list.
type AccessListTx ¶
type AccessListTx struct { ChainID *uint256.Int // destination chain ID Nonce uint64 // nonce of sender account GasPrice *uint256.Int // wei per gas Gas uint64 // gas limit To *types.Address `rlp:"nil"` // nil means contract creation From *types.Address `rlp:"nil"` // nil means contract creation Value *uint256.Int // wei amount Data []byte // contract invocation input data AccessList AccessList // EIP-2930 access list Sign []byte // signature values V, R, S *uint256.Int // signature values }
type AccessTuple ¶
type AccessTuple struct { Address types.Address `json:"address" gencodec:"required"` StorageKeys []types.Hash `json:"storageKeys" gencodec:"required"` }
AccessTuple is the element type of an access list.
type DynamicFeeTx ¶
type DynamicFeeTx struct { ChainID *uint256.Int Nonce uint64 GasTipCap *uint256.Int // a.k.a. maxPriorityFeePerGas GasFeeCap *uint256.Int // a.k.a. maxFeePerGas Gas uint64 To *types.Address `rlp:"nil"` // nil means contract creation From *types.Address `rlp:"nil"` // nil means contract creation Value *uint256.Int Data []byte AccessList AccessList Sign []byte // Signature values V, R, S *uint256.Int // signature values }
type EIP155Signer ¶
type EIP155Signer struct {
// contains filtered or unexported fields
}
EIP155Signer implements Signer using the EIP-155 rules. This accepts transactions which are replay-protected as well as unprotected homestead transactions.
func NewEIP155Signer ¶
func NewEIP155Signer(chainId *big.Int) EIP155Signer
func (EIP155Signer) ChainID ¶
func (s EIP155Signer) ChainID() *big.Int
func (EIP155Signer) Equal ¶
func (s EIP155Signer) Equal(s2 Signer) bool
func (EIP155Signer) Hash ¶
func (s EIP155Signer) Hash(tx *Transaction) types.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (EIP155Signer) Sender ¶
func (s EIP155Signer) Sender(tx *Transaction) (types.Address, error)
func (EIP155Signer) SignatureValues ¶
func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type FrontierSigner ¶
type FrontierSigner struct{}
func (FrontierSigner) ChainID ¶
func (s FrontierSigner) ChainID() *big.Int
func (FrontierSigner) Equal ¶
func (s FrontierSigner) Equal(s2 Signer) bool
func (FrontierSigner) Hash ¶
func (fs FrontierSigner) Hash(tx *Transaction) types.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (FrontierSigner) Sender ¶
func (fs FrontierSigner) Sender(tx *Transaction) (types.Address, error)
func (FrontierSigner) SignatureValues ¶
func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type HomesteadSigner ¶
type HomesteadSigner struct{ FrontierSigner }
HomesteadTransaction implements TransactionInterface using the homestead rules.
func (HomesteadSigner) ChainID ¶
func (s HomesteadSigner) ChainID() *big.Int
func (HomesteadSigner) Equal ¶
func (s HomesteadSigner) Equal(s2 Signer) bool
func (HomesteadSigner) Sender ¶
func (hs HomesteadSigner) Sender(tx *Transaction) (types.Address, error)
func (HomesteadSigner) SignatureValues ¶
func (hs HomesteadSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type LegacyTx ¶
type LegacyTx struct { Nonce uint64 // nonce of sender account GasPrice *uint256.Int // wei per gas Gas uint64 // gas limit To *types.Address `rlp:"nil"` // nil means contract creation From *types.Address `rlp:"nil"` // nil means contract creation Value *uint256.Int // wei amount Data []byte // contract invocation input data V, R, S *uint256.Int // signature values Sign []byte }
LegacyTx is the transaction data of regular Ethereum transactions.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is a fully derived transaction and implements core.Message
func NewMessage ¶
func (Message) AccessList ¶
func (m Message) AccessList() AccessList
func (Message) CheckNonce ¶
func (*Message) SetCheckNonce ¶
type SakuragiTx ¶
type Signer ¶
type Signer interface { // Sender returns the sender address of the transaction. Sender(tx *Transaction) (types.Address, error) // SignatureValues returns the raw R, S, V values corresponding to the // given signature. SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) ChainID() *big.Int // Hash returns 'signature hash', i.e. the transaction hash that is signed by the // private key. This hash does not uniquely identify the transaction. Hash(tx *Transaction) types.Hash // Equal returns true if the given signer is the same as the receiver. Equal(Signer) bool }
Signer encapsulates transaction signature handling. The name of this type is slightly misleading because Signers don't actually sign, they're just for validating and processing of signatures.
Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.
func LatestSignerForChainID ¶
LatestSignerForChainID returns the 'most permissive' Signer available. Specifically, this enables support for EIP-155 replay protection and all implemented EIP-2718 transaction types if chainID is non-nil.
Use this in transaction-handling code where the current block number and fork configuration are unknown. If you have a ChainConfig, use LatestSigner instead. If you have a ChainConfig and know the current block number, use MakeSigner instead.
func MakeSigner ¶
func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer
MakeSigner returns a Signer based on the given chain config and block number.
func NewEIP2930Signer ¶
NewEIP2930Signer returns a signer that accepts EIP-2930 access list transactions, EIP-155 replay protected transactions, and legacy Homestead transactions.
func NewLondonSigner ¶
NewLondonSigner returns a signer that accepts - EIP-1559 dynamic fee transactions - EIP-2930 access list transactions, - EIP-155 replay protected transactions, and - legacy Homestead transactions.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func FromProtoMessage ¶
func FromProtoMessage(message proto.Message) (*Transaction, error)
func NewContractCreation ¶
func NewContractCreation(nonce uint64, amount *uint256.Int, gasLimit uint64, gasPrice *uint256.Int, data []byte) *Transaction
NewContractCreation creates an unsigned legacy transaction. Deprecated: use NewTx instead.
func NewTransaction ¶
func NewTransaction(nonce uint64, from types.Address, to *types.Address, amount *uint256.Int, gasLimit uint64, gasPrice *uint256.Int, data []byte) *Transaction
NewTransaction creates an unsigned legacy transaction. Deprecated: use NewTx instead.
func SignNewTx ¶
func SignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) (*Transaction, error)
SignNewTx creates a transaction and signs it.
func SignTx ¶
func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)
SignTx signs the transaction using the given signer and private key.
func (*Transaction) AccessList ¶
func (tx *Transaction) AccessList() AccessList
func (*Transaction) ChainId ¶
func (tx *Transaction) ChainId() *uint256.Int
func (*Transaction) Cost ¶
func (tx *Transaction) Cost() *uint256.Int
func (*Transaction) Data ¶
func (tx *Transaction) Data() []byte
func (*Transaction) EffectiveGasTip ¶
EffectiveGasTip returns the effective miner gasTipCap for the given base fee. Note: if the effective gasTipCap is negative, this method returns both error the actual negative value, _and_ ErrGasFeeCapTooLow
func (*Transaction) EffectiveGasTipCmp ¶
func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *uint256.Int) int
EffectiveGasTipCmp compares the effective gasTipCap of two transactions assuming the given base fee.
func (*Transaction) EffectiveGasTipIntCmp ¶
EffectiveGasTipIntCmp compares the effective gasTipCap of a transaction to the given gasTipCap.
func (*Transaction) EffectiveGasTipValue ¶
func (tx *Transaction) EffectiveGasTipValue(baseFee *uint256.Int) *uint256.Int
EffectiveGasTipValue is identical to EffectiveGasTip, but does not return an error in case the effective gasTipCap is negative
func (*Transaction) From ¶
func (tx *Transaction) From() *types.Address
func (*Transaction) Gas ¶
func (tx *Transaction) Gas() uint64
func (*Transaction) GasFeeCap ¶
func (tx *Transaction) GasFeeCap() *uint256.Int
func (*Transaction) GasFeeCapCmp ¶
func (tx *Transaction) GasFeeCapCmp(other *Transaction) int
GasFeeCapCmp compares the fee cap of two transactions.
func (*Transaction) GasFeeCapIntCmp ¶
func (tx *Transaction) GasFeeCapIntCmp(other *uint256.Int) int
GasFeeCapIntCmp compares the fee cap of the transaction against the given fee cap.
func (*Transaction) GasPrice ¶
func (tx *Transaction) GasPrice() *uint256.Int
func (*Transaction) GasTipCap ¶
func (tx *Transaction) GasTipCap() *uint256.Int
func (*Transaction) GasTipCapCmp ¶
func (tx *Transaction) GasTipCapCmp(other *Transaction) int
GasTipCapCmp compares the gasTipCap of two transactions.
func (*Transaction) GasTipCapIntCmp ¶
func (tx *Transaction) GasTipCapIntCmp(other *uint256.Int) int
GasTipCapIntCmp compares the gasTipCap of the transaction against the given gasTipCap.
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() types.Hash
func (Transaction) Marshal ¶
func (tx Transaction) Marshal() ([]byte, error)
func (*Transaction) Nonce ¶
func (tx *Transaction) Nonce() uint64
func (*Transaction) Protected ¶
func (tx *Transaction) Protected() bool
Protected says whether the transaction is replay-protected.
func (*Transaction) RawSignatureValues ¶
func (tx *Transaction) RawSignatureValues() (v, r, s *uint256.Int)
func (*Transaction) SetFrom ¶
func (tx *Transaction) SetFrom(addr types.Address)
func (*Transaction) SetNonce ¶
func (tx *Transaction) SetNonce(nonce uint64)
func (*Transaction) Sign ¶
func (tx *Transaction) Sign() []byte
func (*Transaction) To ¶
func (tx *Transaction) To() *types.Address
func (*Transaction) ToProtoMessage ¶
func (tx *Transaction) ToProtoMessage() proto.Message
func (*Transaction) Type ¶
func (tx *Transaction) Type() uint8
func (*Transaction) Unmarshal ¶
func (tx *Transaction) Unmarshal(data []byte) error
func (*Transaction) Value ¶
func (tx *Transaction) Value() *uint256.Int
func (*Transaction) WithSignature ¶
func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error)
WithSignature returns a new transaction with the given signature. This signature needs to be in the [R || S || V] format where V is 0 or 1.
func (*Transaction) WithSignatureValues ¶
func (tx *Transaction) WithSignatureValues(v, r, s *uint256.Int) (*Transaction, error)
WithSignature todo
type Transactions ¶
type Transactions []*Transaction
Transactions implements DerivableList for transactions.
func (Transactions) EncodeIndex ¶
func (s Transactions) EncodeIndex(i int, w *bytes.Buffer)
EncodeIndex encodes the i'th transaction to w. Note that this does not check for errors because we assume that *Transaction will only ever contain valid txs that were either constructed by decoding or via public API in this package.