diff --git a/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt b/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt index 773741dd53..53bee551b7 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt @@ -129,19 +129,26 @@ data class LedgerTransaction @JvmOverloads constructor( * If any contract fails to verify, the whole transaction is considered to be invalid. */ private fun verifyContracts() { + val contractInstances = ArrayList(contracts.size) for ((key, result) in contracts) { when (result) { is Try.Failure -> throw TransactionVerificationException.ContractCreationError(id, key, result.exception) is Try.Success -> { try { - val contract = result.value.newInstance() - contract.verify(this) + contractInstances.add(result.value.newInstance()) } catch (e: Throwable) { - throw TransactionVerificationException.ContractRejection(id, result.value.name, e) + throw TransactionVerificationException.ContractCreationError(id, result.value.name, e) } } } } + contractInstances.forEach { contract -> + try { + contract.verify(this) + } catch (e: Throwable) { + throw TransactionVerificationException.ContractRejection(id, contract, e) + } + } } /**