haskoin/haskoin — pull request #49 by xenog (2014-06-28 23:49:37+00:00)
Title: Simplified signatures

I believe transaction signature was too convoluted in the original code. Instead of trying to work iteratively to refactor that code, I decided to roll my own, replacing the way transaction signatures are made and validated. The main goal of this code is clarity: to be easier to read, and precision. I spent part of the week mapping out the behaviour of bitcoind's signing code in order to come up with this scheme.

Some highlights are:

- No separate code or types for P2SH transactions
- Removal of signature status type, it is enough to use a boolean value to convey transaction signature status
- Code common to monadic (SecretT) and deterministic signing code factored out
- Signing functions split according to function and layer of abstraction, with intuitive naming and documentation
- Interface of higher-level function remains mostly unchanged
- Signature validation to determine whether transaction is completely signed is performed at the highest layer
- Reduction and confinement of code that makes contextual deductions, in favor of explicit parameters

My branch in terms of lines of code is a tad longer than plaprade's similar modifications by a small number of lines, but this code has more documentation, and is written in a sparse style for readability.