bitcoinjs/bitcoinjs-lib — pull request #213 by dcousens (2014-06-15 07:37:52+00:00)
Title: ECSignature

Chained on #212.

This pull request moves all the `ecdsa` serialize/parse functions to `ECSignature`, a new class interface for importing/exporting `ECSignature`s.

The code is straight forward enough, with the test data broken away from `ecdsa` fixtures, but not altered.
`ECSignature.fromScriptSignature` was also added to import `DER` signatures with a hashType byte appended on the end. It is up for debate whether this is worthwhile for now. But it will be worthwhile if we instead pass around this object and only encode it when a script signature is made.
That is, instead of `createPubKeyScriptSig(DERsignatureBuffer)`, it is instead:
```
createPubKeyScriptSig = function(txSignatureInfo) {
var signature = txSignatureInfo.signature
var hashType = txSignatureInfo.hashType

return Script.fromChunks([signature.toScriptSignature(hashType)])
}
```

This saves serialization to `DER` until is necessary, meaning we can allow for easier verification of signatures as an intermediary step.

Comparison link: https://github.com/dcousens/bitcoinjs-lib/compare/txclean...ecsignature