From 7c24cd790d39b67ee16ad7f1b1a805fcb131dc8a Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 28 Nov 2014 19:39:20 -0500 Subject: [PATCH] fix panic on bad sender --- chain/transaction_pool.go | 6 +++++- chain/types/transaction.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chain/transaction_pool.go b/chain/transaction_pool.go index 119712ba8f..ae96b0251e 100644 --- a/chain/transaction_pool.go +++ b/chain/transaction_pool.go @@ -116,7 +116,11 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { // Get the sender //sender := pool.Ethereum.BlockManager().procState.GetAccount(tx.Sender()) - sender := pool.Ethereum.BlockManager().CurrentState().GetAccount(tx.Sender()) + senderAddr := tx.Sender() + if senderAddr == nil { + return fmt.Errorf("Invalid sender") + } + sender := pool.Ethereum.BlockManager().CurrentState().GetAccount(senderAddr) totAmount := new(big.Int).Set(tx.Value) // Make sure there's enough in the sender's account. Having insufficient diff --git a/chain/types/transaction.go b/chain/types/transaction.go index 626a7e5cec..5599512f6e 100644 --- a/chain/types/transaction.go +++ b/chain/types/transaction.go @@ -116,7 +116,7 @@ func (tx *Transaction) Sender() []byte { // 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 }