diff options
Diffstat (limited to 'core/execution.go')
-rw-r--r-- | core/execution.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/core/execution.go b/core/execution.go index 24e085e6d..93fb03ecc 100644 --- a/core/execution.go +++ b/core/execution.go @@ -50,16 +50,29 @@ func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm. } vsnapshot := env.State().Copy() + var createAccount bool if self.address == nil { // Generate a new address nonce := env.State().GetNonce(caller.Address()) - addr := crypto.CreateAddress(caller.Address(), nonce) env.State().SetNonce(caller.Address(), nonce+1) + + addr := crypto.CreateAddress(caller.Address(), nonce) + self.address = &addr + createAccount = true } snapshot := env.State().Copy() - from, to := env.State().GetStateObject(caller.Address()), env.State().GetOrNewStateObject(*self.address) + var ( + from = env.State().GetStateObject(caller.Address()) + to *state.StateObject + ) + if createAccount { + to = env.State().CreateAccount(*self.address) + } else { + to = env.State().GetOrNewStateObject(*self.address) + } + err = env.Transfer(from, to, self.value) if err != nil { env.State().Set(vsnapshot) |