diff --git a/common/address.go b/common/address.go index 18c2b5392c..aac905d5ae 100644 --- a/common/address.go +++ b/common/address.go @@ -407,8 +407,9 @@ func MakeErrQuaiAddress(addr string) error { return fmt.Errorf("expected Qi address, but found Quai address: %s", addr) } -func (a Address) MixedcaseAddress() MixedcaseAddress { - return NewMixedcaseAddress(a) +func (a Address) MixedcaseAddress() *MixedcaseAddress { + m := NewMixedcaseAddress(a) + return &m } func IsConversionOutput(a []byte, nodeLocation Location) bool { diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 359eb39eb7..67fe96511c 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -32,19 +32,19 @@ type txJSON struct { Type hexutil.Uint64 `json:"type"` // Common transaction fields: - Nonce *hexutil.Uint64 `json:"nonce"` - GasPrice *hexutil.Big `json:"gasPrice"` - MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"` - MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` - Gas *hexutil.Uint64 `json:"gas"` - Value *hexutil.Big `json:"value"` - Data *hexutil.Bytes `json:"input"` - To *common.Address `json:"to"` - AccessList *AccessList `json:"accessList"` - TxIn []TxInJSON `json:"inputs,omitempty"` - TxOut []TxOutJSON `json:"outputs,omitempty"` - UTXOSignature *hexutil.Bytes `json:"utxoSignature,omitempty"` - IsCoinbase *hexutil.Uint64 `json:"isCoinbase"` + Nonce *hexutil.Uint64 `json:"nonce"` + GasPrice *hexutil.Big `json:"gasPrice"` + MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"` + MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` + Gas *hexutil.Uint64 `json:"gas"` + Value *hexutil.Big `json:"value"` + Data *hexutil.Bytes `json:"input"` + To *common.MixedcaseAddress `json:"to"` + AccessList *AccessList `json:"accessList"` + TxIn []TxInJSON `json:"inputs,omitempty"` + TxOut []TxOutJSON `json:"outputs,omitempty"` + UTXOSignature *hexutil.Bytes `json:"utxoSignature,omitempty"` + IsCoinbase *hexutil.Uint64 `json:"isCoinbase"` // Optional fields only present for internal transactions ChainID *hexutil.Big `json:"chainId,omitempty"` V *hexutil.Big `json:"v,omitempty"` @@ -52,9 +52,9 @@ type txJSON struct { S *hexutil.Big `json:"s,omitempty"` // Optional fields only present for external transactions - Sender *common.Address `json:"sender,omitempty"` - OriginatingTxHash *common.Hash `json:"originatingTxHash,omitempty"` - ETXIndex *hexutil.Uint64 `json:"etxIndex,omitempty"` + ETXSender *common.MixedcaseAddress `json:"sender,omitempty"` + OriginatingTxHash *common.Hash `json:"originatingTxHash,omitempty"` + ETXIndex *hexutil.Uint64 `json:"etxIndex,omitempty"` // Only used for encoding: Hash common.Hash `json:"hash"` @@ -92,7 +92,7 @@ func (t *Transaction) MarshalJSON() ([]byte, error) { enc.MaxPriorityFeePerGas = (*hexutil.Big)(tx.GasTipCap) enc.Value = (*hexutil.Big)(tx.Value) enc.Data = (*hexutil.Bytes)(&tx.Data) - enc.To = t.To() + enc.To = t.To().MixedcaseAddress() enc.V = (*hexutil.Big)(tx.V) enc.R = (*hexutil.Big)(tx.R) enc.S = (*hexutil.Big)(tx.S) @@ -104,8 +104,8 @@ func (t *Transaction) MarshalJSON() ([]byte, error) { enc.Gas = (*hexutil.Uint64)(&tx.Gas) enc.Value = (*hexutil.Big)(tx.Value) enc.Data = (*hexutil.Bytes)(&tx.Data) - enc.To = t.To() - enc.Sender = &tx.Sender + enc.To = t.To().MixedcaseAddress() + enc.ETXSender = tx.Sender.MixedcaseAddress() isCoinbase := hexutil.Uint64(0) if tx.IsCoinbase { isCoinbase = hexutil.Uint64(1) @@ -161,7 +161,8 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { } itx.ChainID = (*big.Int)(dec.ChainID) if dec.To != nil { - itx.To = dec.To + addr := dec.To.Address() + itx.To = &addr } if dec.Nonce == nil { return errors.New("missing required field 'nonce' in internal transaction") @@ -214,7 +215,8 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { } etx.AccessList = *dec.AccessList if dec.To != nil { - etx.To = dec.To + addr := dec.To.Address() + etx.To = &addr } if dec.OriginatingTxHash == nil { return errors.New("missing required field 'originatingTxHash' in external transaction") @@ -236,10 +238,10 @@ func (t *Transaction) UnmarshalJSON(input []byte) error { return errors.New("missing required field 'input' in external transaction") } etx.Data = *dec.Data - if dec.Sender == nil { + if dec.ETXSender == nil { return errors.New("missing required field 'sender' in external transaction") } - etx.Sender = *dec.Sender + etx.Sender = dec.ETXSender.Address() if dec.IsCoinbase == nil { return errors.New("missing required field 'isCoinbase' in external transaction") } diff --git a/core/types/wo.go b/core/types/wo.go index b3ba2627b2..82749c76bd 100644 --- a/core/types/wo.go +++ b/core/types/wo.go @@ -1005,7 +1005,7 @@ func (wh *WorkObjectHeader) RPCMarshalWorkObjectHeader() map[string]interface{} "txHash": wh.TxHash(), "timestamp": hexutil.Uint64(wh.Time()), "mixHash": wh.MixHash(), - "coinbase": wh.Coinbase(), + "coinbase": wh.Coinbase().MixedcaseAddress(), } return result } diff --git a/internal/quaiapi/api.go b/internal/quaiapi/api.go index e51b65ab6a..7d36d3aa4d 100644 --- a/internal/quaiapi/api.go +++ b/internal/quaiapi/api.go @@ -297,13 +297,13 @@ func (s *PublicBlockChainAPI) GetOutpointsByAddressAtBlock(ctx context.Context, // Result structs for GetProof type AccountResult struct { - Address common.Address `json:"address"` - AccountProof []string `json:"accountProof"` - Balance *hexutil.Big `json:"balance"` - CodeHash common.Hash `json:"codeHash"` - Nonce hexutil.Uint64 `json:"nonce"` - StorageHash common.Hash `json:"storageHash"` - StorageProof []StorageResult `json:"storageProof"` + Address common.MixedcaseAddress `json:"address"` + AccountProof []string `json:"accountProof"` + Balance *hexutil.Big `json:"balance"` + CodeHash common.Hash `json:"codeHash"` + Nonce hexutil.Uint64 `json:"nonce"` + StorageHash common.Hash `json:"storageHash"` + StorageProof []StorageResult `json:"storageProof"` } type StorageResult struct { @@ -362,7 +362,7 @@ func (s *PublicBlockChainAPI) GetProof(ctx context.Context, address common.Addre } return &AccountResult{ - Address: address, + Address: *address.MixedcaseAddress(), AccountProof: toHexSlice(accountProof), Balance: (*hexutil.Big)(state.GetBalance(internal)), CodeHash: codeHash, @@ -1032,33 +1032,33 @@ func (s *PublicBlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Work // RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction type RPCTransaction struct { - BlockHash *common.Hash `json:"blockHash"` - BlockNumber *hexutil.Big `json:"blockNumber"` - From *common.Address `json:"from,omitempty"` - Gas hexutil.Uint64 `json:"gas"` - GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` - GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` - Hash common.Hash `json:"hash"` - Input hexutil.Bytes `json:"input"` - Nonce hexutil.Uint64 `json:"nonce"` - To *common.Address `json:"to,omitempty"` - TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` - Value *hexutil.Big `json:"value,omitempty"` - Type hexutil.Uint64 `json:"type"` - Accesses *types.AccessList `json:"accessList,omitempty"` - ChainID *hexutil.Big `json:"chainId,omitempty"` - V *hexutil.Big `json:"v,omitempty"` - R *hexutil.Big `json:"r,omitempty"` - S *hexutil.Big `json:"s,omitempty"` - TxIn []RPCTxIn `json:"inputs,omitempty"` - TxOut []RPCTxOut `json:"outputs,omitempty"` - UTXOSignature hexutil.Bytes `json:"utxoSignature,omitempty"` - OriginatingTxHash *common.Hash `json:"originatingTxHash,omitempty"` - ETXIndex *hexutil.Uint64 `json:"etxIndex,omitempty"` - IsCoinbase *hexutil.Uint64 `json:"isCoinbase,omitempty"` - ETxType string `json:"etxType"` + BlockHash *common.Hash `json:"blockHash"` + BlockNumber *hexutil.Big `json:"blockNumber"` + From *common.MixedcaseAddress `json:"from,omitempty"` + Gas hexutil.Uint64 `json:"gas"` + GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` + GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` + Hash common.Hash `json:"hash"` + Input hexutil.Bytes `json:"input"` + Nonce hexutil.Uint64 `json:"nonce"` + To *common.MixedcaseAddress `json:"to,omitempty"` + TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` + Value *hexutil.Big `json:"value,omitempty"` + Type hexutil.Uint64 `json:"type"` + Accesses *types.AccessList `json:"accessList,omitempty"` + ChainID *hexutil.Big `json:"chainId,omitempty"` + V *hexutil.Big `json:"v,omitempty"` + R *hexutil.Big `json:"r,omitempty"` + S *hexutil.Big `json:"s,omitempty"` + TxIn []RPCTxIn `json:"inputs,omitempty"` + TxOut []RPCTxOut `json:"outputs,omitempty"` + UTXOSignature hexutil.Bytes `json:"utxoSignature,omitempty"` + OriginatingTxHash *common.Hash `json:"originatingTxHash,omitempty"` + ETXIndex *hexutil.Uint64 `json:"etxIndex,omitempty"` + IsCoinbase *hexutil.Uint64 `json:"isCoinbase,omitempty"` + ETxType string `json:"etxType"` // Optional fields only present for external transactions - Sender *common.Address `json:"sender,omitempty"` + ETXSender *common.MixedcaseAddress `json:"sender,omitempty"` } type RPCTxIn struct { @@ -1108,12 +1108,12 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber from, _ := types.Sender(signer, tx) result = &RPCTransaction{ Type: hexutil.Uint64(tx.Type()), - From: &from, + From: from.MixedcaseAddress(), Gas: hexutil.Uint64(tx.Gas()), Hash: tx.Hash(), Input: hexutil.Bytes(tx.Data()), Nonce: hexutil.Uint64(tx.Nonce()), - To: tx.To(), + To: tx.To().MixedcaseAddress(), Value: (*hexutil.Big)(tx.Value()), ChainID: (*hexutil.Big)(tx.ChainId()), GasFeeCap: (*hexutil.Big)(tx.GasFeeCap()), @@ -1125,14 +1125,14 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber Gas: hexutil.Uint64(tx.Gas()), Hash: tx.Hash(), Input: hexutil.Bytes(tx.Data()), - To: tx.To(), + To: tx.To().MixedcaseAddress(), Value: (*hexutil.Big)(tx.Value()), } originatingTxHash := tx.OriginatingTxHash() etxIndex := uint64(tx.ETXIndex()) sender := tx.ETXSender() result.OriginatingTxHash = &originatingTxHash - result.Sender = &sender + result.ETXSender = sender.MixedcaseAddress() result.ETXIndex = (*hexutil.Uint64)(&etxIndex) if tx.IsCoinbase() { isCoinbase := uint64(1) diff --git a/internal/quaiapi/quai_api.go b/internal/quaiapi/quai_api.go index ed75f03550..929169c8a4 100644 --- a/internal/quaiapi/quai_api.go +++ b/internal/quaiapi/quai_api.go @@ -243,7 +243,7 @@ func (s *PublicBlockChainQuaiAPI) GetProof(ctx context.Context, address common.A } return &AccountResult{ - Address: address, + Address: *address.MixedcaseAddress(), AccountProof: toHexSlice(accountProof), Balance: (*hexutil.Big)(state.GetBalance(internal)), CodeHash: codeHash,