Skip to content

Instantly share code, notes, and snippets.

@ashutoshmeher-r3
Last active October 25, 2021 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashutoshmeher-r3/d0ca80143902da7df15e2a5b85db0ed5 to your computer and use it in GitHub Desktop.
Save ashutoshmeher-r3/d0ca80143902da7df15e2a5b85db0ed5 to your computer and use it in GitHub Desktop.
@InitiatingFlow
@StartableByRPC
public class IssueLandTitleFlow implements Flow<Void>{
// FlowIdentity, IdentityService and NotaryLookupService Injected Here
@CordaInject
private TransactionBuilderFactory transactionBuilderFactory;
@CordaInject
private FlowEngine flowEngine;
@CordaInject
private FlowMessaging flowMessaging;
@Override
@Suspendable
public Void call() {
// Code Here to fetch identites as dicuscussed earlier i.e. notary, owner and issuer.
// Build the transaction.
TransactionBuilder transactionBuilder = transactionBuilderFactory.create()
.setNotary(notary)
.addOutputState(landTitleOutputState)
.addCommand(new LandTitleContract.Commands.Issue(), Arrays.asList(issuer.getOwningKey()));
// Verify that the transaction is valid.
transactionBuilder.verify();
// Self Sign the transaction.
SignedTransaction signedTx = transactionBuilder.sign();
// Notarise and record the transaction
FlowSession receiverSession = flowMessaging.initiateFlow(landTitleState.getOwner());
SignedTransaction notarisedTx = flowEngine.subFlow(new FinalityFlow(signedTx, Arrays.asList(receiverSession)));
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment