mirror of
https://github.com/corda/corda.git
synced 2025-04-07 19:34:41 +00:00
Enforce transaction validity rules
This commit is contained in:
parent
76ffd485ac
commit
f5776d6bd7
@ -27,8 +27,8 @@ abstract class BaseTransaction : NamedByHash {
|
||||
}
|
||||
|
||||
private fun checkNotarySetIfInputsPresent() {
|
||||
if (notary == null) {
|
||||
check(inputs.isEmpty()) { "The notary must be specified explicitly for any transaction that has inputs" }
|
||||
if (inputs.isNotEmpty()) {
|
||||
check(notary != null) { "The notary must be specified explicitly for any transaction that has inputs" }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,9 @@ data class WireTransaction(
|
||||
) : CoreTransaction(), TraversableTransaction {
|
||||
init {
|
||||
checkBaseInvariants()
|
||||
check(inputs.isNotEmpty() || outputs.isNotEmpty()) { "A transaction must contain at least one input or output state" }
|
||||
check(commands.isNotEmpty()) { "A transaction must contain at least one command" }
|
||||
if (timeWindow != null) check(notary != null) { "Transactions with time-windows must be notarised" }
|
||||
check(availableComponents.isNotEmpty()) { "A WireTransaction cannot be empty" }
|
||||
}
|
||||
|
||||
/** The transaction id is represented by the root hash of Merkle tree over the transaction components. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user