Skip to content

Allow some addresses to have zero transactions without skipping balances

Andreas C. Osowski requested to merge mark-bradshaw:missing-addresses into master

Created by: mark-bradshaw

TL;DR sometimes balances mysteriously disappear if an address has somehow been skipped. We need to allow for a little bit of this when calculating balances, otherwise balances end up on addresses further down the chain and disappear until that address comes up in operation.


Another thing I noticed when working on the cli was that my balance on a test seed suddenly disappeared. This was troubling to say the least. :) I looked at the transaction history and I could see no reason for it. A last transaction moved a small amount of iota out to another seed's address, and then banked the remainder in a new address. After that, the banked iota just disappeared.

In determining the reason for this I determined that the address the iota was sent to, while valid for the seed, was not showing up in the list of addresses used in determining the account balance. I tracked that down to some code in getNewAddress.

The logic in that function that enumerates addresses in use stops immediately when it finds an address without transactions. However, in practice it turns out that occasionally addresses will get skipped. Because of this the address enumeration often stops too soon, and skips valid addresses with actual balances.

I'm not sure my fix here is a perfect one, but what I found was that while enumerating addresses once I'd seen about five go past with zero transactions, that signaled the end of the actively used addresses. It may not be a perfect fix, but it seems likely to work better in practice than the current logic.

Merge request reports