3

I'm developing an application on Bitcoin blockchain, and I use output transaction scripts that are not standard according to the classic payment methods. However, even so, on Tesnet everything works fine but I recently read on Bitcoin site the following:

enter image description here

So, appearently, Tesnet may relax some restrictions on transaction scripts, but it doesn't specify much more. So, now, I have no way of knowing if such output transaction scripts could be accepted on the Mainnet, except by buying some Bitcoins with money that I really don't have, and I'm also starting to wonder what is the purpose of the Testnet if its behaviour doesn't reflect the one of the real net and, even worse, what is the purpose of having a script language with such multiple instructions when you can actually use just a few of them. Is someone able to give me more informations about all this? Thanks in advance.

2 Answers 2

8

Standard output scripts are defined by IsStandard() (which calls Solver() to perform the actual script matching). The standard output scripts are as follows:

  • P2PKH
  • P2PK
  • P2SH
  • P2WPKH
  • P2WSH
  • A script beginning with an OP_RETURN and only pushes at most 80 bytes data to the stack
  • Bare multisig up to a 3-of-3 multisig

Any other script will be non-standard and the entire transaction will be rejected as being non-standard.


Instead of trying to include a non-standard output script, you can instead use P2SH or P2WSH. Your output script will become the redeem script or witness script which can be anything. P2SH and P2WSH allow you to do exactly the same things as if the script were in an output script.

If you still insist on wanting your non-standard script to be in the output, then for your transaction to be broadcast and mined, you will need to find a miner and give them your transaction through some other means. Non-standard transactions will not be relayed and most nodes will not accept them. You will need to give your transaction to a miner who is accepting non-standard transactions, and it is highly likely that you need to do this out of band, i.e. over some form of communication that is not the P2P network.

4
  • 1
    Thank you very much for your exhaustive answer. The fact that I can't use P2SH is because this requires the redeem script to be known by the sender (so he can include the hash in the output script) and the receiver. In my setting, instead, the redeem script is known only by the sender.
    – Daniel
    Dec 4, 2018 at 18:29
  • 1
    That doesn't really make sense. How does the receiver know he's being paid if he doesn't know what output script to look for?
    – Andrew Chow
    Dec 4, 2018 at 21:57
  • @AndrewChow you are saying just use P2SH instead of any non-standard script... but then the redeem script will be non-standard, right? Or is ANYTHING considered valid in a redeem script?
    – ZMitton
    Apr 6 at 15:14
  • 1
    @ZMitton Any redeemScript is valid. There are no standardness checks on the input script type.
    – Andrew Chow
    Apr 6 at 16:23
1

You can always wrap your non-standard output scripts in p2sh/p2wsh output scripts, which will be recognized for standardness and propagated by nodes on the network.

3
  • 1
    The fact is that I can't use P2SH, because I need my non-standard script to be placed into an output script. With P2SH I have to place it into an input script.
    – Daniel
    Dec 4, 2018 at 11:09
  • What do you mean saying "I need my non-standard script to be placed into an output script"??? You can not today put your arbitrary script into the transaction outputs. But you can achieve the SAME goals using p2sh/p2wsh - they were designed/implemented for this case!
    – amaclin
    Dec 4, 2018 at 11:47
  • Yeah, I figured as much. However, Testnet allows me to do that.
    – Daniel
    Dec 4, 2018 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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