Reputation: 23140
Suppose I have the following flow pair:
Initiator
, who creates a transactionResponder
, who either accepts or refuses to sign the transactionIf the node running the Responder
flow refuses to sign, how can he pass the reason for his refusal back to the node running the Initiator
flow?
Upvotes: 1
Views: 226
Reputation: 23140
The node running the Responder
flow needs to throw a FlowException
. A FlowException
is a special exception type that should be thrown in flows when you want the exception's message to be visible to the counterparty.
So in Responder
, you might write:
val signTransactionFlow = object : SignTransactionFlow(otherPartyFlow) {
override fun checkTransaction(stx: SignedTransaction) {
val counterparty = otherPartyFlow.counterparty
throw FlowException("I refuse to trade with $counterparty")
}
}
return subFlow(signTransactionFlow)
And in the Initiator
, you could choose to handle the exception:
try {
val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, setOf(otherPartyFlow), GATHERING_SIGS.childProgressTracker()))
} catch (e: FlowException) {
logger.error(e.message)
TODO("Handle error.")
}
Upvotes: 0