5

Can output descriptors be used to describe an arbitrary script?

Say I had a script something like the following:

OP_IF
  1737417600 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_DUP OP_HASH160 <pubKeyHashD> OP_EQUALVERIFY OP_CHECKSIG
OP_ELSE
  2 <PubKeyA> <PubKeyB> <PubKeyC> 3 OP_CHECKMULTISIG
OP_ENDIF

That's a two-branch script that either allows a 2-of-3 multisig or a single-address retrieval after a set amount of time. Is there a way to convert that into descriptor that I could then use to derive addresses?

wsh seems focused on set types of scripts, while trying raw on a 32-bit hash of a script gives me Descriptor does not have a corresponding address.

1 Answer 1

5

Output script descriptors do not currently support any arbitrary script. However once extended by Miniscript, descriptors will be able to support any script logically. Minscript is an extension of descriptors which allows for arbitrary scripts, within certain parameters. While you cannot specify any arbitrary script, you can use Minscript to create an arbitrary script that does what you want. This will not necessarily be the same as an arbitrary script that you come up with, but it will be logically identical.


As of October 2023, Miniscript is becoming more widely used. Under P2WSH, you can import Miniscript descriptors in watchonly mode on Bitcoin Core since version 24.0.1 and sign for them since version 25. The upcoming version 26 will support Miniscript under Tapscript (ie within Taproot descriptors).

1
  • Thanks, Andrew! I'd seen that the functionality looked possible in miniscript, I appreciate the pointer that it's the way to go.
    – Shannon A.
    Commented May 26, 2021 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.