mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
core/types: copy tx recipient address (#23376)
This commit is contained in:
parent
e18e6111af
commit
17b62319c0
4 changed files with 13 additions and 12 deletions
|
|
@ -59,7 +59,7 @@ type AccessListTx struct {
|
||||||
func (tx *AccessListTx) copy() TxData {
|
func (tx *AccessListTx) copy() TxData {
|
||||||
cpy := &AccessListTx{
|
cpy := &AccessListTx{
|
||||||
Nonce: tx.Nonce,
|
Nonce: tx.Nonce,
|
||||||
To: tx.To, // TODO: copy pointed-to address
|
To: copyAddressPtr(tx.To),
|
||||||
Data: common.CopyBytes(tx.Data),
|
Data: common.CopyBytes(tx.Data),
|
||||||
Gas: tx.Gas,
|
Gas: tx.Gas,
|
||||||
// These are copied below.
|
// These are copied below.
|
||||||
|
|
@ -96,7 +96,6 @@ func (tx *AccessListTx) copy() TxData {
|
||||||
// accessors for innerTx.
|
// accessors for innerTx.
|
||||||
func (tx *AccessListTx) txType() byte { return AccessListTxType }
|
func (tx *AccessListTx) txType() byte { return AccessListTxType }
|
||||||
func (tx *AccessListTx) chainID() *big.Int { return tx.ChainID }
|
func (tx *AccessListTx) chainID() *big.Int { return tx.ChainID }
|
||||||
func (tx *AccessListTx) protected() bool { return true }
|
|
||||||
func (tx *AccessListTx) accessList() AccessList { return tx.AccessList }
|
func (tx *AccessListTx) accessList() AccessList { return tx.AccessList }
|
||||||
func (tx *AccessListTx) data() []byte { return tx.Data }
|
func (tx *AccessListTx) data() []byte { return tx.Data }
|
||||||
func (tx *AccessListTx) gas() uint64 { return tx.Gas }
|
func (tx *AccessListTx) gas() uint64 { return tx.Gas }
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ type DynamicFeeTx struct {
|
||||||
func (tx *DynamicFeeTx) copy() TxData {
|
func (tx *DynamicFeeTx) copy() TxData {
|
||||||
cpy := &DynamicFeeTx{
|
cpy := &DynamicFeeTx{
|
||||||
Nonce: tx.Nonce,
|
Nonce: tx.Nonce,
|
||||||
To: tx.To, // TODO: copy pointed-to address
|
To: copyAddressPtr(tx.To),
|
||||||
Data: common.CopyBytes(tx.Data),
|
Data: common.CopyBytes(tx.Data),
|
||||||
Gas: tx.Gas,
|
Gas: tx.Gas,
|
||||||
// These are copied below.
|
// These are copied below.
|
||||||
|
|
@ -84,7 +84,6 @@ func (tx *DynamicFeeTx) copy() TxData {
|
||||||
// accessors for innerTx.
|
// accessors for innerTx.
|
||||||
func (tx *DynamicFeeTx) txType() byte { return DynamicFeeTxType }
|
func (tx *DynamicFeeTx) txType() byte { return DynamicFeeTxType }
|
||||||
func (tx *DynamicFeeTx) chainID() *big.Int { return tx.ChainID }
|
func (tx *DynamicFeeTx) chainID() *big.Int { return tx.ChainID }
|
||||||
func (tx *DynamicFeeTx) protected() bool { return true }
|
|
||||||
func (tx *DynamicFeeTx) accessList() AccessList { return tx.AccessList }
|
func (tx *DynamicFeeTx) accessList() AccessList { return tx.AccessList }
|
||||||
func (tx *DynamicFeeTx) data() []byte { return tx.Data }
|
func (tx *DynamicFeeTx) data() []byte { return tx.Data }
|
||||||
func (tx *DynamicFeeTx) gas() uint64 { return tx.Gas }
|
func (tx *DynamicFeeTx) gas() uint64 { return tx.Gas }
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPric
|
||||||
func (tx *LegacyTx) copy() TxData {
|
func (tx *LegacyTx) copy() TxData {
|
||||||
cpy := &LegacyTx{
|
cpy := &LegacyTx{
|
||||||
Nonce: tx.Nonce,
|
Nonce: tx.Nonce,
|
||||||
To: tx.To, // TODO: copy pointed-to address
|
To: copyAddressPtr(tx.To),
|
||||||
Data: common.CopyBytes(tx.Data),
|
Data: common.CopyBytes(tx.Data),
|
||||||
Gas: tx.Gas,
|
Gas: tx.Gas,
|
||||||
// These are initialized below.
|
// These are initialized below.
|
||||||
|
|
|
||||||
|
|
@ -299,13 +299,7 @@ func (tx *Transaction) Nonce() uint64 { return tx.inner.nonce() }
|
||||||
// To returns the recipient address of the transaction.
|
// To returns the recipient address of the transaction.
|
||||||
// For contract-creation transactions, To returns nil.
|
// For contract-creation transactions, To returns nil.
|
||||||
func (tx *Transaction) To() *common.Address {
|
func (tx *Transaction) To() *common.Address {
|
||||||
// Copy the pointed-to address.
|
return copyAddressPtr(tx.inner.to())
|
||||||
ito := tx.inner.to()
|
|
||||||
if ito == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
cpy := *ito
|
|
||||||
return &cpy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tx *Transaction) From() *common.Address {
|
func (tx *Transaction) From() *common.Address {
|
||||||
|
|
@ -865,3 +859,12 @@ func (m *Message) SetBalanceTokenFeeForCall() {
|
||||||
func (m *Message) SetBalanceTokenFee(balanceTokenFee *big.Int) {
|
func (m *Message) SetBalanceTokenFee(balanceTokenFee *big.Int) {
|
||||||
m.balanceTokenFee = balanceTokenFee
|
m.balanceTokenFee = balanceTokenFee
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copyAddressPtr copies an address.
|
||||||
|
func copyAddressPtr(a *common.Address) *common.Address {
|
||||||
|
if a == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cpy := *a
|
||||||
|
return &cpy
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue