commit 8d67c75f187669a4f3e87a03b5738fcdad8c50bb parent 649252027133e93298cff57e648442a0f2d27cc9 Author: lash <dev@holbrook.no> Date: Mon, 5 Jan 2026 16:11:50 +0100 Ensure entry parent is same as current state of ledger Diffstat:
| M | dummy/usawa/ledger.py | | | 6 | +++++- |
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dummy/usawa/ledger.py b/dummy/usawa/ledger.py @@ -346,11 +346,15 @@ class Ledger: :type entry: usawa.Entry :param modify_tree: If True, also append the entry to the XML export. :type modify_tree: boolean + :raises ValueError: When entry parent does not match ledger state. + :raises PermissionError: When entry is missing valid signature. :todo: modify_tree is too low-level for this API """ def add_entry(self, entry, modify_tree=True): + if self.cur != entry.parent: + raise ValueError('entry parent does not match ledger state') if not self.check_sigs(entry): - raise ValueError('entry must have at least one valid signature') + raise PermissionError('entry must have at least one valid signature') try: entries = self.entries[entry.serial] except KeyError: