<blockquote>
<pre><code>OP_1 &lt;Public Key hash&gt; &lt;Public Key hash&gt; &lt;Public Key hash&gt; 3 OP_CHECKMULTISIGVERIFY OP_3 OP_EQUAL
</code></pre>
</blockquote>
<p>This is not a valid use of <code>CHECKMULTISIGVERIFY</code>. This script would not be spendable.</p>
<blockquote>
<p>Is it possible to use a custom script using a descriptor? If I understand, a descriptor is &quot;like a function,&quot; so I don't know if a &quot;custom&quot; function is available.</p>
</blockquote>
<p>Under <code>tr()</code> and <code>wsh()</code> you can import more complex scripts but those have to be valid <a href="https://bitcoin.sipa.be/miniscript/" rel="nofollow noreferrer">Miniscripts</a>. Otherwise, the modern equivalent of the <code>importaddress</code> you were using on legacy wallets would be to use an <code>addr()</code> descriptor. In this case however Bitcoin Core won't know how to spend an output with the corresponding scriptPubKey.</p>

CC BY-SA 4.0
2023-12-09T13:08:20.283Z
Hello, thanks for your reply. This script is for study purposes only. Anyway, I will build the scriptsig properly in order to spend the transaction. It works with legacy commands. you are talking about "addr(ADDR) (top level only): the script which ADDR expands to." correct? what does mean Top Level only? Maybe I could use even raw(hex)
monkeyUser
CC BY-SA 4.0
2023-12-09T13:09:55.863Z
Top-level means that you can't use it inside another desc. Yes you could use raw() too. What are you trying to achieve? If you want to play with the Script interpreter there are tools out there you might be interested in trying out, such as https://github.com/bitcoin-core/btcdeb
Antoine Poinsot
CC BY-SA 4.0
2023-12-09T13:16:05.213Z
Yes, I love btcdeb, and I use it. My purpose is just for study. I want to import a multisignature 1-3, sign it, and check that OP_3 is equal to OP_3 that I put in my scriptsig. I create the signature manually. I repeat, it's just for fun and understanding what happens under the hood. With the legacy core, it works properly, but I updated to version 26, and I want to migrate it.
monkeyUser
CC BY-SA 4.0
2023-12-09T13:18:07.757Z
I see. Note this won't work because as i put in my answer your use of CMS is invalid. If you pass it public key hashes it'll just fail at `VERIFY` and never get to execute `OP_3 OP_EQUAL`. :)
Antoine Poinsot
CC BY-SA 4.0
2023-12-09T14:03:10.440Z
the public key hashes form the redeem script and in scriptSig I put Signature and and OP_3. the script works as you can see in testnet https://tbtc.bitaps.com/d3d661ec439baa845a22078b2ced81d346fe0fcd7c1e12f16980c87438d78961/input/0
monkeyUser
CC BY-SA 4.0
2023-12-09T14:05:10.413Z
The P2SH redeem script used in `d3d661ec439baa845a22078b2ced81d346fe0fcd7c1e12f16980c87438d78961`'s input uses public key with CMS, not public key hashes. Maybe you just made a typo in the OP?
Antoine Poinsot
CC BY-SA 4.0
2023-12-09T14:15:05.887Z
oh! understand now! typo in comment :). Edited, thanks BTW: CMS stands for?
monkeyUser
CC BY-SA 4.0
2023-12-09T15:35:10.330Z
I updated my answer with your hint
monkeyUser
CC BY-SA 4.0
2023-12-09T16:11:14.257Z
CMS = op_CheckMultiSig
Pieter Wuille
CC BY-SA 4.0
2023-12-09T12:54:49.223Z
2023-12-09T12:54:49.223Z
Antoine Poinsot
<p>I have a Multisignature address 1-3 with a verification of OP_3, just a simple script to understand custom scripts in Bitcoin</p>
<p>Script definition</p>
<pre><code>#OP_1 &lt;Public Key&gt; &lt;Public Key&gt; &lt;Public Key&gt; 3 OP_CHECKMULTISIGVERIFY OP_3 OP_EQUAL
SCRIPT=&quot;5121&quot;$(cat compressed_public_key_1.txt)&quot;21&quot;$(cat compressed_public_key_2.txt)&quot;21&quot;$(cat compressed_public_key_3.txt)&quot;53AF5387&quot;
</code></pre>
<p>Now, I want to import my address using descriptor</p>
<pre><code>PK1=`cat compressed_private_key_WIF_1.txt`
PK2=`cat compressed_private_key_WIF_2.txt`
PK3=`cat compressed_private_key_WIF_3.txt`
CHECKSUM=$(bitcoin-cli getdescriptorinfo &quot;sh(multi(1,$PK1,$PK2,$PK3))&quot; | jq -r .checksum)
bitcoin-cli importdescriptors '[{ &quot;desc&quot;: &quot;sh(multi(1,'$PK1','$PK2','$PK3'))#'$CHECKSUM'&quot;, &quot;timestamp&quot;: &quot;now&quot;, &quot;internal&quot;: true }]'
</code></pre>
<p>The problem is I can't have the same address because the script is different.
I will do the signature manually, only for study purposes.
I read <a href="https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md</a> but I didn't find any help about my problem.</p>
<p>Using Legacy code, I was able to import</p>
<pre><code>bitcoin-cli importaddress $ADDR_P2SH
</code></pre>
<p>Where $ADDR_P2SH is the result of my address 1-3.</p>
<p>Is it possible to use a custom script using a descriptor? If I understand, a descriptor is &quot;like a function,&quot; so I don't know if a &quot;custom&quot; function is available.</p>
<p><strong>Update</strong></p>
<p>Thanks to Antoine Poinsot, I am posting the solution. Maybe it could be useful to someone.</p>
<pre><code>ADDR_P2SH=`cat address_P2SH.txt`
bitcoin-cli -named createwallet wallet_name=&quot;bia&quot; disable_private_keys=true


