Last active
June 30, 2020 20:17
-
-
Save davidawad/58bffcd790f41349a5acc2e5ba8c159d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public TokenIssueFlowInitiator(Party owner, int amount) { | |
this.owner = owner; | |
this.amount = amount; | |
} | |
@Suspendable | |
@Override | |
public SignedTransaction call() throws FlowException { | |
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); | |
Party issuer = getOurIdentity(); | |
TokenState tokenState = new TokenState(issuer, owner, amount); | |
TransactionBuilder transactionBuilder = new TransactionBuilder(notary); | |
CommandData commandData = new TokenContract.Commands.Issue(); | |
transactionBuilder.addCommand(commandData, issuer.getOwningKey(), owner.getOwningKey()); | |
transactionBuilder.addOutputState(tokenState, TokenContract.ID); | |
transactionBuilder.verify(getServiceHub()); | |
FlowSession session = initiateFlow(owner); | |
SignedTransaction signedTransaction = getServiceHub().signInitialTransaction(transactionBuilder); | |
SignedTransaction fullySignedTransaction = subFlow(new CollectSignaturesFlow(signedTransaction, singletonList(session))); | |
return subFlow(new FinalityFlow(fullySignedTransaction, singletonList(session))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment