Java 从corda中的事务中检索帐户名

Java 从corda中的事务中检索帐户名,java,blockchain,corda,Java,Blockchain,Corda,我在Corda中创建了一个流,它与两个其他帐户共享一个状态,每个帐户托管在不同的节点上。 在使用vault Query查询任一参与者的vault时,它会显示一些ID来代替参与者的名称。流的调用函数的代码如下所示 public SignedTransaction call() throws FlowException { AccountService accountService = getServiceHub().cordaService(KeyManagementBackedAccou

我在Corda中创建了一个流,它与两个其他帐户共享一个状态,每个帐户托管在不同的节点上。 在使用vault Query查询任一参与者的vault时,它会显示一些ID来代替参与者的名称。流的调用函数的代码如下所示

public SignedTransaction call() throws FlowException {
    AccountService accountService = getServiceHub().cordaService(KeyManagementBackedAccountService.class);

    //Owner Account
    AccountInfo policyOwnerAccountInfo = accountService.accountInfo(policyOwner).get(0).getState().getData();
    PublicKey policyOwnerKey = subFlow(new NewKeyForAccount(policyOwnerAccountInfo.getIdentifier().getId())).getOwningKey();

    //Insurance Company Account
    AccountInfo insurerAccountInfo = accountService.accountInfo(insuranceCompany).get(0).getState().getData();
    AnonymousParty insuranceCompanyAccount = subFlow(new RequestKeyForAccount(insurerAccountInfo));

    //LSP account
    AccountInfo lspAccountInfo = accountService.accountInfo(lsp).get(0).getState().getData();
    AnonymousParty lspAccount = subFlow(new RequestKeyForAccount(lspAccountInfo));

    List<AccountInfo> parties = new ArrayList<>();
    parties.add(insurerAccountInfo);
    parties.add(lspAccountInfo);


    // Step 1. Get a reference to the notary service on our network and our key pair.
    // Note: ongoing work to support multiple notary identities is still in progress.
    final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);

//        UniqueIdentifier policyLinearId = new UniqueIdentifier(policyID);
    final PolicyState output = new PolicyState(new UniqueIdentifier(), policyID, sellerID, insurerID, policyNo, faceValue, deathBenefits, annualPremium, cashSurrenderValue, policyStartDate,new AnonymousParty(policyOwnerKey), false, Arrays.asList(insuranceCompanyAccount,lspAccount), true);

    progressTracker.setCurrentStep(GENERATING_TRANSACTION);
    final TransactionBuilder builder = new TransactionBuilder(notary);
    //Adding outputState to the transaction
    progressTracker.setCurrentStep(ADDING_POLICY);
    builder.addOutputState(output, PolicyContract.ID);
    builder.addCommand(new PolicyContract.Commands.Create(), Arrays.asList(policyOwnerKey,insuranceCompanyAccount.getOwningKey(),lspAccount.getOwningKey()));

//  self sign Transaction
    progressTracker.setCurrentStep(SIGNING_TRANSACTION);
    builder.verify(getServiceHub());
    SignedTransaction locallySignedTx = getServiceHub().signInitialTransaction(builder, Arrays.asList(getOurIdentity().getOwningKey(),policyOwnerKey));


    progressTracker.setCurrentStep(GATHERING_SIGS);
    FlowSession session = initiateFlow(insurerAccountInfo.getHost());
    List<TransactionSignature> accountToMoveToSignature = (List<TransactionSignature>) subFlow(new CollectSignatureFlow(locallySignedTx,
                    session,insuranceCompanyAccount.getOwningKey()));
    SignedTransaction signedByCounterParty = locallySignedTx.withAdditionalSignatures(accountToMoveToSignature);

    FlowSession session1 = initiateFlow(lspAccountInfo.getHost());
    List<TransactionSignature> accountToMoveToSignature1 = (List<TransactionSignature>) subFlow(new CollectSignatureFlow(signedByCounterParty,
                    session1,lspAccount.getOwningKey()));
    signedByCounterParty = signedByCounterParty.withAdditionalSignatures(accountToMoveToSignature1);

    progressTracker.setCurrentStep(FINALISING_TRANSACTION);
    return subFlow(new FinalityFlow(signedByCounterParty, session,session1));
    getOurIdentity()).collect(Collectors.toList())));
}
public SignedTransaction调用()引发流异常{
AccountService AccountService=getServiceHub().cordaService(KeyManagementBackedAccountService.class);
//所有者帐户
AccountInfo policyOwnerAccountInfo=accountService.AccountInfo(policyOwner.get(0).getState().getData();
PublicKey policyOwnerKey=子流(新的NewKeyForAccount(policyOwnerAccountInfo.getIdentifier().getId()).getOwningKey();
//保险公司帐户
AccountInfo InsuranceAccountInfo=accountService.AccountInfo(保险公司).get(0.getState().getData();
AnonymousParty insuranceCompanyAccount=子流(新RequestKeyForAccount(InsuralerAccountInfo));
//LSP帐户
AccountInfo lspAccountInfo=accountService.AccountInfo(lsp).get(0.getState().getData();
AnonymousParty lspAccount=子流(新RequestKeyForAccount(lspAccountInfo));

列表

这是一种预期行为。当我们在某个状态下使用帐户时,我们使用的是AnonymousParty类,它只有公钥而没有合法名称。这与帐户不是Corda身份且没有合法名称这一事实是一致的

您需要构建一个自定义流来获取帐户名。您可以借助提供api的帐户服务来完成此操作。下面是一个您可以参考的示例: