accounts icon indicating copy to clipboard operation
accounts copied to clipboard

How to extend AccountInfo ContractState

Open cmaliwal opened this issue 5 years ago • 7 comments

I have a use case where each account would have some extra details like First Name, Last Name, Email etc. I noticed that your library creates AccountInfo State which is accessible by all accounts on the same node. So, can we extend AccountInfo such it can store custom fields along with name, host and identifier? Also, is it wise to create another State to store user information and share it with all the other accounts on the same node?

cmaliwal avatar Nov 14 '19 12:11 cmaliwal

AccountInfo is not currently extendable but perhaps it could be in the future. Reason being is that it's usually not a good idea to put personal information about account holders on the ledger. There are a number of options you have:

  1. Store the user information off-ledger in a series of Hibernate entities. You can join this data to the associated account using the account ID (externalId)
  2. Create a series of state objects for holding this data (name, email, etc.) and link them to the account info by including the AccountInfo as a reference state in the transactions which create the data states.

roger-that-dev avatar Nov 19 '19 09:11 roger-that-dev

How Accounts authenticate a request i.e. how to ensure that the user that is invoking the Flow is a correct person? In the current implementation, this library just requires UUID of account to perform the transaction. So, if any other account has my accountId then he can perform operations on my behalf?. Also, I noticed that AccountInfo (name, host, accountId) is/should be public at the network level (to know all available accounts across nodes).

So, How this implementation ensures that the invoker of the Flow is an authenticated account?

manjeet-thadani avatar Nov 27 '19 12:11 manjeet-thadani

@roger3cev this is what we're after as well in a project currently, but the CreateAccount flow doesn't allow setting an (optional) externalId. Also the field is not available for queries in PersistentAccountInfo. Does it make sense for me to make a (backwards compatible) PR for this?

manosbatsis avatar Dec 21 '20 15:12 manosbatsis

@manosbatsis I use the name property of the AccountInfo state each time I need an external identifier for the account (actually I couldn't find any other utility for this property :D ) - maybe it fits your use case also ...

mevir avatar Dec 21 '20 20:12 mevir

@mevir that won't work for me - need the name for a human-readable handle, which is why i'm after a more accessible externalId as a business key.

manosbatsis avatar Dec 21 '20 21:12 manosbatsis

@manosbatsis well, the name must be unique at the node level. If you want to use something like firstName lastName as a human-readable handle the probability of collisions is high. Also take care of personal data - if the owner of the account is a EU citizen he has the right to be forgotten under GDPR - I don't know how this can be handled as long as the AccountInfo state can be shared freely with other nodes - is there is a tracking for this?

mevir avatar Dec 21 '20 22:12 mevir

@mevir our use-cases are more about agents like services or legal entities VS persons, where having both an external business key as externalId along with a (unique) human readable name is very convenient. PR https://github.com/corda/accounts/pull/105 allows the typical LinearState.linearId.externalId approach with AccountInfo.

Indeed user accounts need more careful consideration; i believe even usernames are borderline GDPR-wise.

manosbatsis avatar Dec 22 '20 12:12 manosbatsis