1
what is the criteria for a txout script to be accepted into a mined block? is there any criteria at all? the reason i ask is that OP_RETURN is regularly used in txout scripts yet it is not spendable:
case OP_RETURN:
{
return set_error(serror, SCRIPT_ERR_OP_RETURN);
}
and i have also seen transactions which push elements to the stack which are more than MAX_SCRIPT_ELEMENT_SIZE bytes.
i'm guessing that a syntactically incorrect script such as:
05aa
(ie OP_PUSHDATA(5) <aa>)
would not be permitted?
could someone point me to the code which miners use to validate whether a tx will be included or discarded as invalid (due to its txout scripts). i'm guessing it lies in main.cpp, but i would like to know where exactly, thanks.
obviously anybody can mine a block that is set up any way they like, but presumably there are fixed rules for whether it is considered valid or not - so other miners will know whether to use its hash as their prev-header-hash when mining the next block?
You'll find a lot of scripts like this on testnet3, and a smaller number on the main network. Many of them are attempting (and actually manage in some cases) to break reimplementations using obscure and undocumented behaviors. – Anonymous – 2015-06-18T06:52:19.880
yep! it broke my re-implementation - that's the reason i'm asking :) but i don't see a whole lot of value for validating testnet blocks - people can put anything in there and there is not much hashpower to even guarantee valid blocks.
– mulllhausen – 2015-06-18T08:22:37.6871You're never going to download a block with invalid contents, because the block would just simply be invalid. The amount of proof of work for this is almost entirely orthogonal. You really shouldn't be reimplementing script, history has shown (bitcoinjs, bitcoin-ruby, btcd) that nobody has the capability to clone the behavior directly, no matter how many millions of dollars are poured into the effort. Unless this is for fun or experience, link to
libconsensusand avoid losing piles of money. It's not foolproof, but it means you won't have avoidable mistakes in script execution. – Anonymous – 2015-06-18T08:43:31.730thanks for the warning but for me its purely educational. you never really know something until you can build it yourself from scratch. – mulllhausen – 2015-06-18T12:09:09.330
i didn't know about
libconsensus- that looks really useful! – mulllhausen – 2015-06-18T12:21:40.363For a learning experience go right ahead reimplementing. Somewhat unexpectedly, that's how some consensus bugs have been found in the past. The warning was mostly born of people reimplementing and then running million dollar companies on top of it without really acknowledging the risk. – Anonymous – 2015-06-18T18:23:25.180
cool. yeah that's another reason for my re-implementation. so far i have always been late to the party - discovering "bugs" well after they have been fixed by bips
– mulllhausen – 2015-06-20T01:44:53.580