abstract class SignTransactionFlow : FlowLogic<SignedTransaction>
The SignTransactionFlow should be called in response to the CollectSignaturesFlow. It automates the signing of a transaction providing the transaction:
Usage:
Example - checking and signing a transaction involving a net.corda.core.contracts.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))
}
}
otherSideSession
- The session which is providing you a transaction to sign.
RECEIVING |
object RECEIVING : Step |
SIGNING |
object SIGNING : Step |
VERIFYING |
object VERIFYING : Step |
<init> |
The SignTransactionFlow should be called in response to the CollectSignaturesFlow. It automates the signing of a transaction providing the transaction: SignTransactionFlow(otherSideSession: FlowSession, progressTracker: ProgressTracker = SignTransactionFlow.tracker()) |
otherSideSession |
The session which is providing you a transaction to sign. val otherSideSession: FlowSession |
progressTracker |
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. open val progressTracker: ProgressTracker |
call |
This is where you fill out your business logic. open fun call(): SignedTransaction |
checkTransaction |
The checkTransaction method allows the caller of this flow to provide some additional checks over the proposed transaction received from the counterparty. For example: abstract fun checkTransaction(stx: SignedTransaction): Unit |
tracker |
fun tracker(): ProgressTracker |
receiveAll |
Suspends until a message has been received for each session in the specified sessions. fun FlowLogic<*>.receiveAll(session: Pair<FlowSession, Class<out Any>>, vararg sessions: Pair<FlowSession, Class<out Any>>): Map<FlowSession, UntrustworthyData<Any>> fun <R : Any> FlowLogic<*>.receiveAll(receiveType: Class<R>, session: FlowSession, vararg sessions: FlowSession): List<UntrustworthyData<R>> fun <R : Any> FlowLogic<*>.receiveAll(session: FlowSession, vararg sessions: FlowSession): List<UntrustworthyData<R>> |