OP_PUSHDATA1 is not allowed inside redeem script of P2SH?

0

P2SH “relaxed standards” for P2SH redeem scripts in Bitcoin Core 0.10.0

What is meant by "relaxed standards" for P2SH redeem scripts in Bitcoin Core 0.10.0?

I just try to create redeem script with OP_PUSHDATA1 opcode and push it using Blockchain.info

RAW TX is

In case I start use OP_PUSHDATA1 transaction not broadcast to network At example Blockchain.info give me error "P2SH script execution resulted in a non-true stack"

Transaction with data = 90 bytes

0100000001a54c8127690cbf24f4d18336aae1c72f124fe00039218ad8ca42d988050d303f17000000e247304402205221bd680af998ac98f7ede5b532761a0a643da1cf16a30afb73b8b79fdcfd010220759d2e7eccf89d85b921f6d9c9246f9e9193ab6b60e3b387e31ec86298a643640121026b8cdb5ee526886dd01540df3c3c001876a5dedbe834f92b75eea7e1cc17ed7c4c764c5a3131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131317576a9146902e12aeb180003f48d4411ed27ff6f5202d0fa88acffffffff0198210000000000001976a9146902e12aeb180003f48d4411ed27ff6f5202d0fa88ac00000000

JSON

{"output": [{"address": ["1AaFQDd393APFh9XAKYJjsKLtvRdZPpzKk"], "out_index": 0, "script": {"pattern": "OP_DUP OP_HASH160 <20> OP_EQUALVERIFY OP_CHECKSIG", "asm": "OP_DUP OP_HASH160 6902e12aeb180003f48d4411ed27ff6f5202d0fa OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9146902e12aeb180003f48d4411ed27ff6f5202d0fa88ac", "type": "P2PKH"}, "amount": 8600}],

"input": [ {"sequence": 4294967295, "address": ["38rsbYpEuckLjnts7dF2YjNT2wcu1RmjmU"],

"sig_script": { "pattern": "<71> <33> <118>",

 "asm": "304402205221bd680af998ac98f7ede5b532761a0a643da1cf16a30afb73b8b79fdcfd010220759d2e7eccf89d85b921f6d9c9246f9e9193ab6b60e3b387e31ec86298a6436401 026b8cdb5ee526886dd01540df3c3c001876a5dedbe834f92b75eea7e1cc17ed7c 4c5a3131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131317576a9146902e12aeb180003f48d4411ed27ff6f5202d0fa88ac", 

"type": "SIGSCRIPT",

"hex": "47304402205221bd680af998ac98f7ede5b532761a0a643da1cf16a30afb73b8b79fdcfd010220759d2e7eccf89d85b921f6d9c9246f9e9193ab6b60e3b387e31ec86298a643640121026b8cdb5ee526886dd01540df3c3c001876a5dedbe834f92b75eea7e1cc17ed7c4c764c5a3131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131317576a9146902e12aeb180003f48d4411ed27ff6f5202d0fa88ac"},

"redeem_script": {"pattern": "<90> OP_DROP OP_DUP OP_HASH160 <20> OP_EQUALVERIFY OP_CHECKSIG",

I use : test = b"1"*90 s = b"\x4c"+len(test).to_bytes(1,'little')+test+OPCODE["OP_DROP"]+s

"asm": "313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131 OP_DROP OP_DUP OP_HASH160 6902e12aeb180003f48d4411ed27ff6f5202d0fa OP_EQUALVERIFY OP_CHECKSIG", 

"hex": "4c5a3131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131317576a9146902e12aeb180003f48d4411ed27ff6f5202d0fa88ac",

"type": "NON_STANDART"},

"script": {"pattern": "OP_HASH160 <20> OP_EQUAL", "asm": "OP_HASH160 4ea616b2ce8f782688f9170e32cde1f0396be720 OP_EQUAL", "type": "P2SH", "hex": "a9144ea616b2ce8f782688f9170e32cde1f0396be72087"}, "amount": 20000, "input_index": 0, "output_index": 23, "transaction_hash": "3f300d0588d942cad88a213900e04f122fc7e1aa3683d1f424bf0c6927814ca5"}], "data": "", "timestamp": 1473702857, "size": 311, "locktime": 0, "hash": "3e3b46a701103d18849f3b36fc906a6fedcc790b2f7185660ccfa6b9d9451e90", "coinbase": false, "block": null, "fee": 11400}

bitaps.com

Posted 2016-09-12T12:05:37.083

Reputation: 563

Answers

2

OP_PUSHDATA1 and even OP_PUSHDATA2 are allowed inside P2SH scripts fine. However, there is another policy in Bitcoin Core to require that all pushes are minimal in standard transactions. That means you can only use OP_PUSHDATA1 when a direct push is not possible (up to 75 bytes), and only use OP_PUSHDATA2 when an OP_PUSHDATA1 is not possible (up to 255 bytes).

Also, in general: when experimenting with scripts, try things on testnet first.

Pieter Wuille

Posted 2016-09-12T12:05:37.083

Reputation: 54 032

Thank you Pieter for reply. Could you provide example of transaction inside blockchain. If I will have example I will investigate my problem. I know about minimal limitation to prevent transaction malleability. And I tried to create transaction with data push > 75. Same error I just edit my question and add transaction with data = 90 bytesbitaps.com 2016-09-12T17:57:49.320

@bitaps I looked at your Script a little bit and it seems that you are using OP_PUSHDATA1 appropriately. I'm wondering if this is an issue with blockchain.info, have you tried using this against bitcoin core?Chris Stewart 2016-09-12T21:05:15.987

https://www.smartbit.com.au/txs/pushtx -> PUSH TRANSACTION ERROR: 16: MANDATORY-SCRIPT-VERIFY-FLAG-FAILED (SCRIPT EVALUATED WITHOUT ERROR BUT FINISHED WITH A FALSE/EMPTY TOP STACK ELEMENT)bitaps.com 2016-09-13T00:45:38.233

https://blockchain.info/ru/pushtx -> P2SH script execution resulted in a non-true stackbitaps.com 2016-09-13T00:49:11.327

https://live.blockcypher.com/btc/pushtx/ -> Error sending transaction: Rejected script for input 0 referencing 3f300d0588d942cad88a213900e04f122fc7e1aa3683d1f424bf0c6927814ca5 at 23..bitaps.com 2016-09-13T00:51:14.020

We have own bitcoin node implementation, and our node successfully decode this transaction https://bitaps.com/3e3b46a701103d18849f3b36fc906a6fedcc790b2f7185660ccfa6b9d9451e90 But most of network nodes reject it. I want to understand the reason.

bitaps.com 2016-09-13T00:53:52.840

This really just looks like the signature is wrong.Pieter Wuille 2016-09-13T03:52:17.840

Thank you Peter! Just found and fixed problem with signature hash generation. https://bitaps.com/41e5c7718389d6fb7b845f0b396db4b7b245101dbb58ae40c4610030cb959e16 Transaction successfully accepted in network

bitaps.com 2016-09-13T08:00:31.893