Implement constraints

A constraint is a precondition attached to a transaction.
All constraints must be fulfilled when the transaction is submitted.
Possible constraints are e.g. "a certain document exists"
or "a certain document is not changed during the transaction".

This is part of issue #4.

This commit also includes a major API change.