CHECKSUM=$(bitcoin-cli getdescriptorinfo &quot;addr($(cat address_P2SH.txt))&quot; | jq -r .checksum)
bitcoin-cli -rpcwallet=bia importdescriptors '[{ &quot;desc&quot;: &quot;addr('$(cat address_P2SH.txt)')#'$CHECKSUM'&quot;, &quot;timestamp&quot;: &quot;now&quot;, &quot;internal&quot;: true }]'
</code></pre>
<p>and I get the UTXO with</p>
<pre><code>UTXO=`bitcoin-cli -rpcwallet=bia listunspent 1 101 '[&quot;'$ADDR_P2SH'&quot;]'`
</code></pre>

CC BY-SA 4.0
2023-12-09T15:36:07.443Z
Please open a new thread for new questions instead of updating the OP.
Antoine Poinsot
CC BY-SA 4.0
2023-12-09T15:49:06.410Z
Now resolved, I appreciate your time. I've posted the solution to help someone in a similar situation.
monkeyUser
<wallet><p2sh><output-script-descriptors>
descriptor and Custom script
monkeyUser
# descriptor and Custom script

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

I have a Multisignature address 1-3 with a verification of OP\_3, just a simple script to understand custom scripts in Bitcoin

Script definition

```
#OP_1 <Public Key> <Public Key> <Public Key> 3 OP_CHECKMULTISIGVERIFY OP_3 OP_EQUAL
SCRIPT="5121"$(cat compressed_public_key_1.txt)"21"$(cat compressed_public_key_2.txt)"21"$(cat compressed_public_key_3.txt)"53AF5387"

```

Now, I want to import my address using descriptor

```
PK1=`cat compressed_private_key_WIF_1.txt`
PK2=`cat compressed_private_key_WIF_2.txt`
PK3=`cat compressed_private_key_WIF_3.txt`
CHECKSUM=$(bitcoin-cli getdescriptorinfo "sh(multi(1,$PK1,$PK2,$PK3))" | jq -r .checksum)
bitcoin-cli importdescriptors '[{ "desc": "sh(multi(1,'$PK1','$PK2','$PK3'))#'$CHECKSUM'", "timestamp": "now", "internal": true }]'

```

The problem is I can't have the same address because the script is different.
I will do the signature manually, only for study purposes.
I read <https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md> but I didn't find any help about my problem.

