Skip to content

accounts not being created in the correct order in the array. #807

Closed
@alexvandesande

Description

@alexvandesande

Here's a nice snippet of code for checking all your accounts, in order:

function checkAllBalances() { 
    var i =0; 
    eth.accounts.forEach( function(e){
        console.log("\tAccount["+i+"]: \t" +  e + " \tbalance: \t" + web3.fromWei(eth.getBalance(e), "ether") + " ether"); 
        i++; 
    })
}; 

checkAllBalances();

Check all your balances and note their order. Now do a

admin.newAccount()

and run a

checkAllBalances();

Ideally, the newest account should be added in the end of the array. Instead its seemingly added at random, some times in be [0] slot, sometimes in the last slot, sometimes somewhere in the middle. It's not a but in the checkBalances code, you can check each manually by doing a eth.accounts[x].

Currently my accounts were created in this order:

index      order created
  0                 4th
  1                 1st
  2                 3rd
  3                 2nd
  4                 5th

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions