Skip to content

Commit

Permalink
[R4R]-[tx]feat: fix tx cost (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tri-stone committed Feb 22, 2024
1 parent d12aec3 commit 52122bd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,13 @@ func (tx *Transaction) IsSystemTx() bool {
return tx.inner.isSystemTx()
}

// Cost returns gas * gasPrice + value.
// Cost returns (gas * gasPrice) + (blobGas * blobGasPrice) + value.
func (tx *Transaction) Cost() *big.Int {
total := new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas()))
if tx.Type() == BlobTxType {
total.Add(total, new(big.Int).Mul(tx.BlobGasFeeCap(), new(big.Int).SetUint64(tx.BlobGas())))
}
total.Add(total, tx.Value())
return total
}

Expand Down

0 comments on commit 52122bd

Please sign in to comment.