xuechenwang
xuechenwang

Reputation: 35

Can 3rd party check the state that he does not know, and add this state in a flow as a input state?

Here is my deliverydemo source code on github.

My scenario:

  1. A issues tokens to B
  2. B makes an order with C
  3. C delivers the goods to B, and try to start a flow for retrieving token from B.

My question:


As Joel's suggestion, I try to send some request and receive the StateAndRef from PartyB on PartyC in my OrderDeliveredFlow.

Unfortunately, seems like JAVA does not support "unwrap", but Kotlin does. After I add a small segment for send and receive Java.String and unwarp it in a workable flow - my token issue flow, this flow going to rise this error - "missing parameter name at index 0 {}".

An possible solution that I think, is create a new flow in Kotlin just like "CollectSignaturesFlow". Otherwise, I have to translate my Java code into Kotlin.

Upvotes: 0

Views: 73

Answers (2)

Cais Manai
Cais Manai

Reputation: 966

As an alternative to Joel's answer. You could look into adding C as a participant of the token state.

e.g. in Kotlin, where other would be set as C

override val participants: List<AbstractParty> get() = listOf(issuer, owner, other)

C would then know about the state of the token that B has. However, you can see that this would require the issuer or B to know about C beforehand.

Naturally, the route you take all depends on your privacy model.

Upvotes: 0

Joel
Joel

Reputation: 23210

C isn't aware of the existence of the token states, so can't add them to the transaction herself.

Instead, C should ask B to send over the token states she wants to spend, and add them to a transaction.

The flow code would look something like:

val otherPartySession = initiateFlow(otherParty)
val tokenState = otherPartySession.receive<StateAndRef<Cash.State>>().unwrap { it }
txBuilder.addInputState(tokenState)

Upvotes: 0

Related Questions