Add check in transaction builder

This commit is contained in:
Dimos Raptis 2019-10-28 16:01:30 +00:00
parent e8c20fc338
commit ca3128f44c

View File

@ -285,7 +285,9 @@ open class TransactionBuilder(
// For each contract, resolve the AutomaticPlaceholderConstraint, and select the attachment.
val contractAttachmentsAndResolvedOutputStates: List<Pair<AttachmentId, List<TransactionState<ContractState>>?>> = 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<TransactionState<ContractState>> = contractAttachmentsAndResolvedOutputStates.mapNotNull { it.second }
@ -433,6 +435,15 @@ open class TransactionBuilder(
return Pair(selectedAttachmentId, resolvedOutputStates)
}
private fun checkForUnsupportedConstraints(transactionState: TransactionState<ContractState>, 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