I've cleaned up and added some unit tests. The preliminary PR is here:
The main issue right now is that it only works for transfers with two equal and opposite augment/reduce postings (and worse, does not gracefully detect and reject more complex forms, such as a transfer from one account into two others, or from two others into one). The case of split-transferring from one account into two others (e.g., account1: -100 HOOL, account2: 50 HOOL, account3: 50 HOOL) is especially problematic as there's no way to know which cost units should go to account2 and which to account3.
Preliminary feedback from anyone would be very much appreciated, specifically:
- this question of how to handle and/or reject more-complex-transfers
- cases to add more tests for
- anything about the code itself