<p>Here you have <a href="https://blockstream.info/testnet/tx/da58f6688b0727a7f1bf3eec899099bde1f18b9c7099f9d2c79556db238e623d" rel="nofollow noreferrer">an example</a> of a transaction spending from a P2PKH output and creating a P2SH output with an OP_1.</p>
<p>And here you have <a href="https://www.blockstream.info/testnet/tx/839b903b9f79c3372792ceb95917047c46d1b919ed1f6471f5a19d7c865ab32c" rel="nofollow noreferrer">the counterpart</a>, a transaction spending from the first one (with an input script '0151') and generating a P2PKH output.</p>
<p>I've created both using a Python library i'm coauthor of. You can check it out <a href="https://github.com/sr-gi/bitcoin_tools" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 3.0
2018-03-23T10:42:28.697Z
I've added new transactions including fees to ensure that they end up in a block.
sr_gi
CC BY-SA 3.0
2018-03-23T18:57:51.643Z
Does the output script you use to fund the p2sh transaction always have to be OP_HAS160 (hash) OP_EQUAL ?
Errol
CC BY-SA 3.0
2018-03-23T19:11:57.953Z
Yes, that's the structure of any P2SH output script.
sr_gi
CC BY-SA 3.0
2018-03-23T19:18:50.153Z
Could a transaction like that be created on the mainnet?
Errol
CC BY-SA 3.0
2018-03-23T19:51:32.827Z
Sure. However you should be careful, anyone will be able to redeem it.
sr_gi
CC BY-SA 3.0
2018-03-23T20:08:47.533Z
Would the transaction with scriptsig 0151 be considered standard or non standard?
Errol
CC BY-SA 3.0
2018-03-23T20:22:56.297Z
Standard AFAIK, it's just a push of data.
sr_gi
CC BY-SA 3.0
2018-03-23T21:23:09.270Z
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
CC BY-SA 3.0
2018-03-23T22:01:13.183Z
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
CC BY-SA 3.0
2018-03-23T22:24:11.677Z
So how can you know if it encapsulates the hash of OP_TRUE and what does a hash of OP_TRUE  look like?
Errol
CC BY-SA 3.0
2018-03-23T22:43:57.567Z
`has160(A) = hash_A` no matter how many times you compute it. So the hash of OP_True will always be `da1745e9b549bd0bfa1a569971c77eba30cd5a4b`
sr_gi
CC BY-SA 3.0
2018-03-23T22:54:25.433Z
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
CC BY-SA 3.0
2018-03-23T23:12:07.803Z
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
CC BY-SA 3.0
2018-03-23T23:32:09.997Z
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
CC BY-SA 4.0
2020-12-31T13:03:45.807Z
Updated links to blockstream.info as prior block explorer links have been taken down
Michael Folkson
CC BY-SA 4.0
2018-03-23T10:03:43.463Z
2020-12-31T13:03:03.643Z
2020-12-31T13:03:03.643Z
sr_gi
<p>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?</p>

<p>Also could some one provide an example of such a transaction?</p>

CC BY-SA 4.0
2022-06-04T22:20:43.577Z
@Michael Folkson I see the tag `bitcoin-core-development` was added by you, but I don't understand how it's related to the question, can you explain?
Vojtěch Strnad
CC BY-SA 4.0
2022-06-05T12:05:03.023Z
@VojtěchStrnad: Not sure, it was a while back! Think I thought it was functional test related but removed now :)
Michael Folkson
<script><python><input-script><opcodes>
How to create a p2sh transaction with a scriptsig of OP_true?
Errol
# How to create a p2sh transaction with a scriptsig of OP_true?

(Asked by: username_0 on 2018-03-21)

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?

**Tags:** script, python, input-script, opcodes

> **Comments:**
> **username_1**: @username_2 I see the tag `bitcoin-core-development` was added by you, but I don't understand how it's related to the question, can you explain?  
> **username_2**: @VojtěchStrnad: Not sure, it was a while back! Think I thought it was functional test related but removed now :)  

---

## 1 answers

### Answer by username_3 on 2018-03-23. Score: 2

Here you have [an example](https://blockstream.info/testnet/tx/da58f6688b0727a7f1bf3eec899099bde1f18b9c7099f9d2c79556db238e623d) of a transaction spending from a P2PKH output and creating a P2SH output with an OP\_1.

And here you have [the counterpart](https://www.blockstream.info/testnet/tx/839b903b9f79c3372792ceb95917047c46d1b919ed1f6471f5a19d7c865ab32c), 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](https://github.com/sr-gi/bitcoin_tools).

> **Comments:**
> **username_3**: I've added new transactions including fees to ensure that they end up in a block.  
> **username_0**: Does the output script you use to fund the p2sh transaction always have to be OP_HAS160 (hash) OP_EQUAL ?  
> **username_3**: Yes, that's the structure of any P2SH output script.  
> **username_0**: Could a transaction like that be created on the mainnet?  
> **username_3**: Sure. However you should be careful, anyone will be able to redeem it.  
> **username_0**: Would the transaction with scriptsig 0151 be considered standard or non standard?  
> **username_3**: Standard AFAIK, it's just a push of data.  
> **username_0**: 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?  
> **username_3**: 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.  
> **username_0**: So how can you know if it encapsulates the hash of OP_TRUE and what does a hash of OP_TRUE  look like?  
> **username_3**: `has160(A) = hash_A` no matter how many times you compute it. So the hash of OP_True will always be `da1745e9b549bd0bfa1a569971c77eba30cd5a4b`  
> **username_0**: 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?  
> **username_3**: 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.  
> **username_0**: 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?  
> **username_2**: Updated links to blockstream.info as prior block explorer links have been taken down  

---

