delete unused account.secretKey

This commit is contained in:
maskpp 2025-05-07 22:55:09 +08:00
parent d6655cb450
commit 9bd85d78a7
2 changed files with 12 additions and 22 deletions

View file

@ -38,17 +38,13 @@ type Account struct {
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
Balance *big.Int `json:"balance" gencodec:"required"`
Nonce uint64 `json:"nonce,omitempty"`
// used in tests
PrivateKey []byte `json:"secretKey,omitempty"`
}
type accountMarshaling struct {
Code hexutil.Bytes
Balance *math.HexOrDecimal256
Nonce math.HexOrDecimal64
Storage map[storageJSON]storageJSON
PrivateKey hexutil.Bytes
Code hexutil.Bytes
Balance *math.HexOrDecimal256
Nonce math.HexOrDecimal64
Storage map[storageJSON]storageJSON
}
// storageJSON represents a 256 bit byte array, but allows less than 256 bits when

View file

@ -17,11 +17,10 @@ var _ = (*accountMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (a Account) MarshalJSON() ([]byte, error) {
type Account struct {
Code hexutil.Bytes `json:"code,omitempty"`
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
Nonce math.HexOrDecimal64 `json:"nonce,omitempty"`
PrivateKey hexutil.Bytes `json:"secretKey,omitempty"`
Code hexutil.Bytes `json:"code,omitempty"`
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
Nonce math.HexOrDecimal64 `json:"nonce,omitempty"`
}
var enc Account
enc.Code = a.Code
@ -33,18 +32,16 @@ func (a Account) MarshalJSON() ([]byte, error) {
}
enc.Balance = (*math.HexOrDecimal256)(a.Balance)
enc.Nonce = math.HexOrDecimal64(a.Nonce)
enc.PrivateKey = a.PrivateKey
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (a *Account) UnmarshalJSON(input []byte) error {
type Account struct {
Code *hexutil.Bytes `json:"code,omitempty"`
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"`
PrivateKey *hexutil.Bytes `json:"secretKey,omitempty"`
Code *hexutil.Bytes `json:"code,omitempty"`
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"`
}
var dec Account
if err := json.Unmarshal(input, &dec); err != nil {
@ -66,8 +63,5 @@ func (a *Account) UnmarshalJSON(input []byte) error {
if dec.Nonce != nil {
a.Nonce = uint64(*dec.Nonce)
}
if dec.PrivateKey != nil {
a.PrivateKey = *dec.PrivateKey
}
return nil
}