<p>Hashes don't actually 'change'. When you add a transaction to a block you are creating another block.</p>

<p>It's like an author published a book and then next year printed a new edition with an extra comma in the page 36 and the fans said he released a 'new' book. It doesn't make sense for books but for blockchain every bit counts.</p>

CC BY-SA 4.0
2019-09-23T22:59:07.303Z
2019-09-23T22:59:07.303Z
Osias Jota
<blockquote>
  <p>If I go back to block #1000 and add one more transaction, this will change the hash and it wont be the same one stored in #1001. However, how the hash of block #1000 changes in the first place if it was already calculated? </p>
</blockquote>

<p>Once a block has been mined and accepted as part of the longest valid chain (ie, several confirmations deep), it will not ever change (which means the block's contents, and thus hash, will not change). </p>

<p>In order to change it, you would have to also change every block that comes after it, all the way up until the current chain tip. This would take a huge amount of computational power to pull off, you would basically need to 51% attack the network, to re-write the blockchain history. This sort of attack is extremely expensive, and ignores the incentives for mining honestly, <a href="https://bitcoin.stackexchange.com/questions/tagged/majority-attack?tab=Votes">you can read more about it here</a>.</p>

<p>Otherwise, if you just changed block #1000, and then attempted to broadcast the changed block to your peers, they will all reject that block, since it is not part of the longest valid chain (assuming they have already heard about the original block #1000, and all of the blocks that came after it). </p>

<blockquote>
  <p>does this mean that the hash of each block is recalculated regularly?</p>
</blockquote>

<p>A block's hash will be calculated in order to determine its validity, but we would never expect the hash to change for a block that has a sufficient number of confirmations on the network. </p>

CC BY-SA 4.0
2019-09-24T01:35:04.573Z
2019-09-24T01:35:04.573Z
chytrik
<p>I think you are referring to consensus..if you try to go back and add something to a prior block and transmit it to the network the other nodes will reject it..</p>

CC BY-SA 4.0
2020-01-06T04:36:03.593Z
This doesn't answer the question
Raghav Sood
CC BY-SA 4.0
2020-01-06T04:55:47.640Z
Sure it does, if its rejected you know
Johnny Good
CC BY-SA 4.0
2020-01-06T04:25:50.207Z
2020-01-06T04:25:50.207Z
Johnny Good
<blockquote>
  <p>how does a block know that its transactions have tampered with in the
  first place?</p>
</blockquote>

<p>It is not the block that knows this; it is the nodes which verify that.
To quote <a href="https://bitcoin.org/bitcoin.pdf" rel="nofollow noreferrer">the bitcoin whitepaper</a>: </p>

<blockquote>
  <p>When a node finds a proof-of-work, it broadcasts the block to all
  nodes. Nodes accept the block only if all transactions in it are valid
  and not already spent.</p>
</blockquote>

<p>and </p>

<blockquote>
  <p>[...] network nodes can verify transactions for themselves</p>
</blockquote>

<p>So, the nodes verify the transactions upon receiving a new block. This adds to the blocks confirmation counter (you can see it in <a href="https://www.blockchain.com/btc/block/280963" rel="nofollow noreferrer">here, for example</a>), hence making it more trustworthy. </p>

<p>To answer your question directly, yes, the blocks get recalculated regularly. </p>

<p>This is not much of a problem for a node however, since it needs only one hash (the nonce is already known) to verify a block, which is vastly easier than calculating a proof-of-work. Same goes for verifying transactions. Exactly how many transactions are verified is something which I don't know myself, might be a topic for another question.</p>

<p>When a node "notices" that a block is invalid, it discards it and can even </p>

<blockquote>
  <p>[prompt] user's   software   to   download   the   full   block   and 
  alerted transactions to confirm the inconsistency. </p>
</blockquote>

<p>You might also find this thread quite informative: <a href="https://bitcoin.stackexchange.com/questions/88065/bitcoin-transactions-validation-process">Bitcoin transactions validation process</a></p>

CC BY-SA 4.0
2024-04-27T13:07:38.153Z
I know I'm late to this thread, but do you have any source on "yes, the blocks get recalculated regularly"? I haven't seen it mentioned on the thread you linked
A. Darwin
CC BY-SA 4.0
2020-01-05T22:59:40.537Z
2020-01-05T22:59:40.537Z
Jacob
<p>I know that the transactions stay in the block and hashed alongside few other things and that hash is stored in the next block. And I understand that if you try to tamper with one of the transactions, the hash will change and it will affect all the blocks that come after it.</p>

<p>However, how does a block know that its transactions have tampered with in the first place? </p>

<p>Assume that block #1000 has 10 transactions.
Now, the hash has been calculated and stored in block #1001</p>

<p>so, if I go back to block #1000 and add one more transaction, this will change the hash and it wont be the same one stored in #1001. 
However, how the hash of block #1000 changes in the first place if it was already calculated? does this mean that the hash of each block is recalculated regularly? </p>

CC BY-SA 4.0
2019-09-23T23:11:21.363Z
what makes you think you can "add" a transaction to a block? the miner chooses what goes in the block. a miner can mine with your transaction included or excluded, but if he includes it, he can get the fees. somebody might find another block at the same height, that doesn't include your transaction but has high enough difficulty. but the security assumption is that it's hash will be different.
Janus Troelsen
CC BY-SA 4.0
2024-08-22T15:34:07.773Z
Related: https://bitcoin.stackexchange.com/q/95564/5406
Murch
<blockchain><security><block>
How the blockchain knows that its been tampered with?
l Wawa
# How the blockchain knows that its been tampered with?

(Asked by: username_0 on 2019-09-23)

I know that the transactions stay in the block and hashed alongside few other things and that hash is stored in the next block. And I understand that if you try to tamper with one of the transactions, the hash will change and it will affect all the blocks that come after it.

However, how does a block know that its transactions have tampered with in the first place?

Assume that block #1000 has 10 transactions.
Now, the hash has been calculated and stored in block #1001

so, if I go back to block #1000 and add one more transaction, this will change the hash and it wont be the same one stored in #1001.
However, how the hash of block #1000 changes in the first place if it was already calculated? does this mean that the hash of each block is recalculated regularly?

**Tags:** blockchain, security, block

> **Comments:**
> **username_1**: what makes you think you can "add" a transaction to a block? the miner chooses what goes in the block. a miner can mine with your transaction included or excluded, but if he includes it, he can get the fees. somebody might find another block at the same height, that doesn't include your transaction but has high enough difficulty. but the security assumption is that it's hash will be different.  
> **username_2**: Related: https://bitcoin.stackexchange.com/q/95564/5406  

---

## 4 answers

### Answer by username_3 on 2019-09-23. Score: 1

Hashes don't actually 'change'. When you add a transaction to a block you are creating another block.

It's like an author published a book and then next year printed a new edition with an extra comma in the page 36 and the fans said he released a 'new' book. It doesn't make sense for books but for blockchain every bit counts.


---

### Answer by username_4 on 2019-09-24. Score: 1

> If I go back to block #1000 and add one more transaction, this will change the hash and it wont be the same one stored in #1001. However, how the hash of block #1000 changes in the first place if it was already calculated?

Once a block has been mined and accepted as part of the longest valid chain (ie, several confirmations deep), it will not ever change (which means the block's contents, and thus hash, will not change).

In order to change it, you would have to also change every block that comes after it, all the way up until the current chain tip. This would take a huge amount of computational power to pull off, you would basically need to 51% attack the network, to re-write the blockchain history. This sort of attack is extremely expensive, and ignores the incentives for mining honestly, [you can read more about it here](https://bitcoin.stackexchange.com/questions/tagged/majority-attack?tab=Votes).

Otherwise, if you just changed block #1000, and then attempted to broadcast the changed block to your peers, they will all reject that block, since it is not part of the longest valid chain (assuming they have already heard about the original block #1000, and all of the blocks that came after it).

> does this mean that the hash of each block is recalculated regularly?

A block's hash will be calculated in order to determine its validity, but we would never expect the hash to change for a block that has a sufficient number of confirmations on the network.


---

### Answer by username_5 on 2020-01-06. Score: 0

I think you are referring to consensus..if you try to go back and add something to a prior block and transmit it to the network the other nodes will reject it..

> **Comments:**
> **username_6**: This doesn't answer the question  
> **username_5**: Sure it does, if its rejected you know  

---

### Answer by username_7 on 2020-01-05. Score: -1

> how does a block know that its transactions have tampered with in the
> first place?

It is not the block that knows this; it is the nodes which verify that.
To quote [the bitcoin whitepaper](https://bitcoin.org/bitcoin.pdf):

> When a node finds a proof-of-work, it broadcasts the block to all
> nodes. Nodes accept the block only if all transactions in it are valid
> and not already spent.

and

> [...] network nodes can verify transactions for themselves

So, the nodes verify the transactions upon receiving a new block. This adds to the blocks confirmation counter (you can see it in [here, for example](https://www.blockchain.com/btc/block/280963)), hence making it more trustworthy.

To answer your question directly, yes, the blocks get recalculated regularly.

This is not much of a problem for a node however, since it needs only one hash (the nonce is already known) to verify a block, which is vastly easier than calculating a proof-of-work. Same goes for verifying transactions. Exactly how many transactions are verified is something which I don't know myself, might be a topic for another question.

When a node "notices" that a block is invalid, it discards it and can even

> [prompt] user's software to download the full block and
> alerted transactions to confirm the inconsistency.

You might also find this thread quite informative: [Bitcoin transactions validation process](https://bitcoin.stackexchange.com/questions/88065/bitcoin-transactions-validation-process)

> **Comments:**
> **username_8**: I know I'm late to this thread, but do you have any source on "yes, the blocks get recalculated regularly"? I haven't seen it mentioned on the thread you linked  

---

