I am using accounts library for my project in Corda. I need to create accounts with custom IDs for the account. Till Now I am creating accounts using the CreateAccount Flow which accepts only one parameter which is account name. the Code for the Create Account Flow is as follow:
@InitiatingFlow
@StartableByRPC
public class CreateAccountFlow extends FlowLogic<String> {
private String accountName;
// private UUID userID;
public CreateAccountFlow(String accountName) {
this.accountName = accountName;
}
@Override
@Suspendable
public String call() throws FlowException {
StateAndRef<AccountInfo> newAccount = null;
try {
// newAccount = getServiceHub().cordaService(KeyManagementBackedAccountService.class).createAccount(accountName).get();
newAccount =(StateAndRef<AccountInfo>) subFlow(new CreateAccount(accountName));
} catch (Exception e) {
e.printStackTrace();
}
AccountInfo acc = newAccount.getState().getData();
return "Account "+acc.getName()+ " Created";
}
}
Is there any way so I can create Account with ID and Name both??
Write your own version of the flow which extends CreateAccount
and has a public constructor that accepts both name
and identifier
; as you can see here, the flow already has that constructor but it's marked as private.
Thank Adel, But an error is popping up as I am extending the CreateAccount class, The Error is : Cannot inherit from final 'com.r3.corda.lib.accounts.workflows.flows.CreateAccount'