github.com/neatio-net/neatio@v1.7.3-0.20231114194659-f4d7a2226baa/neatcli/signer.go (about) 1 package neatcli 2 3 import ( 4 "errors" 5 "math/big" 6 7 "github.com/neatio-net/neatio/chain/core/types" 8 "github.com/neatio-net/neatio/utilities/common" 9 ) 10 11 type senderFromServer struct { 12 addr common.Address 13 blockhash common.Hash 14 } 15 16 var errNotCached = errors.New("sender not cached") 17 18 func setSenderFromServer(tx *types.Transaction, addr common.Address, block common.Hash) { 19 20 types.Sender(&senderFromServer{addr, block}, tx) 21 } 22 23 func (s *senderFromServer) Equal(other types.Signer) bool { 24 os, ok := other.(*senderFromServer) 25 return ok && os.blockhash == s.blockhash 26 } 27 28 func (s *senderFromServer) Sender(tx *types.Transaction) (common.Address, error) { 29 if s.blockhash == (common.Hash{}) { 30 return common.Address{}, errNotCached 31 } 32 return s.addr, nil 33 } 34 35 func (s *senderFromServer) Hash(tx *types.Transaction) common.Hash { 36 panic("can't sign with senderFromServer") 37 } 38 func (s *senderFromServer) SignatureValues(tx *types.Transaction, sig []byte) (R, S, V *big.Int, err error) { 39 panic("can't sign with senderFromServer") 40 }