Detecting generation transactions

1

I'm implementing my own blockchain reader but I'm stuck validating transactions.

I can validate a common transaction checking the UTXO and executing both scripts, but... how do I validate generation transactions? AFAIK there's no flag that lets me detect generation so I can ignore the input.

kaoD

Posted 2014-01-11T06:42:01.740

Reputation: 958

possible duplicate of Eligius pool and 'generated' bitcoins

cdecker 2014-01-11T17:08:11.487

@cdecker IMHO it's not a duplicate, even if the answer overlaps. That question asks what are generated transactions, this one asks how to detect them. Different questions. I'd keep this one for reference.kaoD 2014-01-11T18:22:17.733

Sure, I'll retract the close flag.cdecker 2014-01-11T19:44:03.713

Answers

1

Let me clarify the response from kaoD for future reference. The generation transaction is a transaction with exactly 1 input, whose prevOut hash is null:

0000000000000000000000000000000000000000000000000000000000000000

An example of such a transaction in JSON format can be found here (blockchain.info is no use here as it does not conform the JSON output of bitcoind). Notice that besides this, the Satoshi client also puts the coinbase transaction in first position in the tx array, I wouldn't trust this too much though as it may well change in future and may not be consistent across clients.

cdecker

Posted 2014-01-11T06:42:01.740

Reputation: 7 878

0

Okay, found it:

In main.h, function IsCoinBase(): return (vin.size() == 1 && vin[0].prevout.IsNull());

kaoD

Posted 2014-01-11T06:42:01.740

Reputation: 958