From ca3128f44c195e68a108c3bf870c59efe471cc64 Mon Sep 17 00:00:00 2001 From: Dimos Raptis Date: Mon, 28 Oct 2019 16:01:30 +0000 Subject: [PATCH] Add check in transaction builder --- .../corda/core/transactions/TransactionBuilder.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt b/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt index c31011e51f..93fd289bca 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt @@ -285,7 +285,9 @@ open class TransactionBuilder( // For each contract, resolve the AutomaticPlaceholderConstraint, and select the attachment. val contractAttachmentsAndResolvedOutputStates: List>?>> = allContracts.toSet() .map { ctr -> - handleContract(ctr, inputContractGroups[ctr], outputContractGroups[ctr], explicitAttachmentContractsMap[ctr], services) + handleContract(ctr, inputContractGroups[ctr], outputContractGroups[ctr], explicitAttachmentContractsMap[ctr], services).also { + it.second?.forEach { state -> checkForUnsupportedConstraints(state, services) } + } } val resolvedStates: List> = contractAttachmentsAndResolvedOutputStates.mapNotNull { it.second } @@ -433,6 +435,15 @@ open class TransactionBuilder( return Pair(selectedAttachmentId, resolvedOutputStates) } + private fun checkForUnsupportedConstraints(transactionState: TransactionState, services: ServicesForResolution) { + if (transactionState.constraint is SignatureAttachmentConstraint) { + val constraintKey = transactionState.constraint.key + if (constraintKey is CompositeKey && constraintKey.leafKeys.size > 1) + checkMinimumPlatformVersion(services.networkParameters.minimumPlatformVersion, 5, + "Composite keys for signature constraints") + } + } + /** * Checks whether the current transaction can migrate from a [HashAttachmentConstraint] to a * [SignatureAttachmentConstraint]. This is only possible in very specific scenarios. Most