-1

Hi all I was wondering if I am doin a wrong assumption here: Let's assume a dezentralized peer to peer network and the bitcoin protocol. If a full node changes a transaction within a block and then start looking for a suited nonce to fulfill the requirements and than win the competition: All other nodes would verify the block, due to the correct hash requirements. This would result in the fact that nodes can change transactions within a block after receiving them and than start their proof of work. All the other nodes would accept that block if the node is the fastest. Is this correct?

To conclude the question more precisely: after the fastest node has found a nonce for its false transaction block, will the other nodes verify only the hash value (which fulfills the requirements) or do they also verify the transactions in the block again?

3 Answers 3

3

Bitcoin funds are locked to a specific private key. In order to spend them in a transaction, the transaction needs to be signed with the private keys corresponding to each input. The signature commits to the exact content of the transaction. If another user changes the transaction, the signature is no longer valid. Other users cannot produce another signature as they're not privy to the private key.

Therefore your scenario fails in one of two ways: One, the attacker creates a fake transaction with an invalid signature. Every other node that verifies the block's content notices the invalid signature and rejects the block. Two, the attacker attempts to create a valid transaction with a different outcome than the original. He cannot, because he doesn't have the correct private key to produce the signature.

Remember that every node checks all details of each transaction and each block independently. Editing your node's database locally or changing the code that your node is running does not impact the behavior of other nodes.

8
  • Thank you for the more detailed explanation. What about an attacker is changing a transaction of his own, where he has the appropriate private keys of the inputs?
    – frosk
    Commented Apr 27, 2020 at 5:54
  • That is called a doublespend. If the original is already confirmed, it'll be invalid for trying to spend non-existent funds. If it's not confirmed, only one, the original or the doublespend can be included in a block.
    – Murch
    Commented Apr 27, 2020 at 6:21
  • 1
    Every node validates all information for themselves. If you change your code or database locally that doesn't change what everyone else is doing. Nodes validating transactions check whether the unspent transaction outputs (UTXO) consumed by the inputs are available and then mark those UTXO as spent. A second transaction using the same funds fails because the UTXO are unavailable for spending, they are already spent.
    – Murch
    Commented Apr 27, 2020 at 14:32
  • 1
    @frosk Yes, as you've now been told 3 times: every node checks every transaction in every block fully. The other nodes treat the incoming block as a new block they have not seen, so they fully verify it. There is nothing special about miners receiving blocks created by other miners: miners are nodes, and every node checks every block fully. Miners could choose to not do this by modifying their software, but it would be silly: they'd just risk building on top of an invalid block and see their energy spent on mining go to waste. Commented Apr 28, 2020 at 21:36
  • 1
    Note that different miners working simultaneously do not actually work on the same block. Each may have a (slightly) different set of transactions (as propagation of transactions is not perfect), and their coinbase transaction (the one that pays themselves the subsidy/fees) is of course different. Each has their own candidate block, but they have full discretion over what goes into it. Once they solve their candidate's PoW, they broadcast it, and hopefully for them, the network's nodes (including other miners' nodes) accept it after validating it. Commented Apr 28, 2020 at 21:42
2

after the fastest node has found a nonce for its false transaction block, will the other nodes verify only the hash value (which fulfills the requirements) or do they also verify the transactions in the block again?

Every full node fully verifies every transaction in every block independently. This is even true for non-mining nodes. If a block contains an invalid signature, it will be ignored by the entire network.

Miners do this too (including blocks produced by other miners), but not only because the protocol prescribes it. Miners serve the network, and if they mine blocks the network does not like, their efforts are wasted. Thus they are incentized to validate everything, and not risk building (or building on top of) invalid blocks.

7
  • Thanks pieter, it seems to me now you are facing my question. So can you tell me maybe a little more about the verification process in the cycle of a new block generation. So if the transaction arrives on every note it gets verified and kept in memory. After enough transactions have been collected they get promoted to the next block. Now every node is competing in finding the nonce. Here now a malicious node could change a transaction and try to find the nonce for this block containing an invalid transaction.
    – frosk
    Commented Apr 26, 2020 at 16:01
  • Will the new block again be verified according to its transactions or only according to its generated hash value before committing it
    – frosk
    Commented Apr 26, 2020 at 16:01
  • Please read my comment again and could you tell me when in the creation process the block gets verified?
    – frosk
    Commented Apr 26, 2020 at 16:40
  • 3
    Every transaction in every block gets verified by every node. This has nothing to do with mining. Miners can build whatever blocks they like, but if they build a block with invalid transactions, their efforts are wasted. So they are incentivized to build valid blocks, and also build on top of valid blocks. Commented Apr 26, 2020 at 17:30
  • 2
    Every transaction gets fully validated by every node. Not just their hashes: all the transaction details, including digital signatures. That includes miners. If they didn't, they could be tricked into building on top of an invalid block, which would make their electricity that went into hashing wasted. Commented Apr 27, 2020 at 5:54
1

If a block is in any sense invalid, no honest node will ever accept it, period. So producing a block that is invalid is pointless, a waste of effort.

Now say a block is just produced right now. Someone could, if they got lucky, quickly produce another block with the same block number as that block that has different transactions in it. This can even happen without anyone being malicious.

At this point, the network wouldn't know which of those two blocks to treat as valid. This is why exchanges wait for several more blocks to be produced before crediting anyone for deposited bitcoins.

Pretty quickly, it will be clear which of those two blocks wins. Nobody wants to mine on an alternate chain because they will never get to keep any of the rewards or fees. So every honest miner quickly cooperates to pick one of those chains and lengthen it sufficiently to ensure that their mining rewards do stick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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