Add minimum platform version check before attempting a hash -> signature constraints auto migration. (#4623)

This commit is contained in:
josecoll 2019-01-23 13:10:41 +00:00 committed by GitHub
parent 100a6fcb56
commit 82f5a756fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -280,10 +280,11 @@ open class TransactionBuilder(
): Pair<Set<AttachmentId>, List<TransactionState<ContractState>>?> {
val inputsAndOutputs = (inputStates ?: emptyList()) + (outputStates ?: emptyList())
// Hash to Signature constraints migration switchover
// Hash to Signature constraints migration switchover (only applicable from version 4 onwards)
// identify if any input-output pairs are transitioning from hash to signature constraints:
// 1. output states contain implicitly selected hash constraint (pre-existing from set of unconsumed states in a nodes vault) or explicitly set SignatureConstraint
// 2. node has signed jar for associated contract class and version
if (services.networkParameters.minimumPlatformVersion >= 4) {
val inputsHashConstraints = inputStates?.filter { it.constraint is HashAttachmentConstraint } ?: emptyList()
val outputHashConstraints = outputStates?.filter { it.constraint is HashAttachmentConstraint } ?: emptyList()
val outputSignatureConstraints = outputStates?.filter { it.constraint is SignatureAttachmentConstraint } ?: emptyList()
@ -308,6 +309,7 @@ open class TransactionBuilder(
return Pair(attachmentIds.toSet(), outputConstraints)
}
}
}
// Determine if there are any HashConstraints that pin the version of a contract. If there are, check if we trust them.
val hashAttachments = inputsAndOutputs