// Creates a 20 byte address and bumps the creator's nonce. func (cache *TxCache) CreateAccount(creator *vm.Account) *vm.Account { // Generate an address nonce := creator.Nonce creator.Nonce += 1 addr := LeftPadWord256(NewContractAddress(creator.Address.Postfix(20), int(nonce))) // Create account from address. account, removed := cache.accounts[addr].unpack() if removed || account == nil { account = &vm.Account{ Address: addr, Balance: 0, Code: nil, Nonce: 0, Permissions: cache.GetAccount(ptypes.GlobalPermissionsAddress256).Permissions, Other: vmAccountOther{ PubKey: nil, StorageRoot: nil, }, } cache.accounts[addr] = vmAccountInfo{account, false} return account } else { // either we've messed up nonce handling, or sha3 is broken PanicSanity(Fmt("Could not create account, address already exists: %X", addr)) return nil } }
// Creates a 20 byte address and bumps the creator's nonce. func (cache *TxCache) CreateAccount(creator *vm.Account) *vm.Account { // Generate an address nonce := creator.Nonce creator.Nonce += 1 addr := LeftPadWord256(NewContractAddress(creator.Address.Postfix(20), nonce)) // Create account from address. account, removed := vmUnpack(cache.accounts[addr]) if removed || account == nil { account = &vm.Account{ Address: addr, Balance: 0, Code: nil, Nonce: 0, StorageRoot: Zero256, } cache.accounts[addr] = vmAccountInfo{account, false} return account } else { panic(Fmt("Could not create account, address already exists: %X", addr)) } }