2

The official iota-cli app on the IOTA repo has a balance command which is supposed to calculate the balance for the logged in seed.

Sometimes, the command takes ages. I wondered and looked into the code. It seems, as if the balances command first calls getNewAddress. Why is that?

Here is the code: https://github.com/iotaledger/cli-app/blob/9266d7af4de57be0f70ce5b8778981301d5c0657/lib/commands/balance.js#L26

ralf
  • 1,063
  • 5
  • 10

1 Answers1

2

When you call getNewAddress with returnAll: true, it will not only return the new address but all other addresses before that one too. And you have to know all addresses to be able to ask for their balances.

getNewAddress will not attach the new address or anything, just compute addresses until it finds one that has never been used before i.e. findTransactions doesn't return any transactions.

Zauz
  • 4,454
  • 15
  • 42
mihi
  • 7,324
  • 2
  • 15
  • 34