<p>First of all, like pointed out in the first comment on your question, you're confusing the &quot;witness program&quot; and &quot;witness script&quot;. The witness program for p2wpkh is <code>OP_0</code> followed by the 32-byte SHA-256 hash of the witness script.</p>
<p>So it seems that you are actually asking about the witness script.</p>
<p>To answer your question directly: <strong>no</strong>, there are no standard witness scripts.</p>
<p>The witness script obviously depend on what you are trying to achieve. The most common use case for p2wsh would be multisig addresses, but they can be used for various other use-cases like policies with time-locked backup spend paths, lightning channel setup, etc.</p>
<p>Each use-case and in fact each application will have to specify the Script they use in the p2wsh policy. There is no real standard among those scripts. However, there are some things to consider:</p>
<ul>
<li><p>Whatever Script you are using, <em>you need to remember the script in order to spend the money that is in them</em>. Usually this is something that your wallet will do, but for example if the wallet you are using goes out of service, you will need to know the type of script they use in order to recover your money, alongside the seed phrase.</p>
</li>
<li><p>Many users will use tools like <strong>miniscript Script descriptors</strong> to turn a script policy into a Bitcoin Script. These users can store the Script descriptor as a backup together with their seed phrase. Script descriptors were introduced exactly to overcome the problem of each wallet having their own scripts.</p>
</li>
<li><p>In several cases, among multisig-enabled wallets that don't support miniscript descriptors yet, the &quot;Script template&quot; they use is either very trivial (a simple multisig f.e., even though f.e. the order of keys also matters here, already making it less trivial), or the template is documented online and a user could potentially find out how to recover their money when they only know their seed phrase.</p>
</li>
</ul>
<p>To conclude, witness scripts used in p2wsh addresses are not standardized and <strong>ideally your wallet provider would instruct you to backup a miniscript descriptor alongside the seed phrase</strong> so that users can actually recover their coins in the event where the wallet provider disappears and/or the wallet app becomes unusable.</p>

CC BY-SA 4.0
2023-09-29T16:14:29.010Z
2023-09-29T16:14:29.010Z
Steven Roose
<p>It is <code>0</code> and a 32-byte push of Sha256 of the scriptPubKey (which is the script you use to generate the address). You can find an example here: <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wsh" rel="nofollow noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wsh</a></p>
<p>The Python example you linked uses WP2PSH as WP2PKH. You can see the how WP2PKH works here: <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh" rel="nofollow noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh</a></p>

CC BY-SA 4.0
2021-01-11T17:42:19.280Z
2021-01-11T17:42:19.280Z
MCCCS
<p><em>For the examples below I am going to be talking of 1-of-1 multisig only derived from a single private key.</em></p>
<p>For P2WPKH, the address is generated using using hash160 of the public key which acts as the witness program.</p>
<p><strong>For P2WSH, is there any standard witness program?</strong> The demo in <a href="https://bc-2.jp/tools/bech32demo/index.html" rel="nofollow noreferrer">https://bc-2.jp/tools/bech32demo/index.html</a> uses <code>&lt;pubkey&gt; OP_CHECKSIG[0xac]</code> as the WitnessScript. While <code>bitcoinaddress</code> pip package uses a different approach (see <a href="https://github.com/fortesp/bitcoinaddress/blob/master/bitcoinaddress/address.py#L130-L133" rel="nofollow noreferrer">https://github.com/fortesp/bitcoinaddress/blob/master/bitcoinaddress/address.py#L130-L133</a> )</p>
<p>(Please excuse any wrong nomenclature I might have used in this question)</p>

