@ -36,7 +36,7 @@ var (
ErrUnexpectedProtection = errors . New ( "transaction type does not supported EIP-155 protected signatures" )
ErrInvalidTxType = errors . New ( "transaction type not valid in this context" )
ErrTxTypeNotSupported = errors . New ( "transaction type not supported" )
ErrFeeCapTooLow = errors . New ( "fee cap less than base fee" )
ErrGas FeeCapTooLow = errors . New ( "fee cap less than base fee" )
errEmptyTypedTx = errors . New ( "empty typed transaction bytes" )
)
@ -77,8 +77,8 @@ type TxData interface {
data ( ) [ ] byte
gas ( ) uint64
gasPrice ( ) * big . Int
ti p( ) * big . Int
f eeCap( ) * big . Int
gasTipCa p( ) * big . Int
gasF eeCap( ) * big . Int
value ( ) * big . Int
nonce ( ) uint64
to ( ) * common . Address
@ -269,11 +269,11 @@ func (tx *Transaction) Gas() uint64 { return tx.inner.gas() }
// GasPrice returns the gas price of the transaction.
func ( tx * Transaction ) GasPrice ( ) * big . Int { return new ( big . Int ) . Set ( tx . inner . gasPrice ( ) ) }
// Tip returns the ti p per gas of the transaction.
func ( tx * Transaction ) Tip ( ) * big . Int { return new ( big . Int ) . Set ( tx . inner . ti p( ) ) }
// GasTipCap returns the gasTipCa p per gas of the transaction.
func ( tx * Transaction ) Gas TipCa p( ) * big . Int { return new ( big . Int ) . Set ( tx . inner . gasTipCa p( ) ) }
// FeeCap returns the fee cap per gas of the transaction.
func ( tx * Transaction ) FeeCap ( ) * big . Int { return new ( big . Int ) . Set ( tx . inner . f eeCap( ) ) }
// Gas FeeCap returns the fee cap per gas of the transaction.
func ( tx * Transaction ) Gas FeeCap( ) * big . Int { return new ( big . Int ) . Set ( tx . inner . gasF eeCap( ) ) }
// Value returns the ether amount of the transaction.
func ( tx * Transaction ) Value ( ) * big . Int { return new ( big . Int ) . Set ( tx . inner . value ( ) ) }
@ -306,62 +306,62 @@ func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int) {
return tx . inner . rawSignatureValues ( )
}
// FeeCapCmp compares the fee cap of two transactions.
func ( tx * Transaction ) FeeCapCmp ( other * Transaction ) int {
return tx . inner . f eeCap( ) . Cmp ( other . inner . f eeCap( ) )
// Gas FeeCapCmp compares the fee cap of two transactions.
func ( tx * Transaction ) Gas FeeCapCmp( other * Transaction ) int {
return tx . inner . gasF eeCap( ) . Cmp ( other . inner . gasF eeCap( ) )
}
// FeeCapIntCmp compares the fee cap of the transaction against the given fee cap.
func ( tx * Transaction ) FeeCapIntCmp ( other * big . Int ) int {
return tx . inner . f eeCap( ) . Cmp ( other )
// Gas FeeCapIntCmp compares the fee cap of the transaction against the given fee cap.
func ( tx * Transaction ) Gas FeeCapIntCmp( other * big . Int ) int {
return tx . inner . gasF eeCap( ) . Cmp ( other )
}
// TipCmp compares the ti p of two transactions.
func ( tx * Transaction ) TipCmp ( other * Transaction ) int {
return tx . inner . ti p( ) . Cmp ( other . inner . ti p( ) )
// GasTipCapCmp compares the gasTipCa p of two transactions.
func ( tx * Transaction ) Gas TipCa pCmp( other * Transaction ) int {
return tx . inner . gasTipCa p( ) . Cmp ( other . inner . gasTipCa p( ) )
}
// TipIntCmp compares the tip of the transaction against the given ti p.
func ( tx * Transaction ) TipIntCmp ( other * big . Int ) int {
return tx . inner . ti p( ) . Cmp ( other )
// GasTipCapIntCmp compares the gasTipCap of the transaction against the given gasTipCa p.
func ( tx * Transaction ) Gas TipCa pIntCmp( other * big . Int ) int {
return tx . inner . gasTipCa p( ) . Cmp ( other )
}
// EffectiveTip returns the effective miner ti p for the given base fee.
// Note: if the effective ti p is negative, this method returns both error
// the actual negative value, _and_ ErrFeeCapTooLow
func ( tx * Transaction ) EffectiveTip ( baseFee * big . Int ) ( * big . Int , error ) {
// EffectiveGasTip returns the effective miner gasTipCa p for the given base fee.
// Note: if the effective gasTipCa p is negative, this method returns both error
// the actual negative value, _and_ ErrGas FeeCapTooLow
func ( tx * Transaction ) EffectiveGas Tip ( baseFee * big . Int ) ( * big . Int , error ) {
if baseFee == nil {
return tx . Tip ( ) , nil
return tx . Gas TipCa p( ) , nil
}
var err error
f eeCap := tx . FeeCap ( )
if f eeCap. Cmp ( baseFee ) == - 1 {
err = ErrFeeCapTooLow
gasF eeCap := tx . Gas FeeCap( )
if gasF eeCap. Cmp ( baseFee ) == - 1 {
err = ErrGas FeeCapTooLow
}
return math . BigMin ( tx . Tip ( ) , f eeCap. Sub ( f eeCap, baseFee ) ) , err
return math . BigMin ( tx . Gas TipCa p( ) , gasF eeCap. Sub ( gasF eeCap, baseFee ) ) , err
}
// EffectiveTipValue is identical to EffectiveTip, but does not return an
// error in case the effective ti p is negative
func ( tx * Transaction ) EffectiveTipValue ( baseFee * big . Int ) * big . Int {
effectiveTip , _ := tx . EffectiveTip ( baseFee )
// EffectiveGas TipValue is identical to EffectiveGas Tip, but does not return an
// error in case the effective gasTipCa p is negative
func ( tx * Transaction ) EffectiveGas TipValue ( baseFee * big . Int ) * big . Int {
effectiveTip , _ := tx . EffectiveGas Tip ( baseFee )
return effectiveTip
}
// EffectiveTipCmp compares the effective ti p of two transactions assuming the given base fee.
func ( tx * Transaction ) EffectiveTipCmp ( other * Transaction , baseFee * big . Int ) int {
// EffectiveGasTipCmp compares the effective gasTipCa p of two transactions assuming the given base fee.
func ( tx * Transaction ) EffectiveGas TipCmp ( other * Transaction , baseFee * big . Int ) int {
if baseFee == nil {
return tx . TipCmp ( other )
return tx . Gas TipCa pCmp( other )
}
return tx . EffectiveTipValue ( baseFee ) . Cmp ( other . EffectiveTipValue ( baseFee ) )
return tx . EffectiveGas TipValue ( baseFee ) . Cmp ( other . EffectiveGas TipValue ( baseFee ) )
}
// EffectiveTipIntCmp compares the effective tip of a transaction to the given ti p.
// EffectiveTipIntCmp compares the effective gasTipCap of a transaction to the given gasTipCa p.
func ( tx * Transaction ) EffectiveTipIntCmp ( other * big . Int , baseFee * big . Int ) int {
if baseFee == nil {
return tx . TipIntCmp ( other )
return tx . Gas TipCa pIntCmp( other )
}
return tx . EffectiveTipValue ( baseFee ) . Cmp ( other )
return tx . EffectiveGas TipValue ( baseFee ) . Cmp ( other )
}
// Hash returns the transaction hash.
@ -449,17 +449,17 @@ func (s TxByNonce) Len() int { return len(s) }
func ( s TxByNonce ) Less ( i , j int ) bool { return s [ i ] . Nonce ( ) < s [ j ] . Nonce ( ) }
func ( s TxByNonce ) Swap ( i , j int ) { s [ i ] , s [ j ] = s [ j ] , s [ i ] }
// TxWithMinerFee wraps a transaction with its gas price or effective miner ti p
// TxWithMinerFee wraps a transaction with its gas price or effective miner gasTipCa p
type TxWithMinerFee struct {
tx * Transaction
minerFee * big . Int
}
// NewTxWithMinerFee creates a wrapped transaction, calculating the effective
// miner ti p if a base fee is provided.
// Returns error in case of a negative effective miner ti p.
// miner gasTipCa p if a base fee is provided.
// Returns error in case of a negative effective miner gasTipCa p.
func NewTxWithMinerFee ( tx * Transaction , baseFee * big . Int ) ( * TxWithMinerFee , error ) {
minerFee , err := tx . EffectiveTip ( baseFee )
minerFee , err := tx . EffectiveGas Tip ( baseFee )
if err != nil {
return nil , err
}
@ -575,14 +575,14 @@ type Message struct {
amount * big . Int
gasLimit uint64
gasPrice * big . Int
feeCap * big . Int
tip * big . Int
gasFeeCap * big . Int
gasTipCap * big . Int
data [ ] byte
accessList AccessList
checkNonce bool
}
func NewMessage ( from common . Address , to * common . Address , nonce uint64 , amount * big . Int , gasLimit uint64 , gasPrice , feeCap , ti p * big . Int , data [ ] byte , accessList AccessList , checkNonce bool ) Message {
func NewMessage ( from common . Address , to * common . Address , nonce uint64 , amount * big . Int , gasLimit uint64 , gasPrice , gasFeeCap , gasTipCa p * big . Int , data [ ] byte , accessList AccessList , checkNonce bool ) Message {
return Message {
from : from ,
to : to ,
@ -590,8 +590,8 @@ func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *b
amount : amount ,
gasLimit : gasLimit ,
gasPrice : gasPrice ,
feeCap : f eeCap,
tip : ti p,
gasFeeCap : gasF eeCap,
gasTipCap : gasTipCa p,
data : data ,
accessList : accessList ,
checkNonce : checkNonce ,
@ -604,8 +604,8 @@ func (tx *Transaction) AsMessage(s Signer, baseFee *big.Int) (Message, error) {
nonce : tx . Nonce ( ) ,
gasLimit : tx . Gas ( ) ,
gasPrice : new ( big . Int ) . Set ( tx . GasPrice ( ) ) ,
feeCap : new ( big . Int ) . Set ( tx . FeeCap ( ) ) ,
tip : new ( big . Int ) . Set ( tx . Tip ( ) ) ,
gasFeeCap : new ( big . Int ) . Set ( tx . Gas FeeCap( ) ) ,
gasTipCap : new ( big . Int ) . Set ( tx . Gas TipCa p( ) ) ,
to : tx . To ( ) ,
amount : tx . Value ( ) ,
data : tx . Data ( ) ,
@ -614,7 +614,7 @@ func (tx *Transaction) AsMessage(s Signer, baseFee *big.Int) (Message, error) {
}
// If baseFee provided, set gasPrice to effectiveGasPrice.
if baseFee != nil {
msg . gasPrice = math . BigMin ( msg . gasPrice . Add ( msg . ti p, baseFee ) , msg . f eeCap)
msg . gasPrice = math . BigMin ( msg . gasPrice . Add ( msg . gasTipCa p, baseFee ) , msg . gasF eeCap)
}
var err error
msg . from , err = Sender ( s , tx )
@ -624,8 +624,8 @@ func (tx *Transaction) AsMessage(s Signer, baseFee *big.Int) (Message, error) {
func ( m Message ) From ( ) common . Address { return m . from }
func ( m Message ) To ( ) * common . Address { return m . to }
func ( m Message ) GasPrice ( ) * big . Int { return m . gasPrice }
func ( m Message ) FeeCap ( ) * big . Int { return m . f eeCap }
func ( m Message ) Tip ( ) * big . Int { return m . ti p }
func ( m Message ) Gas FeeCap( ) * big . Int { return m . gasF eeCap }
func ( m Message ) Gas TipCa p( ) * big . Int { return m . gasTipCa p }
func ( m Message ) Value ( ) * big . Int { return m . amount }
func ( m Message ) Gas ( ) uint64 { return m . gasLimit }
func ( m Message ) Nonce ( ) uint64 { return m . nonce }