<p>The most straightforward (and safe) way is to use a Miniscript output descriptor. You can generate one using a Miniscript policy compiler.</p>
<p>For instance with your key <code>A</code>, and 4 other keys <code>B</code> <code>C</code> <code>D</code> and <code>E</code> the Miniscript policy could be <code>and(pk(A),thresh(1,pk(B),pk(C),pk(D),pk(E)))</code>.</p>
<p>Using @sipa's <a href="https://bitcoin.sipa.be/miniscript/" rel="nofollow noreferrer">online Miniscript policy compiler</a>, this compiles to <code>and_v(v:pk(A),c:or_i(pk_k(B),or_i(pk_h(C),or_i(pk_h(D),pk_h(E)))))</code>. You can then use the <code>wsh(and_v(v:pk(A),c:or_i(pk_k(B),or_i(pk_h(C),or_i(pk_h(D),pk_h(E))))))</code> output descriptor in a wallet that supports it (for instance Bitcoin Core), to receive and send funds using this policy.</p>
<hr />
<p>For what it's worth, the Bitcoin Script corresponding to the above Miniscript is:</p>
<pre><code>&lt;A&gt; OP_CHECKSIGVERIFY OP_IF
  &lt;B&gt;
OP_ELSE
  OP_IF
    OP_DUP OP_HASH160 &lt;HASH160(C)&gt; OP_EQUALVERIFY
  OP_ELSE
    OP_IF
      OP_DUP OP_HASH160 &lt;HASH160(D)&gt; OP_EQUALVERIFY
    OP_ELSE
      OP_DUP OP_HASH160 &lt;HASH160(E)&gt; OP_EQUALVERIFY
    OP_ENDIF
  OP_ENDIF
OP_ENDIF
OP_CHECKSIG
</code></pre>

CC BY-SA 4.0
2023-04-10T09:35:04.540Z
Ha beat me to it. Deleting my answer :)
Michael Folkson
CC BY-SA 4.0
2023-04-10T09:33:13.283Z
2023-04-10T09:33:13.283Z
Antoine Poinsot
<p>You just have to modify your script a little like that <code>&lt;my_key&gt; OP_CHECKSIG OP_IFDUP OP_NOTIF OP_1 &lt;key1&gt; &lt;key2&gt; &lt;key3&gt; &lt;key4&gt; OP_4 OP_CHECKMULTISIG OP_ENDIF</code></p>
<p>It will require two signatures to unlock the transaction output, one from your key and one from the other four key.</p>
<p>To use this as a Bitcoin lock script you will have to create a P2SH address that will contain the hash of your script, also notice that this script is pre Taproot since it use <code>CHECKMULTISIG(VERIFY)</code> . And of course dont forget to test heavily all this on a testnet if you want to use real fund for it.</p>

CC BY-SA 4.0
2023-04-10T09:10:12.567Z
Thanks, but how do you make sure that my key is always present? As far as i understand, with your script, any combination of 5 keys can claim this transaction.
Anıl
CC BY-SA 4.0
2023-04-10T09:11:07.760Z
I think the question asker wants their key to be used for all spends with an additional key from the 4. Your script would allow spends without the question asker's key
Michael Folkson
CC BY-SA 4.0
2023-04-10T09:16:32.603Z
I modified my answer, now it ensure that your key have to be present
Saxtheowl
CC BY-SA 4.0
2023-04-10T09:24:53.100Z
Perhaps also state that this is pre Taproot and that with Taproot you'd use CHECKSIGADD rather than CHECKMULTISIG(VERIFY) that was disabled for Taproot addresses
Michael Folkson
CC BY-SA 4.0
2023-04-10T08:57:00.750Z
2023-04-10T09:38:00.047Z
2023-04-10T09:38:00.047Z
Saxtheowl
<p>I need a bitcoin lock script that will require my key and 1 of 4 other people.</p>
<p>For example, If my key is present and one of the 4 other keys are also present, transaction can be claimed. If my key is not present, even the presence of all of the other 4 keys will not be enough to claim the transaction.</p>
<p>I have created a script like below but I couldnt figure out how to convert it to a lock script.</p>
<p>my_key OP_CHECKSIGVERIFY OP_1 key1 key2 key3 key4 OP_4 OP_CHECKMULTISIGVERIFY</p>

