From bda9a38544e88c24947aa1f4e5c15b64c7a0621d Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 15 May 2015 14:34:42 -0400 Subject: [PATCH] CallTx to address with no code fails and costs gas --- state/execution.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/state/execution.go b/state/execution.go index 33eb160ab..d1cdc485e 100644 --- a/state/execution.go +++ b/state/execution.go @@ -403,11 +403,16 @@ func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall bool, evc events.Firea // Maybe create a new callee account if // this transaction is creating a new contract. if !createAccount { - if outAcc == nil { - // take fees (sorry pal) + if outAcc == nil || len(outAcc.Code) == 0 { + // if you call an account that doesn't exist + // or an account with no code then we take fees (sorry pal) inAcc.Balance -= tx.Fee blockCache.UpdateAccount(inAcc) - log.Debug(Fmt("Cannot find destination address %X. Deducting fee from caller", tx.Address)) + if outAcc == nil { + log.Debug(Fmt("Cannot find destination address %X. Deducting fee from caller", tx.Address)) + } else { + log.Debug(Fmt("Attempting to call an account (%X) with no code. Deducting fee from caller", tx.Address)) + } return types.ErrTxInvalidAddress }