Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Preventing invalid spending of broadcasted states - ReplyToMessageResponder
@InitiatedBy(ReplyToMessageFlow::class)
class ReplyToMessageResponder(private val session: FlowSession) : FlowLogic<SignedTransaction>() {
@Suspendable
override fun call(): SignedTransaction {
val stx = subFlow(object : SignTransactionFlow(session) {
override fun checkTransaction(stx: SignedTransaction) {
val message = stx.coreTransaction.outputsOfType<MessageState>().single()
require(message.sender != ourIdentity) {
"The sender of the new message cannot have my identity when I am not the creator of the transaction"
}
require(message.sender == session.counterparty) {
"The sender of the reply must must be the party creating this transaction"
}
}
})
return subFlow(
ReceiveFinalityFlow(
otherSideSession = session,
expectedTxId = stx.id
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.