mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-21 15:29:27 +00:00
accounts/usbwallet: add support for blob and setcode transactions (#33797)
Adds Ledger signing support for BlobTxType (EIP-4844) and SetCodeTxType (EIP-7702) transactions. --------- Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
This commit is contained in:
parent
dc07433d87
commit
36520d8199
1 changed files with 22 additions and 7 deletions
|
|
@ -334,26 +334,41 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if chainID == nil {
|
if chainID == nil {
|
||||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data()}); err != nil {
|
if txrlp, err = rlp.EncodeToBytes([]any{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data()}); err != nil {
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if tx.Type() == types.DynamicFeeTxType {
|
switch tx.Type() {
|
||||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
case types.SetCodeTxType:
|
||||||
|
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations()}); err != nil {
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
// append type to transaction
|
// append type to transaction
|
||||||
txrlp = append([]byte{tx.Type()}, txrlp...)
|
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||||
} else if tx.Type() == types.AccessListTxType {
|
case types.BlobTxType:
|
||||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{chainID, tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList(), tx.BlobGasFeeCap(), tx.BlobHashes()}); err != nil {
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
// append type to transaction
|
// append type to transaction
|
||||||
txrlp = append([]byte{tx.Type()}, txrlp...)
|
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||||
} else if tx.Type() == types.LegacyTxType {
|
case types.DynamicFeeTxType:
|
||||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, big.NewInt(0), big.NewInt(0)}); err != nil {
|
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
|
// append type to transaction
|
||||||
|
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||||
|
case types.AccessListTxType:
|
||||||
|
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
||||||
|
return common.Address{}, nil, err
|
||||||
|
}
|
||||||
|
// append type to transaction
|
||||||
|
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||||
|
case types.LegacyTxType:
|
||||||
|
if txrlp, err = rlp.EncodeToBytes([]any{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, big.NewInt(0), big.NewInt(0)}); err != nil {
|
||||||
|
return common.Address{}, nil, err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return common.Address{}, nil, fmt.Errorf("unsupported transaction type: %d", tx.Type())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
payload := append(path, txrlp...)
|
payload := append(path, txrlp...)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue