I understand there are a couple things that need to be checked for a transaction to be valid - the previous transaction had to be correct, no OP can invalidate the transaction, etc, but is there a complete list on what one needs to check in order to know if a transaction is valid?

For example, does the transaction need to have a specific structure in order to be spent, like the script from TxIn needs to compile to the encoded message, and the TxOut script needs to properly run OP_Checksig on that particular message? If not, one could simply drop the message from TxIn, push their own malicious message and run OP_Checksig on that.

What steps does the protocol require a client to go through to check if the transaction is valid?

link|improve this question

72% accept rate
It's not clear what you're asking. By "valid" do you just mean that the client won't consider a block invalid if it contains that transaction? Or by "valid" do you mean the default client will include that transaction in blocks it generates? Or by "valid" you mean the default client will relay it to other nodes? Or something else? There are different checks on transactions to decide if they are "valid" for a number of different purposes. For example, consider a transaction that spends coins not yet available but that could become available. In some senses, that's valid. In some, not yet. – David Schwartz Jan 5 at 2:21
@DavidSchwartz I suppose all of the above would be useful, but mainly I was thinking about including the transactions in the block. – ThePiachu Jan 5 at 10:51
feedback

2 Answers

On the bitcoin wiki, there is rather complete list of validation checks that are done by the Satoshi client: Protocol_rules

link|improve this answer
feedback

I understand there are a couple things that need to be checked for a transaction to be valid - the previous transaction had to be correct, no OP can invalidate the transaction, etc, but is there a complete list on what one needs to check in order to know if a transaction is valid?

You check the chain, if it goes all the way back to a generation, it is valid. You must wait for a confirmation to get it set in stone.

What steps does the protocol require a client to go through to check if the transaction is valid?

https://github.com/bitcoin/bitcoin/tree/master/src

link|improve this answer
Well, quite more than "a [single] confirmation" to "set [it] in stone". – Lohoris Apr 5 at 11:08
Though you're technically correct in saying that you need to check the chain all the way back to generation, this is not useful. Clients only store the part of the chain they've verified to be valid, and the only thing they need to check is whether it correctly connects to the transactions therein. Also, transactions are never entirely set in stone, but each confirmation significantly reduces the chance for reverting further. – Pieter Wuille May 5 at 12:06
There has not been and there will likely not be a single Chain Fork attack. It is not worth it, it is unlikely, it has not happened. fThe only ever attack to the Bitcoin Client or Chain was an Integer Overflow back at the beginnings of time. – fabianhjr May 5 at 16:59
feedback

Your Answer

 
or
required, but never shown

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