Class SignTransactionFlow
-
- All Implemented Interfaces:
public abstract class SignTransactionFlow extends FlowLogic<SignedTransaction>
The SignTransactionFlow should be called in response to the CollectSignaturesFlow. It automates the signing of a transaction providing the transaction:
Should actually be signed by the Party invoking this flow
Is valid as per the contracts referenced in the transaction
Has been, at least, signed by the counterparty which created it
Conforms to custom checking provided in the checkTransaction method of the SignTransactionFlow
Usage:
Subclass SignTransactionFlow - this can be done inside an existing flow (as shown below)
Override the checkTransaction method to add some custom verification logic
Call the flow via FlowLogic.subFlow
The flow returns the transaction signed with the additional signature.
Example - checking and signing a transaction involving a
DummyContract
, see CollectSignaturesFlowTests.kt for further examples:class Responder(val otherPartySession: FlowSession): FlowLogic<SignedTransaction>() { @Suspendable override fun call(): SignedTransaction { // [SignTransactionFlow] sub-classed as a singleton object. val flow = object : SignTransactionFlow(otherPartySession) { @Suspendable override fun checkTransaction(stx: SignedTransaction) = requireThat { val tx = stx.tx val magicNumberState = tx.outputs.single().data as DummyContract.MultiOwnerState "Must be 1337 or greater" using (magicNumberState.magicNumber >= 1337) } } // Invoke the subFlow, in response to the counterparty calling [CollectSignaturesFlow]. val expectedTxId = subFlow(flow).id return subFlow(ReceiveFinalityFlow(otherPartySession, expectedTxId)) } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
SignTransactionFlow.Companion
-
Field Summary
Fields Modifier and Type Field Description private final FlowSession
otherSideSession
private final ProgressTracker
progressTracker
private final <Error class: unknown class>
logger
private final StateMachineRunId
runId
private final ServiceHub
serviceHub
private final Boolean
isKilled
private final PartyAndCertificate
ourIdentityAndCert
private final Party
ourIdentity
public final static SignTransactionFlow.Companion
Companion
-
Constructor Summary
Constructors Constructor Description SignTransactionFlow(FlowSession otherSideSession, ProgressTracker progressTracker)
-
Method Summary
Modifier and Type Method Description final FlowSession
getOtherSideSession()
ProgressTracker
getProgressTracker()
Override this to provide a ProgressTracker. SignedTransaction
call()
This is where you fill out your business logic. -
Methods inherited from class net.corda.core.flows.FlowLogic
await, await, checkFlowIsNotKilled, checkFlowIsNotKilled, checkFlowPermission, close, flowStackSnapshot, getFlowInfo, getLogger, getOurIdentity, getOurIdentityAndCert, getRunId, getServiceHub, initiateFlow, initiateFlow, isKilled, persistFlowStackSnapshot, receive, receive, receiveAll, receiveAllMap, recordAuditEvent, send, sendAll, sendAllMap, sendAndReceive, sendAndReceive, subFlow, track, trackStepsTree, trackStepsTreeIndex, waitForLedgerCommit, waitForStateConsumption
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
SignTransactionFlow
SignTransactionFlow(FlowSession otherSideSession, ProgressTracker progressTracker)
- Parameters:
otherSideSession
- The session which is providing you a transaction to sign.
-
-
Method Detail
-
getOtherSideSession
final FlowSession getOtherSideSession()
-
getProgressTracker
ProgressTracker getProgressTracker()
Override this to provide a ProgressTracker. If one is provided and stepped, the framework will do something helpful with the progress reports e.g record to the audit service. If this flow is invoked as a subflow of another, then the tracker will be made a child of the current step in the parent. If it's null, this flow doesn't track progress.
Note that this has to return a tracker before the flow is invoked. You can't change your mind half way through.
-
call
SignedTransaction call()
This is where you fill out your business logic.
-
-
-
-