CollectSignaturesFlow.<init> - corda

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

# <init>

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

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:

- Call the CollectSignaturesFlow flow as a subFlow and pass it a SignedTransaction which has at least been signed by the transaction creator (and possibly an oracle, if required)
- The flow expects that the calling node has signed the provided transaction, if not the flow will fail
- The flow will also fail if:

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

- The flow will return a SignedTransaction with all the counterparty signatures (but not the notary's!)
- If the provided transaction has already been signed by all counterparties then this flow simply returns the provided transaction without contacting any counterparties
- Call the FinalityFlow with the return value of this flow

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.