Strange result for Account Index in the api

After creating a new wallet via API, or creating it via the daedalus UI, I have noticed then when calling:

/api/v1/wallets/{walletId}/accounts

I get strange index in the response - a very large number such as 16723090.
I don’t have access to the machine right now so I can’t tell the exact Index I see in all wallets.
I was expecting it to be 1 for each wallet I created.

Our server is Windows based, and we have the latest cardano/daedalus version.

Did I miss anything or is this a bug?
BTW, Can someone reproduce this please?

Hello! The ID you are getting is probably 2,147,483,648 which is middle of the 32 bit int range of 4'294'967'295 possible values. “Standard” signed int32 type in languages ranges in [−2,147,483,647, +2,147,483,647], but Cardano-SL uses unsigned Haskell type UInt32 which ranges in [0, 4'294'967'295], so what you are getting is basically a signed int32 0 casted to unsigned uint32 type.

Not an issue =)

P.S.

Also was discussed a long time ago in dev chat: https://t.me/CardanoDevelopersOfficial/4806

1 Like

It’s kinda looks weird, tho, I agree. And should be clarified if this will be guaranteed result from now on, so that people can rely on expectations. I will try to clarify this with IOHK.

But the main contract of this value is that it’s unique for each account inside single wallet and that it ranges in [0, 4'294'967'295], but neither guaranteed to start with 0, nor to be sequential.

image

Just remember to use something like int64 (java long) to represent these values properly, if your language\db does not support uint32.

Or use int32 and store (accountId - 2,147,483,648), but this would be too easy to forget =)

2 Likes

Thanks mate! That make sense to me. I will check it more deeply. ( I use .NET c#)

You are correct, if this is true, this might be a bad issue.

I was suggested (by one of the devs?) that account indexes are random. I could not believe it though…

1 Like

And just to be clear. this is the number I see in the raw JSON response.