corda / net.corda.core.flows / SignTransactionFlow / <init>

<init>

SignTransactionFlow(otherSideSession: FlowSession, progressTracker: ProgressTracker = SignTransactionFlow.tracker())

The SignTransactionFlow should be called in response to the CollectSignaturesFlow. It automates the signing of a transaction providing the transaction:

  1. Should actually be signed by the Party invoking this flow
  2. Is valid as per the contracts referenced in the transaction
  3. Has been, at least, signed by the counterparty which created it
  4. Conforms to custom checking provided in the checkTransaction method of the SignTransactionFlow

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))
         }
     }

Parameters

otherSideSession - The session which is providing you a transaction to sign.