Two-party flow tutorial issue <Solved>


(jikang shin) #1

I was confused by different versions of tutorials.
I wish I can delete my post, but I don’t know how; so just modified the post.


I’m following tutorials, and got error message while running two-party flows.
When I try to start IOUFlow, I got contract verification fail message:

☠ Contract verification failed: Failed requirement: There must be two signers., contract: com.template.contract.IOUContract@6ee89940, transaction: B95D992F415B45F0CD909AC7D2854DC6523FA99976F87024DD1D47F4C922E42A

I modified IOUFlow and IOUContract following the instructions in the tutorial,
and here is my code for IOUFlow.call()

public Void call() throws FlowException {
    // We retrieve the required identities from the network map.
    final Party me = getServiceHub().getMyInfo().getLegalIdentity();
    final Party notary = getServiceHub().getNetworkMapCache().getAnyNotary(null);

    // We create a transaction builder.
    final TransactionBuilder txBuilder = new TransactionBuilder();
    txBuilder.setNotary(notary);

    // We add the items to the builder.
    IOUState state = new IOUState(iouValue, me, otherParty);
    List<PublicKey> requiredSigners = ImmutableList.of(me.getOwningKey(),otherParty.getOwningKey());
    Command cmd = new Command(new IOUContract.Create(), requiredSigners);
    txBuilder.withItems(state, cmd);

    // Verifying the transaction.
    txBuilder.verify(getServiceHub());

    // Signing the transaction.
    final SignedTransaction signedTx = getServiceHub().signInitialTransaction(txBuilder);

    final SignedTransaction fullySignedTx = subFlow(new CollectSignaturesFlow(signedTx, CollectSignaturesFlow.Companion.tracker()));

    // Finalising the transaction.
    subFlow(new FinalityFlow(fullySignedTx));

    return null;
}