Reputation: 142
I want to use Accounts in my CorDapp and I would like to check if an account already exists before creating a new one.
How can I query the Vault to see if an account with a specific name exists or not?
Upvotes: 0
Views: 111
Reputation: 2548
int numberOfResults = getServiceHub().cordaService(KeyManagementBackedAccountService.class)
.accountInfo("USER_NAME").size();
Btw, this service KeyManagementBackedAccountService
has a lot of useful functions; it comes with the Accounts
library. I recommend exploring it.
Upvotes: 1