9

This is useful in Andreas Antonopoulos' book, Mastering Bitcoin:

https://github.com/bitcoinbook/bitcoinbook/blob/7c552ea5cfbc19448635b36407761b377ff5cbe9/ch05.asciidoc#standard-transactions

"In the first few years of bitcoin’s development, the developers introduced some limitations in the types of scripts that could be processed by the reference client. These limitations are encoded in a function called isStandard(), which defines five types of "standard" transactions."

Where are the five types listed in the Bitcoin Core codebase?

3

This is easier said than done, IMO. There are plenty of little fact sheet web pages (e.g. https://www.cryptocompare.com/coins/guides/what-are-the-bitcoin-transaction-types/) lying around that give a list of the "Standard" Bitcoin Transaction types, but nothing super authoritative.

However, I think the most authoritative source as of this very moment is the Bitcoin core source code.

I did my own search, recently, to prep for Andreas Antonopoulos' meetup tomorrow:

https://duckduckgo.com/?q=how+can+I+find+out+if+a+bitcoin+transaction+type+is+considered+standard%3F&t=ha&ia=web

The Mastering Bitcoin book refers to it in three different chapters:

https://github.com/bitcoinbook/bitcoinbook/search?utf8=%E2%9C%93&q=%22standard+transactions%22&type=

https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch07.asciidoc#multi-signature

I also found a good link to a comprehensive list of them here:

https://books.google.com/books?id=YHfCBwAAQBAJ&pg=PA92&lpg=PA92&dq=how+can+I+find+out+if+a+bitcoin+transaction+type+is+considered+standard?&source=bl&ots=GK4gh-mjoL&sig=BHl4csT7dQZUPwT61W6-QT1qrR0&hl=en&sa=X&ved=0ahUKEwjD5JCD-obTAhUJ0mMKHdyeCBQQ6AEIQDAF#v=onepage&q=how%20can%20I%20find%20out%20if%20a%20bitcoin%20transaction%20type%20is%20considered%20standard%3F&f=false

Google Books result for a Cursory Search

And the 5 types, pubkey, pubkey_hash, multisig, script_hash, op_return, have some neato stats here: https://webbtc.com/stats

Long story short, I think you're just going to have to byte the bullet and get a friend who knows C++ to explain the contents of the policy.cpp file to you:

https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L44

That friend will be me, shortly...

(some time later)

It looks like there are two functions that tell whether a transaction is 'Standard' by Bitcoin Core's logic: IsStandard() and IsStandardTx().

Header: https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.h#L75

Source code:

IsStandard(): https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L34

  1. IsStandard() first checks the transaction against the Solver. https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L37
  2. Next, IsStandard() checks whether the transaction is an N of 3 multisig: https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L40
  3. Lastly, if witness transactions are enabled, IsStandard() checks that the transaction is one of the two standard types of witness transactions. https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L53

IsStandardTx(): https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L59

  1. A standard transaction must have a sufficiently low application version. https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L61
  2. The transaction has to have a sufficiently low weight. https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L66
  3. If a given Bitcoin Transaction is a Pay to Script Hash transaction, it must have a small scriptSig value. According to the arithmetic in the comments, that works out to about 15 M of N signers (that is, 15 "co-signers" for a transaction) maximum. AND it has to be push-only. Not sure what "push-only" means, but apparently it's important. https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L76 https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L89
  4. Next, it seems that it's checking the scriptPubKey against the IsStandard() function. https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L97
  5. Null transactions are considered standard, as are transactions that have only one OP_RETURN output. But not empty multisig or dust transactions. https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L103 https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L114

I'd guess this is a pretty reasonable standard to which to hold "Standard" transactions.

The comments explain some of it.

If you want to have a look at what inputs and witnesses are considered standard, you can just have a look further down the page, or ask another question on this site.

  • Not super comfortable answering this, but I think it's enough to give someone unfamiliar a glimpse into the code base for the first time. If you want to edit it for clarity or correctness, please do so! – Nathan Basanese Apr 3 '17 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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