Benjamin
Benjamin

Reputation: 115

Identification of existance of Corda accounts in main controller API?

How to identify that whether the input string is an account name or host party name from a single parameter in an API function and then route query accordingly in Corda accounts?

Upvotes: 0

Views: 61

Answers (1)

Sneha Damle
Sneha Damle

Reputation: 634

To check if the string name is a well-known counterparty you could use something like this

Party party = proxy.wellKnownPartyFromX500Name(CordaX500Name.parse("O=PartyB,L=New York,C=US"));

To check if an account exists with a particular input string name you could hit the vault using

Vault.Page<AccountInfo> accounts = proxy.vaultQuery(AccountInfo.class);
List<StateAndRef<AccountInfo>>  accountInfos = accounts.getStates();

and check if an account with the specified input name exists in accountInfos.

Upvotes: 1

Related Questions