<script><multi-signature><miniscript>
Conditional MULTISIG transaction
Anıl
# Conditional MULTISIG transaction

(Asked by: username_0 on 2023-04-09)

I need a bitcoin lock script that will require my key and 1 of 4 other people.

For example, If my key is present and one of the 4 other keys are also present, transaction can be claimed. If my key is not present, even the presence of all of the other 4 keys will not be enough to claim the transaction.

I have created a script like below but I couldnt figure out how to convert it to a lock script.

my\_key OP\_CHECKSIGVERIFY OP\_1 key1 key2 key3 key4 OP\_4 OP\_CHECKMULTISIGVERIFY

**Tags:** script, multi-signature, miniscript


---

## 2 answers

### Answer by username_1 on 2023-04-10. Score: 3

The most straightforward (and safe) way is to use a Miniscript output descriptor. You can generate one using a Miniscript policy compiler.

For instance with your key `A`, and 4 other keys `B` `C` `D` and `E` the Miniscript policy could be `and(pk(A),thresh(1,pk(B),pk(C),pk(D),pk(E)))`.

Using @sipa's [online Miniscript policy compiler](https://bitcoin.sipa.be/miniscript/), this compiles to `and_v(v:pk(A),c:or_i(pk_k(B),or_i(pk_h(C),or_i(pk_h(D),pk_h(E)))))`. You can then use the `wsh(and_v(v:pk(A),c:or_i(pk_k(B),or_i(pk_h(C),or_i(pk_h(D),pk_h(E))))))` output descriptor in a wallet that supports it (for instance Bitcoin Core), to receive and send funds using this policy.

---

For what it's worth, the Bitcoin Script corresponding to the above Miniscript is:

```
<A> OP_CHECKSIGVERIFY OP_IF
  <B>
OP_ELSE
  OP_IF
    OP_DUP OP_HASH160 <HASH160(C)> OP_EQUALVERIFY
  OP_ELSE
    OP_IF
      OP_DUP OP_HASH160 <HASH160(D)> OP_EQUALVERIFY
    OP_ELSE
      OP_DUP OP_HASH160 <HASH160(E)> OP_EQUALVERIFY
    OP_ENDIF
  OP_ENDIF
OP_ENDIF
OP_CHECKSIG

```

> **Comments:**
> **username_2**: Ha beat me to it. Deleting my answer :)  

---

### Answer by username_3 on 2023-04-10. Score: 1

You just have to modify your script a little like that `<my_key> OP_CHECKSIG OP_IFDUP OP_NOTIF OP_1 <key1> <key2> <key3> <key4> OP_4 OP_CHECKMULTISIG OP_ENDIF`

It will require two signatures to unlock the transaction output, one from your key and one from the other four key.

To use this as a Bitcoin lock script you will have to create a P2SH address that will contain the hash of your script, also notice that this script is pre Taproot since it use `CHECKMULTISIG(VERIFY)` . And of course dont forget to test heavily all this on a testnet if you want to use real fund for it.

> **Comments:**
> **username_0**: Thanks, but how do you make sure that my key is always present? As far as i understand, with your script, any combination of 5 keys can claim this transaction.  
> **username_2**: I think the question asker wants their key to be used for all spends with an additional key from the 4. Your script would allow spends without the question asker's key  
> **username_3**: I modified my answer, now it ensure that your key have to be present  
> **username_2**: Perhaps also state that this is pre Taproot and that with Taproot you'd use CHECKSIGADD rather than CHECKMULTISIG(VERIFY) that was disabled for Taproot addresses  

---

