Relationship between PrincipalId and AccountIdentifier


Given a PrincipalId: is there a way to find / construct a valid “default” AccountIdentifier for it?

Also: given an AccountIdentifier and a PrincipalId: is t possible to check that the former is controlled (i.e. funds can be spent) by the latter?

There’s a tool to convert a principal to its default account id here:

The principal will convert to the account id it owns, so for the default account just converting it and seeing if the account ids match is your check. But you can also have sub accounts (the default account id is just the sub account set to 0) and for these you’d need to know the sub account name to generate its id, since you can’t go the other way (from account id to principal).

Some great detail on all of this is in these two links, including how to derive the ids yourself: 3


Thank you for your reply – very useful!