Skip to content

Commit

Permalink
Merge pull request bnb-chain#224 from ethereum-optimism/set-sidecar
Browse files Browse the repository at this point in the history
core/types: SetBlobTxSidecar to support blob tx tooling
  • Loading branch information
protolambda authored Jan 24, 2024
2 parents a4e85ec + 288b43d commit 5c6f10d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package types
import (
"bytes"
"errors"
"fmt"
"io"
"math/big"
"sync/atomic"
Expand Down Expand Up @@ -482,6 +483,18 @@ func (tx *Transaction) BlobTxSidecar() *BlobTxSidecar {
return nil
}

// SetBlobTxSidecar sets the sidecar of a transaction.
// The sidecar should match the blob-tx versioned hashes, or the transaction will be invalid.
// This allows tools to easily re-attach blob sidecars to signed transactions that omit the sidecar.
func (tx *Transaction) SetBlobTxSidecar(sidecar *BlobTxSidecar) error {
blobtx, ok := tx.inner.(*BlobTx)
if !ok {
return fmt.Errorf("not a blob tx, type = %d", tx.Type())
}
blobtx.Sidecar = sidecar
return nil
}

// BlobGasFeeCapCmp compares the blob fee cap of two transactions.
func (tx *Transaction) BlobGasFeeCapCmp(other *Transaction) int {
return tx.BlobGasFeeCap().Cmp(other.BlobGasFeeCap())
Expand Down

0 comments on commit 5c6f10d

Please sign in to comment.