cryptocoinjs / btc-transaction

Create, parse, serialize Bitcoin transactions.
11 stars 8 forks source link

TransactionIn is able to accept coinbase TranscationIns (no prev out) #7

Closed sidazhang closed 10 years ago

sidazhang commented 10 years ago

If the user does not pass in outpoint data (for example if you use the blockchain.info api)

There are apis that consider coinbase to have tx_hash of null. If a user uses those api to generate a TransactionIn, the user will run into the problems.

This pull request checks for the existence of prev_out, and if a txin does not reference a txout, it will assign coinbase tx hash and tx index to it (which is 32 zero bytes and index of -1 or 0xffffffff)