2

I am reading the transaction part. I don't know how to get the transaction hash. Does the whole transaction (include its vins and vouts) get hashed?

If a transaction has two vouts (spent by different transaction tx2 and t3), when t2 and t3 spent the vout, they will get the same prevout hash. Is that correct?

For example:

tx1:  tx1_out1  --------> node_A ----tx2(using tx1_out1)---> 
      tx1_out2  --------> node_B ----tx3(using tx1_out2)--->  

Will tx2 and tx3 have conflicts, since tx1_out1 and tx1_out2 are spending the same hash?

5

Short answer

Your questions, in order: Yes. Yes. No.

Long answer

When spending the output of a transaction, it is not enough to know the txid. You also need to know the index of the output. (In other words, whether it is the first, second, third, etc. output.)

The hash of the transaction you're spending and the index of the output you're spending is collectively known as an outpoint.

Quoting the Bitcoin wiki:

The OutPoint structure consists of the following fields:

  • Field Size: 32
    Description: hash
    Data Type: char[32]
    The hash of the referenced transaction.
  • Field Size: 4 bytes
    Description: index
    Data Type: uint32_t
    The index of the specific output in the transaction. The first output is 0, etc.

See also the bitcoin.org docs.

  • Thank you very much, Nick. Also thank you for correcting my English. I consume a node first got tx2 and then got tx3. When the node check tx3 is valid or not, it found it already had a trasanction tx2, which already used tx1.hash. would it continue to check the index of output ? If it found also t3 and t2 use the same index of output. It mark the tx3 as invalid? Am I correct? – Eleven Nov 27 '14 at 4:33
  • @Eleven Yes. Two transactions that spend the same outpoint cannot both be valid. The first one is valid, and the second is invalid. (However, if the second one got into the blockchain, it would be valid and the first would be invalid. This could happen if another node saw the second one before the first one.) – Nick ODell Nov 27 '14 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.