github.com/MetalBlockchain/subnet-evm@v0.4.9/ethclient/signer.go (about) 1 // (c) 2019-2020, Ava Labs, Inc. 2 // 3 // This file is a derived work, based on the go-ethereum library whose original 4 // notices appear below. 5 // 6 // It is distributed under a license compatible with the licensing terms of the 7 // original code from which it is derived. 8 // 9 // Much love to the original authors for their work. 10 // ********** 11 // Copyright 2017 The go-ethereum Authors 12 // This file is part of the go-ethereum library. 13 // 14 // The go-ethereum library is free software: you can redistribute it and/or modify 15 // it under the terms of the GNU Lesser General Public License as published by 16 // the Free Software Foundation, either version 3 of the License, or 17 // (at your option) any later version. 18 // 19 // The go-ethereum library is distributed in the hope that it will be useful, 20 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 // GNU Lesser General Public License for more details. 23 // 24 // You should have received a copy of the GNU Lesser General Public License 25 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 26 27 package ethclient 28 29 import ( 30 "errors" 31 "math/big" 32 33 "github.com/MetalBlockchain/subnet-evm/core/types" 34 "github.com/ethereum/go-ethereum/common" 35 ) 36 37 // senderFromServer is a types.Signer that remembers the sender address returned by the RPC 38 // server. It is stored in the transaction's sender address cache to avoid an additional 39 // request in TransactionSender. 40 type senderFromServer struct { 41 addr common.Address 42 blockhash common.Hash 43 } 44 45 var errNotCached = errors.New("sender not cached") 46 47 func setSenderFromServer(tx *types.Transaction, addr common.Address, block common.Hash) { 48 // Use types.Sender for side-effect to store our signer into the cache. 49 types.Sender(&senderFromServer{addr, block}, tx) 50 } 51 52 func (s *senderFromServer) Equal(other types.Signer) bool { 53 os, ok := other.(*senderFromServer) 54 return ok && os.blockhash == s.blockhash 55 } 56 57 func (s *senderFromServer) Sender(tx *types.Transaction) (common.Address, error) { 58 if s.addr == (common.Address{}) { 59 return common.Address{}, errNotCached 60 } 61 return s.addr, nil 62 } 63 64 func (s *senderFromServer) ChainID() *big.Int { 65 panic("can't sign with senderFromServer") 66 } 67 func (s *senderFromServer) Hash(tx *types.Transaction) common.Hash { 68 panic("can't sign with senderFromServer") 69 } 70 func (s *senderFromServer) SignatureValues(tx *types.Transaction, sig []byte) (R, S, V *big.Int, err error) { 71 panic("can't sign with senderFromServer") 72 }