Using Legacy code, I was able to import

```
bitcoin-cli importaddress $ADDR_P2SH

```

Where $ADDR\_P2SH is the result of my address 1-3.

Is it possible to use a custom script using a descriptor? If I understand, a descriptor is "like a function," so I don't know if a "custom" function is available.

**Update**

Thanks to username_1 username_1, I am posting the solution. Maybe it could be useful to someone.

```
ADDR_P2SH=`cat address_P2SH.txt`
bitcoin-cli -named createwallet wallet_name="bia" disable_private_keys=true

CHECKSUM=$(bitcoin-cli getdescriptorinfo "addr($(cat address_P2SH.txt))" | jq -r .checksum)
bitcoin-cli -rpcwallet=bia importdescriptors '[{ "desc": "addr('$(cat address_P2SH.txt)')#'$CHECKSUM'", "timestamp": "now", "internal": true }]'

```

and I get the UTXO with

```
UTXO=`bitcoin-cli -rpcwallet=bia listunspent 1 101 '["'$ADDR_P2SH'"]'`

```

**Tags:** wallet, p2sh, output-script-descriptors

> **Comments:**
> **username_1**: Please open a new thread for new questions instead of updating the OP.  
> **username_0**: Now resolved, I appreciate your time. I've posted the solution to help someone in a similar situation.  

---

## 1 answers

### Answer by username_1 on 2023-12-09. Score: 1 | Accepted answer

> ```
> OP_1 <Public Key hash> <Public Key hash> <Public Key hash> 3 OP_CHECKMULTISIGVERIFY OP_3 OP_EQUAL
>
> ```

This is not a valid use of `CHECKMULTISIGVERIFY`. This script would not be spendable.

> Is it possible to use a custom script using a descriptor? If I understand, a descriptor is "like a function," so I don't know if a "custom" function is available.

Under `tr()` and `wsh()` you can import more complex scripts but those have to be valid [Miniscripts](https://bitcoin.sipa.be/miniscript/). Otherwise, the modern equivalent of the `importaddress` you were using on legacy wallets would be to use an `addr()` descriptor. In this case however Bitcoin Core won't know how to spend an output with the corresponding scriptPubKey.

> **Comments:**
> **username_0**: Hello, thanks for your reply. This script is for study purposes only. Anyway, I will build the scriptsig properly in order to spend the transaction. It works with legacy commands. you are talking about "addr(ADDR) (top level only): the script which ADDR expands to." correct? what does mean Top Level only? Maybe I could use even raw(hex)  
> **username_1**: Top-level means that you can't use it inside another desc. Yes you could use raw() too. What are you trying to achieve? If you want to play with the Script interpreter there are tools out there you might be interested in trying out, such as https://github.com/bitcoin-core/btcdeb  
> **username_0**: Yes, I love btcdeb, and I use it. My purpose is just for study. I want to import a multisignature 1-3, sign it, and check that OP_3 is equal to OP_3 that I put in my scriptsig. I create the signature manually. I repeat, it's just for fun and understanding what happens under the hood. With the legacy core, it works properly, but I updated to version 26, and I want to migrate it.  
> **username_1**: I see. Note this won't work because as i put in my answer your use of CMS is invalid. If you pass it public key hashes it'll just fail at `VERIFY` and never get to execute `OP_3 OP_EQUAL`. :)  
> **username_0**: the public key hashes form the redeem script and in scriptSig I put Signature and and OP_3. the script works as you can see in testnet https://tbtc.bitaps.com/d3d661ec439baa845a22078b2ced81d346fe0fcd7c1e12f16980c87438d78961/input/0  
> **username_1**: The P2SH redeem script used in `d3d661ec439baa845a22078b2ced81d346fe0fcd7c1e12f16980c87438d78961`'s input uses public key with CMS, not public key hashes. Maybe you just made a typo in the OP?  
> **username_0**: oh! understand now! typo in comment :). Edited, thanks BTW: CMS stands for?  
> **username_0**: I updated my answer with your hint  
> **username_2**: CMS = op_CheckMultiSig  

---

