0

我创建了一个交易对手会话,发行人通过将其密钥传递给 signInitialTransaction 来签署交易。然后,当我调用 CollectSignaturesFlow 来获取买家的签名时,它会抛出“无法匹配密钥”异常。

不知道出了什么问题。

这是我的发起人流程。

package com.template.flows;

@InitiatingFlow
@StartableByRPC
public class InitiateTicketMovementFlow extends FlowLogic<String> {
private final String buyer;
private final String issuer;
private final StateRef assetReference;

public InitiateTicketMovementFlow(String buyer, String issuer, String hash, int index) {
    this.buyer = buyer;
    this.issuer = issuer;
    this.assetReference = new StateRef(SecureHash.parse(hash), index);
}

@Override
@Suspendable
public String call() throws FlowException {

    final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);

    AccountInfo issuerAccountInfo = UtilitiesKt.getAccountService(this)
            .accountInfo(issuer).get(0).getState().getData();

    AccountInfo receiverAccountInfo = UtilitiesKt.getAccountService(this)
            .accountInfo(buyer).get(0).getState().getData();

    AnonymousParty buyerAccount = subFlow(new RequestKeyForAccount(receiverAccountInfo));

    QueryCriteria.VaultQueryCriteria queryCriteria = new QueryCriteria.VaultQueryCriteria()
            .withStateRefs(ImmutableList.of(assetReference));

    StateAndRef<CustomTicket> ticketStateStateAndRef = getServiceHub().getVaultService()
            .queryBy(CustomTicket.class, queryCriteria).getStates().get(0);

    CustomTicket ticketState = ticketStateStateAndRef.getState().getData();

    TransactionBuilder txBuilder = new TransactionBuilder(notary);

    MoveTokensUtilities.addMoveNonFungibleTokens(txBuilder, getServiceHub(),
            ticketState.toPointer(CustomTicket.class), receiverAccountInfo.getHost());

    FlowSession buyerSession = initiateFlow(receiverAccountInfo.getHost());
    buyerSession.send(ticketState.getValuation());

    List<StateAndRef<FungibleToken>> inputs = subFlow(new ReceiveStateAndRefFlow<>(buyerSession));

    List<FungibleToken> moneyReceived = buyerSession.receive(List.class).unwrap(value -> value);

    MoveTokensUtilities.addMoveTokens(txBuilder, inputs, moneyReceived);

    SignedTransaction selfSignedTransaction = getServiceHub().
            signInitialTransaction(txBuilder, ImmutableList.of(issuerAccountInfo.getHost().getOwningKey()));


    SignedTransaction signedTransaction = subFlow(new CollectSignaturesFlow(
            selfSignedTransaction, Arrays.asList(buyerSession), Collections.singleton(issuerAccountInfo.getHost().getOwningKey())));

    SignedTransaction stx = subFlow(new FinalityFlow(
            signedTransaction, ImmutableList.of(buyerSession)));

    subFlow(new UpdateDistributionListFlow(stx));

    return "\nTicket is sold to "+ buyer;
    }
}
4

1 回答 1

0

似乎这里的问题是您以错误的方式获取买家帐户?或者最终流程调用可能已关闭。看看我们的样本。

也许尝试这样的事情来获取您的帐户信息

AccountInfo targetAccount = accountService.accountInfo(<STRING NAME OF ACCOUNT >).get(0);

src 是我们的 Corda 示例存储库:https ://github.com/corda/samples-java/blob/master/Accounts/supplychain/workflows/src/main/java/net/corda/samples/supplychain/flows/SendShippingRequest.java #L80

另外,请注意 finality 调用的不同之处:

https://github.com/corda/samples-java/blob/master/Accounts/supplychain/workflows/src/main/java/net/corda/samples/supplychain/flows/SendShippingRequest.java#L112

于 2021-06-14T15:08:19.423 回答