|
@ -282,22 +282,22 @@ func (s *State) ExecTx(tx_ blk.Tx, runCall bool) error { |
|
|
// Validate input
|
|
|
// Validate input
|
|
|
inAcc = s.GetAccount(tx.Input.Address) |
|
|
inAcc = s.GetAccount(tx.Input.Address) |
|
|
if inAcc == nil { |
|
|
if inAcc == nil { |
|
|
log.Debug("Can't find in account %X", tx.Input.Address) |
|
|
|
|
|
|
|
|
log.Debug(Fmt("Can't find in account %X", tx.Input.Address)) |
|
|
return blk.ErrTxInvalidAddress |
|
|
return blk.ErrTxInvalidAddress |
|
|
} |
|
|
} |
|
|
// pubKey should be present in either "inAcc" or "tx.Input"
|
|
|
// pubKey should be present in either "inAcc" or "tx.Input"
|
|
|
if err := checkInputPubKey(inAcc, tx.Input); err != nil { |
|
|
if err := checkInputPubKey(inAcc, tx.Input); err != nil { |
|
|
log.Debug("Can't find pubkey for %X", tx.Input.Address) |
|
|
|
|
|
|
|
|
log.Debug(Fmt("Can't find pubkey for %X", tx.Input.Address)) |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
signBytes := account.SignBytes(tx) |
|
|
signBytes := account.SignBytes(tx) |
|
|
err := s.ValidateInput(inAcc, signBytes, tx.Input) |
|
|
err := s.ValidateInput(inAcc, signBytes, tx.Input) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Debug("ValidateInput failed on %X:", tx.Input.Address) |
|
|
|
|
|
|
|
|
log.Debug(Fmt("ValidateInput failed on %X:", tx.Input.Address)) |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
if tx.Input.Amount < tx.Fee { |
|
|
if tx.Input.Amount < tx.Fee { |
|
|
log.Debug("Sender did not send enough to cover the fee %X", tx.Input.Address) |
|
|
|
|
|
|
|
|
log.Debug(Fmt("Sender did not send enough to cover the fee %X", tx.Input.Address)) |
|
|
return blk.ErrTxInsufficientFunds |
|
|
return blk.ErrTxInsufficientFunds |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -305,12 +305,12 @@ func (s *State) ExecTx(tx_ blk.Tx, runCall bool) error { |
|
|
if !createAccount { |
|
|
if !createAccount { |
|
|
// Validate output
|
|
|
// Validate output
|
|
|
if len(tx.Address) != 20 { |
|
|
if len(tx.Address) != 20 { |
|
|
log.Debug("Destination address is not 20 bytes %X", tx.Address) |
|
|
|
|
|
|
|
|
log.Debug(Fmt("Destination address is not 20 bytes %X", tx.Address)) |
|
|
return blk.ErrTxInvalidAddress |
|
|
return blk.ErrTxInvalidAddress |
|
|
} |
|
|
} |
|
|
outAcc = s.GetAccount(tx.Address) |
|
|
outAcc = s.GetAccount(tx.Address) |
|
|
if outAcc == nil { |
|
|
if outAcc == nil { |
|
|
log.Debug("Cannot find destination address %X", tx.Address) |
|
|
|
|
|
|
|
|
log.Debug(Fmt("Cannot find destination address %X", tx.Address)) |
|
|
return blk.ErrTxInvalidAddress |
|
|
return blk.ErrTxInvalidAddress |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -344,7 +344,7 @@ func (s *State) ExecTx(tx_ blk.Tx, runCall bool) error { |
|
|
} else { |
|
|
} else { |
|
|
callee, err = appState.CreateAccount(caller) |
|
|
callee, err = appState.CreateAccount(caller) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Debug("Error creating account") |
|
|
|
|
|
|
|
|
log.Debug(Fmt("Error creating account")) |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
code = tx.Data |
|
|
code = tx.Data |
|
@ -365,6 +365,7 @@ func (s *State) ExecTx(tx_ blk.Tx, runCall bool) error { |
|
|
if createAccount { |
|
|
if createAccount { |
|
|
callee.Code = ret |
|
|
callee.Code = ret |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
appState.Sync() |
|
|
appState.Sync() |
|
|
} |
|
|
} |
|
|
// Create a receipt from the ret and whether errored.
|
|
|
// Create a receipt from the ret and whether errored.
|
|
|