Stefano.Maffullo
Stefano.Maffullo

Reputation: 841

How to collect signatures from multiple state participants in a corda flow?

I'm working on a use case where there are three party involved, let's say PartyA, PartyB and PartyC.

In this scenario,

  1. PartyA issue a dealState (A is the only participant),

  2. PartyA sells it to PartyB (A,B are the participants),

  3. now PartyB wants to sell this state to PartyC but we need the signatures from both A and B, plus the one from C accepting the selling process.

How can I gather the signature from the original issuer PartyA in the third scenario in order to make the flow work?

The code in the flow is this one (Im selling as PartyB)

val newOwnerFlow = initiateFlow(PartyC)

progressTracker.currentStep = GATHERING_SIGS

println("Finished gathering signatures stage 9")

// Send the state to the counterparty, and receive it back with their signature.
val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, setOf(newOwnerFlow), GATHERING_SIGS.childProgressTracker()))

// Stage 10.
progressTracker.currentStep = FINALISING_TRANSACTION

println("Finalizing transaction")

// Notarise and record the transaction in both parties' vaults.

return subFlow(FinalityFlow(fullySignedTx, FINALISING_TRANSACTION.childProgressTracker()))

How do I make PartyA signing the transaction?

Upvotes: 1

Views: 623

Answers (1)

Stefano.Maffullo
Stefano.Maffullo

Reputation: 841

After some experimenting I found out the problem is the following:

you have to create a setOf(flowSessions) mapping each participant to its correspondent initiateFlow() that has to be passed to the CollectSignaturesFlow(), the syntax is like the following:

 val participantsParties = dealState.participants.map { serviceHub.identityService.wellKnownPartyFromAnonymous(it)!! }

 val flowSessions = (participantsParties - myIdentity).map { initiateFlow(it) }.toSet()

 progressTracker.currentStep = GATHERING_SIGS

 println("Finished gathering signatures stage 9")

 // Send the state to the counterparty, and receive it back with their signature.

 val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, flowSessions, GATHERING_SIGS.childProgressTracker()))

Upvotes: 1

Related Questions