CC BY-SA 4.0
2021-01-11T22:23:03.667Z
Note that witness program and witness script are not the same thing (the first is the OP_n + hash placed in the scriptPubKey; the second is the actual script executed. Also, you're asking about a standard witness script to do **what**? A 1-of-1 multisig is pointless.
Pieter Wuille
CC BY-SA 4.0
2021-01-12T01:53:53.263Z
@PieterWuille Thanks for your reply Pieter (SegWit designer). So what I am asking is about a standard witness script **to create a P2WSH address**. (In Samourai wallet, I have noticed I have P2WSH addresses, and so I was wondering how it was created.)
GMaster
CC BY-SA 4.0
2021-01-12T02:05:44.267Z
A standard witness script **for what**? A script is a program, it does something. The question is what do you want it to do?
Pieter Wuille
<p2wpkh><p2wsh>
Generating P2WSH addresses | Is there a standard WitnessScript?
GMaster
# Generating P2WSH addresses | Is there a standard WitnessScript?

(Asked by: username_0 on 2021-01-11)

*For the examples below I am going to be talking of 1-of-1 multisig only derived from a single private key.*

For P2WPKH, the address is generated using using hash160 of the public key which acts as the witness program.

**For P2WSH, is there any standard witness program?** The demo in <https://bc-2.jp/tools/bech32demo/index.html> uses `<pubkey> OP_CHECKSIG[0xac]` as the WitnessScript. While `bitcoinaddress` pip package uses a different approach (see <https://github.com/fortesp/bitcoinaddress/blob/master/bitcoinaddress/address.py#L130-L133> )

(Please excuse any wrong nomenclature I might have used in this question)

**Tags:** p2wpkh, p2wsh

> **Comments:**
> **username_1**: Note that witness program and witness script are not the same thing (the first is the OP_n + hash placed in the scriptPubKey; the second is the actual script executed. Also, you're asking about a standard witness script to do **what**? A 1-of-1 multisig is pointless.  
> **username_0**: @username_1 Thanks for your reply username_1 (SegWit designer). So what I am asking is about a standard witness script **to create a P2WSH address**. (In Samourai wallet, I have noticed I have P2WSH addresses, and so I was wondering how it was created.)  
> **username_1**: A standard witness script **for what**? A script is a program, it does something. The question is what do you want it to do?  

---

## 2 answers

### Answer by username_2 on 2023-09-29. Score: 2

First of all, like pointed out in the first comment on your question, you're confusing the "witness program" and "witness script". The witness program for p2wpkh is `OP_0` followed by the 32-byte SHA-256 hash of the witness script.

So it seems that you are actually asking about the witness script.

To answer your question directly: **no**, there are no standard witness scripts.

The witness script obviously depend on what you are trying to achieve. The most common use case for p2wsh would be multisig addresses, but they can be used for various other use-cases like policies with time-locked backup spend paths, lightning channel setup, etc.

Each use-case and in fact each application will have to specify the Script they use in the p2wsh policy. There is no real standard among those scripts. However, there are some things to consider:

* Whatever Script you are using, *you need to remember the script in order to spend the money that is in them*. Usually this is something that your wallet will do, but for example if the wallet you are using goes out of service, you will need to know the type of script they use in order to recover your money, alongside the seed phrase.
* Many users will use tools like **miniscript Script descriptors** to turn a script policy into a Bitcoin Script. These users can store the Script descriptor as a backup together with their seed phrase. Script descriptors were introduced exactly to overcome the problem of each wallet having their own scripts.
* In several cases, among multisig-enabled wallets that don't support miniscript descriptors yet, the "Script template" they use is either very trivial (a simple multisig f.e., even though f.e. the order of keys also matters here, already making it less trivial), or the template is documented online and a user could potentially find out how to recover their money when they only know their seed phrase.

To conclude, witness scripts used in p2wsh addresses are not standardized and **ideally your wallet provider would instruct you to backup a miniscript descriptor alongside the seed phrase** so that users can actually recover their coins in the event where the wallet provider disappears and/or the wallet app becomes unusable.


---

### Answer by username_3 on 2021-01-11. Score: -1

It is `0` and a 32-byte push of Sha256 of the scriptPubKey (which is the script you use to generate the address). You can find an example here: <https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wsh>

The Python example you linked uses WP2PSH as WP2PKH. You can see the how WP2PKH works here: <https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh>


---

