11package core
22
33import (
4+ "errors"
45 "fmt"
56
67 "github.com/ethereum/go-ethereum/core/types"
@@ -9,7 +10,11 @@ import (
910 "github.com/ethereum/go-ethereum/logger"
1011)
1112
12- var txplogger = logger .NewLogger ("TXP" )
13+ var (
14+ txplogger = logger .NewLogger ("TXP" )
15+
16+ ErrInvalidSender = errors .New ("Invalid sender" )
17+ )
1318
1419const txPoolQueueSize = 50
1520
@@ -60,22 +65,23 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
6065 return fmt .Errorf ("Invalid recipient. len = %d" , len (tx .To ()))
6166 }
6267
68+ // Validate curve param
6369 v , _ , _ := tx .Curve ()
6470 if v > 28 || v < 27 {
6571 return fmt .Errorf ("tx.v != (28 || 27) => %v" , v )
6672 }
6773
74+ // Validate sender address
75+ senderAddr := tx .From ()
76+ if senderAddr == nil || len (senderAddr ) != 20 {
77+ return ErrInvalidSender
78+ }
79+
6880 /* XXX this kind of validation needs to happen elsewhere in the gui when sending txs.
6981 Other clients should do their own validation. Value transfer could throw error
7082 but doesn't necessarily invalidate the tx. Gas can still be payed for and miner
7183 can still be rewarded for their inclusion and processing.
72- // Get the sender
73- senderAddr := tx.From()
74- if senderAddr == nil {
75- return fmt.Errorf("invalid sender")
76- }
7784 sender := pool.stateQuery.GetAccount(senderAddr)
78-
7985 totAmount := new(big.Int).Set(tx.Value())
8086 // Make sure there's enough in the sender's account. Having insufficient
8187 // funds won't invalidate this transaction but simple ignores it.
0 commit comments