Update api.go

This commit is contained in:
0xcharry 2026-01-17 18:18:22 +01:00 committed by GitHub
parent e78be59dc9
commit 87c7829e0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1638,6 +1638,21 @@ func (api *TransactionAPI) currentBlobSidecarVersion() byte {
return types.BlobSidecarVersion0 return types.BlobSidecarVersion0
} }
func (api *TransactionAPI) convertLegacyBlobSidecar(tx *types.Transaction) (*types.Transaction, error) {
// Convert legacy blob transaction proofs.
// TODO: remove in go-ethereum v1.17.x
if sc := tx.BlobTxSidecar(); sc != nil {
exp := api.currentBlobSidecarVersion()
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
if err := sc.ToV1(); err != nil {
return nil, fmt.Errorf("blob sidecar conversion failed: %v", err)
}
tx = tx.WithBlobTxSidecar(sc)
}
}
return tx, nil
}
// SendRawTransaction will add the signed transaction to the transaction pool. // SendRawTransaction will add the signed transaction to the transaction pool.
// The sender is responsible for signing the transaction and using the correct nonce. // The sender is responsible for signing the transaction and using the correct nonce.
func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) { func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) {
@ -1646,16 +1661,9 @@ func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil
return common.Hash{}, err return common.Hash{}, err
} }
// Convert legacy blob transaction proofs. tx, err := api.convertLegacyBlobSidecar(tx)
// TODO: remove in go-ethereum v1.17.x if err != nil {
if sc := tx.BlobTxSidecar(); sc != nil { return common.Hash{}, err
exp := api.currentBlobSidecarVersion()
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
if err := sc.ToV1(); err != nil {
return common.Hash{}, fmt.Errorf("blob sidecar conversion failed: %v", err)
}
tx = tx.WithBlobTxSidecar(sc)
}
} }
return SubmitTransaction(ctx, api.b, tx) return SubmitTransaction(ctx, api.b, tx)
@ -1669,16 +1677,9 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
return nil, err return nil, err
} }
// Convert legacy blob transaction proofs. tx, err := api.convertLegacyBlobSidecar(tx)
// TODO: remove in go-ethereum v1.17.x if err != nil {
if sc := tx.BlobTxSidecar(); sc != nil { return nil, err
exp := api.currentBlobSidecarVersion()
if sc.Version == types.BlobSidecarVersion0 && exp == types.BlobSidecarVersion1 {
if err := sc.ToV1(); err != nil {
return nil, fmt.Errorf("blob sidecar conversion failed: %v", err)
}
tx = tx.WithBlobTxSidecar(sc)
}
} }
ch := make(chan core.ChainEvent, 128) ch := make(chan core.ChainEvent, 128)