cryptocoinjs/btc-transaction — pull request #3 by sidazhang (2014-01-24 09:18:10+00:00)
Title: Decode raw transaction into transaction object

This is my script to decode a raw transaction from buffer.

This as it stands is not complete, I plan to add more tests.

@MidnightLightning, Do you feel like that this decode function should be in this module? I think it would make sense for the transaction module to not only be able to serialize but also be able to decode

My goal:

1. Be able to decode transaction
2. Be able to verify signatures
3. Be able to verify transaction to be valid (https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages) - this obviously involves storage. so I plan to have anything that involve the blockchain to be arguments. For example scriptPubkey of a referenced output should be supplied to this module in order to validate the transaction.

The final DSL should be something like this
```
var tx = Transaction.decode(rawBuf)
// referencedOutputs - should contain the outputs and also whether they have been spent
tx.validate(referencedOutputs)
// => boolean
```