Merge branch 'ebuchman-badsig' into poc8

This commit is contained in:
obscuren 2014-12-19 00:33:32 +01:00
commit 75f0412f9d
4 changed files with 14 additions and 10 deletions

View File

@ -301,7 +301,7 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
addr := gui.address() addr := gui.address()
var inout string var inout string
if bytes.Compare(tx.Sender(), addr) == 0 { if bytes.Compare(tx.From(), addr) == 0 {
inout = "send" inout = "send"
} else { } else {
inout = "recv" inout = "recv"
@ -321,7 +321,7 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
if send.Len() != 0 { if send.Len() != 0 {
s = strings.Trim(send.Str(), "\x00") s = strings.Trim(send.Str(), "\x00")
} else { } else {
s = ethutil.Bytes2Hex(tx.Sender()) s = ethutil.Bytes2Hex(tx.From())
} }
if rec.Len() != 0 { if rec.Len() != 0 {
r = strings.Trim(rec.Str(), "\x00") r = strings.Trim(rec.Str(), "\x00")
@ -453,7 +453,7 @@ func (gui *Gui) update() {
tx := ev.Tx tx := ev.Tx
object := state.GetAccount(gui.address()) object := state.GetAccount(gui.address())
if bytes.Compare(tx.Sender(), gui.address()) == 0 { if bytes.Compare(tx.From(), gui.address()) == 0 {
object.SubAmount(tx.Value()) object.SubAmount(tx.Value())
gui.txDb.Put(tx.Hash(), tx.RlpEncode()) gui.txDb.Put(tx.Hash(), tx.RlpEncode())

View File

@ -116,7 +116,11 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
} }
// Get the sender // 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()) totAmount := new(big.Int).Set(tx.Value())
// Make sure there's enough in the sender's account. Having insufficient // 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() { for e := pool.pool.Front(); e != nil; e = e.Next() {
tx := e.Value.(*types.Transaction) tx := e.Value.(*types.Transaction)
sender := state.GetAccount(tx.Sender()) sender := state.GetAccount(tx.From())
err := pool.ValidateTransaction(tx) err := pool.ValidateTransaction(tx)
if err != nil || sender.Nonce >= tx.Nonce() { if err != nil || sender.Nonce >= tx.Nonce() {
pool.pool.Remove(e) pool.pool.Remove(e)

View File

@ -77,7 +77,7 @@ func (self *Transaction) SetNonce(nonce uint64) {
} }
func (self *Transaction) From() []byte { func (self *Transaction) From() []byte {
return self.Sender() return self.sender()
} }
func (self *Transaction) To() []byte { func (self *Transaction) To() []byte {
@ -114,12 +114,12 @@ func (tx *Transaction) PublicKey() []byte {
return pubkey return pubkey
} }
func (tx *Transaction) Sender() []byte { func (tx *Transaction) sender() []byte {
pubkey := tx.PublicKey() pubkey := tx.PublicKey()
// Validate the returned key. // Validate the returned key.
// Return nil if public key isn't in full format // 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 return nil
} }
@ -187,7 +187,7 @@ func (tx *Transaction) String() string {
`, `,
tx.Hash(), tx.Hash(),
len(tx.recipient) == 0, len(tx.recipient) == 0,
tx.Sender(), tx.From(),
tx.recipient, tx.recipient,
tx.nonce, tx.nonce,
tx.gasPrice, tx.gasPrice,

View File

@ -100,7 +100,7 @@ func NewJSTx(tx *types.Transaction, state *state.StateDB) *JSTransaction {
if receiver == "0000000000000000000000000000000000000000" { if receiver == "0000000000000000000000000000000000000000" {
receiver = ethutil.Bytes2Hex(core.AddressFromMessage(tx)) receiver = ethutil.Bytes2Hex(core.AddressFromMessage(tx))
} }
sender := ethutil.Bytes2Hex(tx.Sender()) sender := ethutil.Bytes2Hex(tx.From())
createsContract := core.MessageCreatesContract(tx) createsContract := core.MessageCreatesContract(tx)
var data string var data string