<p>TxID is just a SHA256 hash of binary transation data, so it changes upon any modification of transaction.
Therefore, one cannot include verification of TxID in the script in same transaction (if I correctly understood what you want to achieve).</p>

CC BY-SA 3.0
2012-12-20T23:08:18.113Z
Maybe I'm confused... Where is the TxID?
makerofthings7
CC BY-SA 3.0
2012-12-20T23:20:07.543Z
The transaction id is used to refer to a transaction; it is not part of it.
Pieter Wuille
CC BY-SA 3.0
2012-12-21T06:17:47.523Z
@PieterWuille Is the TxID a simple Sha256 hash of the tx data in it's entirety?  Does that mean the TxID changes if the sequence # changes?  How should I track revisions (new sequences) of the same tx?
makerofthings7
CC BY-SA 3.0
2012-12-21T08:13:01.847Z
@makerofthings7 Yes, it is just hash of all data. If tx data changes then it is NOT the same tx.
aland
CC BY-SA 3.0
2012-12-21T10:39:35.917Z
It is a double-SHA256 of the serialized transaction. So indeed, the sequence number is part of. Changing the sequence number means you get a new transaction, but there is some (currently disabled) code in the reference client which can detect one transaction as a 'new version' of another, and replace it.
Pieter Wuille
CC BY-SA 3.0
2015-04-29T16:09:48.000Z
@PieterWuille does generating txid mean you hash the scriptSif & scriptPubKey as well ?
Haddar Macdasi
CC BY-SA 3.0
2015-04-30T05:58:58.143Z
Yes, any change at all, including any non-sensical or irrelevant change, will change the transaction id.
Pieter Wuille
CC BY-SA 3.0
2012-12-20T22:54:18.443Z
2012-12-20T22:54:18.443Z
aland
<p>I'm creating a non-mainstream client that processes and validates Bitcoin transactions and need to track transactions in my database.</p>

<ul>
<li>How is the TxID generated and when does it change?  </li>
</ul>

<p>Specifically, since sequence is intended to update a transaction, and if the transactions hash were to change I would assume the txid hash would change s well.</p>

<p><a href="https://en.bitcoin.it/w/images/en/e/e1/TxBinaryMap.png">When I look at this image of a Tx,</a> it appears that the txid is marked as TxIn (VI) </p>

<ul>
<li>Is it possible or useful for a script to verify the TxID and signature hash?</li>
</ul>

<transactions><script><multi-signature>
How is a Transaction ID generated & when does it change? (with a new sequence ID?)
makerofthings7
# How is a Transaction ID generated & when does it change? (with a new sequence ID?)

(Asked by: username_0 on 2012-12-20)

I'm creating a non-mainstream client that processes and validates Bitcoin transactions and need to track transactions in my database.

* How is the TxID generated and when does it change?

Specifically, since sequence is intended to update a transaction, and if the transactions hash were to change I would assume the txid hash would change s well.

[When I look at this image of a Tx,](https://en.bitcoin.it/w/images/en/e/e1/TxBinaryMap.png) it appears that the txid is marked as TxIn (VI)

* Is it possible or useful for a script to verify the TxID and signature hash?

**Tags:** transactions, script, multi-signature


---

## 1 answers

### Answer by username_1 on 2012-12-20. Score: 7 | Accepted answer

TxID is just a SHA256 hash of binary transation data, so it changes upon any modification of transaction.
Therefore, one cannot include verification of TxID in the script in same transaction (if I correctly understood what you want to achieve).

> **Comments:**
> **username_0**: Maybe I'm confused... Where is the TxID?  
> **username_2**: The transaction id is used to refer to a transaction; it is not part of it.  
> **username_0**: @PieterWuille Is the TxID a simple Sha256 hash of the tx data in it's entirety?  Does that mean the TxID changes if the sequence # changes?  How should I track revisions (new sequences) of the same tx?  
> **username_1**: @username_0 Yes, it is just hash of all data. If tx data changes then it is NOT the same tx.  
> **username_2**: It is a double-SHA256 of the serialized transaction. So indeed, the sequence number is part of. Changing the sequence number means you get a new transaction, but there is some (currently disabled) code in the reference client which can detect one transaction as a 'new version' of another, and replace it.  
> **username_3**: @PieterWuille does generating txid mean you hash the scriptSif & scriptPubKey as well ?  
> **username_2**: Yes, any change at all, including any non-sensical or irrelevant change, will change the transaction id.  

---

