diff options
author | John Wiegley <johnw@newartisans.com> | 2023-12-13 12:58:35 -0800 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2024-08-05 08:35:56 -0700 |
commit | 621eb11e5cedfa93ae027aafd0b3e14fcf1cd3ee (patch) | |
tree | a0323c5eebb9d9a3de94cfd84a28186467225fea /src | |
parent | cab357a160cf4fdf4eb7c17c35c703e1e1f0ab10 (diff) | |
download | fork-ledger-621eb11e5cedfa93ae027aafd0b3e14fcf1cd3ee.tar.gz fork-ledger-621eb11e5cedfa93ae027aafd0b3e14fcf1cd3ee.tar.bz2 fork-ledger-621eb11e5cedfa93ae027aafd0b3e14fcf1cd3ee.zip |
Add whitespace to xact_t::hash
Diffstat (limited to 'src')
-rw-r--r-- | src/xact.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/xact.cc b/src/xact.cc index ab53794a..e6a3991a 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -596,13 +596,16 @@ namespace { string xact_t::hash(string nonce, hash_type_t hash_type) const { std::ostringstream repr; + repr << nonce; repr << date(); repr << aux_date(); repr << code; repr << payee; + posts_list all_posts(posts.begin(), posts.end()); std::vector<std::string> strings; + foreach (post_t * post, all_posts) { std::ostringstream posting; posting << post->account->fullname(); @@ -614,13 +617,18 @@ string xact_t::hash(string nonce, hash_type_t hash_type) const { posting << post->checkout; strings.push_back(posting.str()); } + std::sort(strings.begin(), strings.end()); + foreach (string& str, strings) { repr << str; } + unsigned char data[128]; string repr_str(repr.str()); + SHA512((void *)repr_str.c_str(), repr_str.length(), data); + return bufferToHex( data, hash_type == HASH_SHA512 ? 64 : 32 /*SHA512_DIGEST_LENGTH*/); } |