corda / net.corda.core.flows / CollectSignaturesFlow

CollectSignaturesFlow

class CollectSignaturesFlow : FlowLogic<SignedTransaction>

The CollectSignaturesFlow is used to automate the collection of counterparty signatures for a given transaction.

You would typically use this flow after you have built a transaction with the TransactionBuilder and signed it with your key pair. If there are additional signatures to collect then they can be collected using this flow. Signatures are collected based upon the WireTransaction.requiredSigningKeys property which contains the union of all the PublicKeys listed in the transaction's commands as well as a notary's public key, if required. This flow returns a SignedTransaction which can then be passed to the FinalityFlow for notarisation. The other side of this flow is the SignTransactionFlow.

WARNING: This flow ONLY works with ServiceHub.legalIdentityKeys and WILL break if used with randomly generated keys by the ServiceHub.keyManagementService.

Usage:

  1. The provided transaction is invalid
  2. Any of the required signing parties cannot be found in the ServiceHub.networkMapCache of the initiator
  3. If the wrong key has been used by a counterparty to sign the transaction
  4. The counterparty rejects the provided transaction

Example - issuing a multi-lateral agreement which requires N signatures:

    val builder = TransactionBuilder(notaryRef)
    val issueCommand = Command(Agreement.Commands.Issue(), state.participants)

    builder.withItems(state, issueCommand)
    builder.toWireTransaction().toLedgerTransaction(serviceHub).verify()

    // Transaction creator signs transaction.
    val ptx = serviceHub.signInitialTransaction(builder)

    // Call to CollectSignaturesFlow.
    // The returned signed transaction will have all signatures appended apart from the notary's.
    val stx = subFlow(CollectSignaturesFlow(ptx))

Parameters

partiallySignedTx - Transaction to collect the remaining signatures for

sessionsToCollectFrom - A session for every party we need to collect a signature from. Must be an exact match.

myOptionalKeys - set of keys in the transaction which are owned by this node. This includes keys used on commands, not just in the states. If null, the default well known identity of the node is used.

Types

COLLECTING

object COLLECTING : Step

VERIFYING

object VERIFYING : Step

Constructors

<init>

CollectSignaturesFlow(partiallySignedTx: SignedTransaction, sessionsToCollectFrom: Collection<FlowSession>, progressTracker: ProgressTracker = CollectSignaturesFlow.tracker())

The CollectSignaturesFlow is used to automate the collection of counterparty signatures for a given transaction.

CollectSignaturesFlow(partiallySignedTx: SignedTransaction, sessionsToCollectFrom: Collection<FlowSession>, myOptionalKeys: Iterable<PublicKey>?, progressTracker: ProgressTracker = CollectSignaturesFlow.tracker())

Properties

myOptionalKeys

set of keys in the transaction which are owned by this node. This includes keys used on commands, not just in the states. If null, the default well known identity of the node is used.

val myOptionalKeys: Iterable<PublicKey>?

partiallySignedTx

Transaction to collect the remaining signatures for

val partiallySignedTx: SignedTransaction

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.

val progressTracker: ProgressTracker

sessionsToCollectFrom

A session for every party we need to collect a signature from. Must be an exact match.

val sessionsToCollectFrom: Collection<FlowSession>

Functions

call

This is where you fill out your business logic.

fun call(): SignedTransaction

Companion Object Functions

tracker

fun tracker(): ProgressTracker

Extension Functions

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