Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Preventing invalid spending of broadcasted states - General contract validation
override fun verify(tx: LedgerTransaction) {
val commandWithParties: CommandWithParties<Commands> = tx.commands.requireSingleCommand()
when (commandWithParties.value) {
is Commands.Send -> // validation for sending
is Commands.Reply -> requireThat {
val inputPublicKeys = tx.inputs.flatMap { it.state.data.participants.map(AbstractParty::owningKey) }.toSet()
"The input participant keys are a subset of the signing keys" using commandWithParties.signers.containsAll(inputPublicKeys)
val outputPublicKeys = tx.outputStates.flatMap { it.participants.map(AbstractParty::owningKey) }.toSet()
"The output participant keys are a subset of the signing keys" using commandWithParties.signers.containsAll(outputPublicKeys)
}
}
}
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.