summaryrefslogtreecommitdiff
path: root/src/textual.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2023-11-24 23:33:59 -0800
committerJohn Wiegley <johnw@newartisans.com>2024-08-05 08:35:56 -0700
commit67de3bce35de8158cd25750901a322cc02071c95 (patch)
tree984346a9cdd73dcd7c9dbc9175143e1f759a8263 /src/textual.cc
parent6e9fda06df1754f58c347e44a4579d059dfd36f0 (diff)
downloadfork-ledger-67de3bce35de8158cd25750901a322cc02071c95.tar.gz
fork-ledger-67de3bce35de8158cd25750901a322cc02071c95.tar.bz2
fork-ledger-67de3bce35de8158cd25750901a322cc02071c95.zip
Make xact hashes independent of posting order
Also, support matching provided hashes against a prefixed of the generated hash.
Diffstat (limited to 'src/textual.cc')
-rw-r--r--src/textual.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/textual.cc b/src/textual.cc
index 9ad62602..af208232 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -2027,10 +2027,12 @@ xact_t * instance_t::parse_xact(char * line,
previous_xact->get_tag("Hash")->to_string() : "");
if (xact->has_tag("Hash")) {
string current_hash = xact->get_tag("Hash")->to_string();
- if (expected_hash != current_hash) {
+ if (! std::equal(expected_hash.begin(),
+ expected_hash.begin() +
+ std::min(expected_hash.size(), current_hash.size()),
+ current_hash.begin()))
throw_(parse_error, _f("Expected hash %1% != %2%") %
expected_hash % current_hash);
- }
} else {
xact->set_tag("Hash", string_value(expected_hash));
}