How to create a p2sh transaction with a scriptsig of OP_true?

2

How can I create a p2sh transaction with a scriptsig containing OP_TRUE only, removing the need for a digital signature, which will be broadcasted and mined?

Also could some one provide an example of such a transaction?

Errol

Posted 2018-03-21T21:55:11.977

Reputation: 117

Answers

2

Here you have an example of a transaction spending from a P2PKH output and creating a P2SH output with an OP_1.

And here you have the counterpart, a transaction spending from the first one (with an input script '0151') and generating a P2PKH output.

I've created both using a Python library i'm coauthor of. You can check it out here.

sr-gi

Posted 2018-03-21T21:55:11.977

Reputation: 2 584

Updated links to blockstream.info as prior block explorer links have been taken down – Michael Folkson – 2020-12-31T13:03:45.807

I've added new transactions including fees to ensure that they end up in a block. – sr-gi – 2018-03-23T10:42:28.697

Does the output script you use to fund the p2sh transaction always have to be OP_HAS160 (hash) OP_EQUAL ? – Errol – 2018-03-23T18:57:51.643

Yes, that's the structure of any P2SH output script. – sr-gi – 2018-03-23T19:11:57.953

Could a transaction like that be created on the mainnet? – Errol – 2018-03-23T19:18:50.153

Sure. However you should be careful, anyone will be able to redeem it. – sr-gi – 2018-03-23T19:51:32.827

Would the transaction with scriptsig 0151 be considered standard or non standard? – Errol – 2018-03-23T20:08:47.533

Standard AFAIK, it's just a push of data. – sr-gi – 2018-03-23T20:22:56.297

So once the output script you are using as your input is OP_HASH160 (hash) OP_EQUAL , you can create a p2sh transaction with scriptsig OP_TRUE that doesn't require a digital signature? – Errol – 2018-03-23T21:23:09.270

You're messing around the concepts a little bit. If you are spending an UTXO of type P2SH that encapsulates the hash of an OP_True, you can create a P2SH transaction that spends it just by pushing a 1 to the stack. – sr-gi – 2018-03-23T22:01:13.183

So how can you know if it encapsulates the hash of OP_TRUE and what does a hash of OP_TRUE look like? – Errol – 2018-03-23T22:24:11.677

has160(A) = hash_A no matter how many times you compute it. So the hash of OP_True will always be da1745e9b549bd0bfa1a569971c77eba30cd5a4b – sr-gi – 2018-03-23T22:43:57.567

So if the utxo doesn't encapsulate OP_TRUE, is there any other op code or combination of op codes that can be used to create a transaction that can be broadcasted and mined? – Errol – 2018-03-23T22:54:25.433

Yes, it doesn't matter the op_code combination. You can create for examples a P2SH encapsulating an OP_2 OP_EQUAL, and then redeem it with a push of 2. There are many combinations that do not imply a signature. – sr-gi – 2018-03-23T23:12:07.803

So is there any op code or combination of opcodes that will make a transaction valid regardless of what the output script encapsulates and if not, how can you determine what the output script encapsultes in order to create a scriptsig with the necessary op codes? – Errol – 2018-03-23T23:32:09.997