<p>Your descriptor (including the Miniscript) is valid. I think you are getting this error because you used an <code>xpub</code> (mainnet encoding of an extended public key) on a testnet node.</p>
<p>On a mainnet node:</p>
<pre><code>$ bitcoin-cli getdescriptorinfo &quot;wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']xpub6EpqBFyJW2qiEmgcYZqwEGCRuQh3y9fY72RWeAG7pNvKJWgnx7mkviWtfsF7VNQhWPx43zzNfkWhoF8RcnP2KKsXbNHrFNdzx8MFy83N5Sq/0/*)))#925wgae2&quot;
{
  &quot;descriptor&quot;: &quot;wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']xpub6EpqBFyJW2qiEmgcYZqwEGCRuQh3y9fY72RWeAG7pNvKJWgnx7mkviWtfsF7VNQhWPx43zzNfkWhoF8RcnP2KKsXbNHrFNdzx8MFy83N5Sq/0/*)))#925wgae2&quot;,
  &quot;checksum&quot;: &quot;925wgae2&quot;,
  &quot;isrange&quot;: true,
  &quot;issolvable&quot;: false,
  &quot;hasprivatekeys&quot;: false
}
</code></pre>
<p>On a regtest node (converting the <code>xpub</code> to a <code>tpub</code>):</p>
<pre><code>$ bitcoin-cli -regtest getdescriptorinfo &quot;wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']tpubDFCThVnzDJoAWZsTzkq2SBXoEXnhxYAbef1oziKGAHgD3oMW2Lcr5ABiuuKu1sMwJJUxfaWFCrLkVRd31eEGCmKpey39vuJEY5wfj84sNhm/0/*)))#qxjqansp&quot;
{
  &quot;descriptor&quot;: &quot;wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']tpubDFCThVnzDJoAWZsTzkq2SBXoEXnhxYAbef1oziKGAHgD3oMW2Lcr5ABiuuKu1sMwJJUxfaWFCrLkVRd31eEGCmKpey39vuJEY5wfj84sNhm/0/*)))#qxjqansp&quot;,
  &quot;checksum&quot;: &quot;qxjqansp&quot;,
  &quot;isrange&quot;: true,
  &quot;issolvable&quot;: false,
  &quot;hasprivatekeys&quot;: false
}
</code></pre>

CC BY-SA 4.0
2023-05-03T14:13:00.020Z
This was absolutely the reason. Thank you Antoine!
francois
CC BY-SA 4.0
2023-04-29T10:28:06.540Z
2023-04-29T10:28:06.540Z
Antoine Poinsot
<p>I'm trying to play around with miniscript and import them into Bitcoin Core v24.0.1.
I created the following descriptor in <a href="https://miniscript.fun" rel="nofollow noreferrer">https://miniscript.fun</a>  and tried to validate it in Bitcoin Core</p>
<pre><code>bitcoin-cli getdescriptorinfo &quot;wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']xpub6EpqBFyJW2qiEmgcYZqwEGCRuQh3y9fY72RWeAG7pNvKJWgnx7mkviWtfsF7VNQhWPx43zzNfkWhoF8RcnP2KKsXbNHrFNdzx8MFy83N5Sq/0/*)))#925wgae2&quot;
</code></pre>
<p>However, I get the following error:</p>
<blockquote>
<p>A function is needed within P2WSH</p>
</blockquote>
<p>Where did I go wrong?</p>
<p>Thanks!</p>

<bitcoin-core><output-script-descriptors><miniscript>
Error when doing a getdescriptorinfo on a Miniscript descriptor (V24.0.1)
francois
# Error when doing a getdescriptorinfo on a Miniscript descriptor (V24.0.1)

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

I'm trying to play around with miniscript and import them into Bitcoin Core v24.0.1.
I created the following descriptor in https://miniscript.fun  and tried to validate it in Bitcoin Core
bitcoin-cli getdescriptorinfo "wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']xpub6EpqBFyJW2qiEmgcYZqwEGCRuQh3y9fY72RWeAG7pNvKJWgnx7mkviWtfsF7VNQhWPx43zzNfkWhoF8RcnP2KKsXbNHrFNdzx8MFy83N5Sq/0/*)))#925wgae2"

However, I get the following error:

A function is needed within P2WSH

Where did I go wrong?
Thanks!

**Tags:** bitcoin-core, output-script-descriptors, miniscript


---

## 1 answers

### Answer by username_1 on 2023-04-29. Score: 5 | Accepted answer

Your descriptor (including the Miniscript) is valid. I think you are getting this error because you used an xpub (mainnet encoding of an extended public key) on a testnet node.
On a mainnet node:
$ bitcoin-cli getdescriptorinfo "wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']xpub6EpqBFyJW2qiEmgcYZqwEGCRuQh3y9fY72RWeAG7pNvKJWgnx7mkviWtfsF7VNQhWPx43zzNfkWhoF8RcnP2KKsXbNHrFNdzx8MFy83N5Sq/0/*)))#925wgae2"
{
  "descriptor": "wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']xpub6EpqBFyJW2qiEmgcYZqwEGCRuQh3y9fY72RWeAG7pNvKJWgnx7mkviWtfsF7VNQhWPx43zzNfkWhoF8RcnP2KKsXbNHrFNdzx8MFy83N5Sq/0/*)))#925wgae2",
  "checksum": "925wgae2",
  "isrange": true,
  "issolvable": false,
  "hasprivatekeys": false
}

On a regtest node (converting the xpub to a tpub):
$ bitcoin-cli -regtest getdescriptorinfo "wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']tpubDFCThVnzDJoAWZsTzkq2SBXoEXnhxYAbef1oziKGAHgD3oMW2Lcr5ABiuuKu1sMwJJUxfaWFCrLkVRd31eEGCmKpey39vuJEY5wfj84sNhm/0/*)))#qxjqansp"
{
  "descriptor": "wsh(thresh(2,nl:older(12960),s:pk(038b4059419fe3b95acdee6aff2f9afdca87231d14bd2cbcd3367b11d9d819a71d),s:pk([c893176c/48'/0'/0'/2']tpubDFCThVnzDJoAWZsTzkq2SBXoEXnhxYAbef1oziKGAHgD3oMW2Lcr5ABiuuKu1sMwJJUxfaWFCrLkVRd31eEGCmKpey39vuJEY5wfj84sNhm/0/*)))#qxjqansp",
  "checksum": "qxjqansp",
  "isrange": true,
  "issolvable": false,
  "hasprivatekeys": false
}

> **Comments:**
> **username_0**: This was absolutely the reason. Thank you Antoine!  

---

