memoriesadrift / tuw-cryptocurrencies-blockchain

Blockchain created for the Cryptocurrencies course at TU Wien
0 stars 0 forks source link

T2: Transaction Validation #16

Closed memoriesadrift closed 11 months ago

memoriesadrift commented 11 months ago

Scope:

  1. Create the logic to represent a transaction. The protocol description defines the struc- ture of a transaction.
  2. Create the logic for transaction validation as specified by the protocol description. Trans- action validation contains the following steps: a) For each input, validate the outpoint. For this, ensure that a valid transaction with the given txid exists in your object database and that it has an output with the given index. b) For each input, verify the signature. c) Outputs contain a public key and a value. The public keys must be in the correct format and the values must be a non-negative integer. d) Transactions must satisfy the weak law of conservation: The sum of input values must be equal or exceed the sum of output values. For now, assume that a (syntactically valid) coinbase transaction is always valid. I.e., you do not have to check how many new coins have been created or what the height is set to. We will validate these starting in the next homework.
  3. When you receive a transaction object, validate it. If the transaction is valid, store it in your object database and gossip it using an ihaveobject message. If it is invalid, send an error message to the node who sent the transaction and do not gossip it. In case the other node sent you an invalid transaction, you should consider the other node faulty. If you could not verify a transaction because it references an object not known to you, this does not indicate a faulty communication partner and you should not close the connection, just send an UNKNOWN_OBJECT error message (for now). You should test your transaction validation by generating different valid and invalid transac- tions, signed using a private key of your choice.
memoriesadrift commented 11 months ago

Note: how does this check work? "TX_INVALID_OUTPOINT: A transaction in a block spends from the coinbase transaction in the same block." "TX_INVALID_OUTPOINT: A transaction in a block double spends or references a transaction output that is not in the current chain."

We probably can't check these for this task as we don't handle blocks.