0
votes

I want to create transaction with self node using corda 4.0 .

I used sample IOU example for this and added my changes in ExampleFlow as shown in below code . https://github.com/corda/cordapp-example/tree/release-V4/java-source.

But its not allowing to create transaction with self node.

also I followed/implemented the answers from this Corda 4 - Single Party Transaction Failed to Commit to Ledger

but it didnt work out.

I made Only changes in ExampleFlow as shown below / Rest of the code from iOU example is same.

Please help.

@Suspendable
override fun call(): SignedTransaction {
// Obtain a reference to the notary we want to use.
val notary = serviceHub.networkMapCache.notaryIdentities[0]

// Stage 1.
progressTracker.currentStep = GENERATING_TRANSACTION
// Generate an unsigned transaction.
val iouState = IOUState(iouValue, serviceHub.myInfo.legalIdentities.first(), otherParty)
val txCommand = Command(IOUContract.Commands.Create(), listOf(ourIdentity.owningKey))
val txBuilder = TransactionBuilder(notary)
        .addOutputState(iouState, IOU_CONTRACT_ID)
        .addCommand(txCommand)

// Stage 2.
progressTracker.currentStep = VERIFYING_TRANSACTION
// Verify that the transaction is valid.
txBuilder.verify(serviceHub)

// Stage 3.
progressTracker.currentStep = SIGNING_TRANSACTION
// Sign the transaction.
val partSignedTx = serviceHub.signInitialTransaction(txBuilder)

// Stage 5.
progressTracker.currentStep = FINALISING_TRANSACTION
// Notarise and record the transaction in both parties' vaults.
return subFlow(FinalityFlow(partSignedTx,emptyList()))
}
1

1 Answers

0
votes

I believe the issue is because you are using the otherparty in the state:

val iouState = IOUState(iouValue, serviceHub.myInfo.legalIdentities.first(), otherParty)

Corda 4 requires that all participants flowsession must be provided in the FinalityFlow, so that the state information could be distributed properly.

Refer here for more Flow Sessions we're not provided for following transaction participants - Corda 4