diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/transaction_pool.go | 8 | ||||
-rw-r--r-- | core/types/transaction.go | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 17fcdb86a..1149d4cfb 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -116,7 +116,11 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { } // Get the sender - sender := pool.chainManager.State().GetAccount(tx.Sender()) + senderAddr := tx.From() + if senderAddr == nil { + return fmt.Errorf("invalid sender") + } + sender := pool.chainManager.State().GetAccount(senderAddr) totAmount := new(big.Int).Set(tx.Value()) // Make sure there's enough in the sender's account. Having insufficient @@ -193,7 +197,7 @@ func (pool *TxPool) RemoveInvalid(state *state.StateDB) { for e := pool.pool.Front(); e != nil; e = e.Next() { tx := e.Value.(*types.Transaction) - sender := state.GetAccount(tx.Sender()) + sender := state.GetAccount(tx.From()) err := pool.ValidateTransaction(tx) if err != nil || sender.Nonce >= tx.Nonce() { pool.pool.Remove(e) diff --git a/core/types/transaction.go b/core/types/transaction.go index c64fb69f0..95a256a76 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -77,7 +77,7 @@ func (self *Transaction) SetNonce(nonce uint64) { } func (self *Transaction) From() []byte { - return self.Sender() + return self.sender() } func (self *Transaction) To() []byte { @@ -114,12 +114,12 @@ func (tx *Transaction) PublicKey() []byte { return pubkey } -func (tx *Transaction) Sender() []byte { +func (tx *Transaction) sender() []byte { pubkey := tx.PublicKey() // Validate the returned key. // Return nil if public key isn't in full format - if len(pubkey) != 0 && pubkey[0] != 4 { + if len(pubkey) == 0 || pubkey[0] != 4 { return nil } @@ -187,7 +187,7 @@ func (tx *Transaction) String() string { `, tx.Hash(), len(tx.recipient) == 0, - tx.Sender(), + tx.From(), tx.recipient, tx.nonce, tx.gasPrice, |