diff options
author | John Wiegley <johnw@newartisans.com> | 2023-11-22 16:47:21 -0800 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2024-08-05 08:35:56 -0700 |
commit | db0661dbb51e9082e47926c31e93bdc97b491bf9 (patch) | |
tree | e60f7dc32ebe9c24cb26eeb8c8438de7e891fe6b /src/session.cc | |
parent | e6dae78c033ea970a459b1a0ccc2f1310d1bff96 (diff) | |
download | ledger-db0661dbb51e9082e47926c31e93bdc97b491bf9.tar.gz ledger-db0661dbb51e9082e47926c31e93bdc97b491bf9.tar.bz2 ledger-db0661dbb51e9082e47926c31e93bdc97b491bf9.zip |
Add support for hash chaining to detect modifications in postings
The following details of a posting contribute to its hash:
fullname of account
string representation of amount
Each posting hashes contributes to the transaction hash, which is compromised
of:
previous transaction’s hash (as encountered in parsing order)
actual date
optional auxiliary date
optional code
payee
hashes of all postings
Note that this means that changes in the “code” or any of the comments
Diffstat (limited to 'src/session.cc')
-rw-r--r-- | src/session.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/session.cc b/src/session.cc index 7cf1a666..6958603e 100644 --- a/src/session.cc +++ b/src/session.cc @@ -134,7 +134,7 @@ std::size_t session_t::read_data(const string& master_account) parsing_context.push(*price_db_path); parsing_context.get_current().journal = journal.get(); try { - if (journal->read(parsing_context) > 0) + if (journal->read(parsing_context, HANDLED(hashes)) > 0) throw_(parse_error, _("Transactions not allowed in price history file")); } catch (...) { @@ -169,7 +169,7 @@ std::size_t session_t::read_data(const string& master_account) parsing_context.get_current().journal = journal.get(); parsing_context.get_current().master = acct; try { - xact_count += journal->read(parsing_context); + xact_count += journal->read(parsing_context, HANDLED(hashes)); } catch (...) { parsing_context.pop(); @@ -230,7 +230,7 @@ journal_t * session_t::read_journal_from_string(const string& data) parsing_context.get_current().journal = journal.get(); parsing_context.get_current().master = journal->master; try { - journal->read(parsing_context); + journal->read(parsing_context, HANDLED(hashes)); } catch (...) { parsing_context.pop(); @@ -331,6 +331,9 @@ option_t<session_t> * session_t::lookup_option(const char * p) case 'f': OPT_(file_); // -f break; + case 'h': + OPT(hashes); + break; case 'i': OPT(input_date_format_); break; |