3

Output descriptors provide a standard to make address bodies more exchangeable between various wallet implementations. It seems that an output descriptor can be used to encode any Miniscript expression for one specific key. Can they also be used to produce a sequence output scripts that all use the same Miniscript expression applied to a chain of derived keys?

1 Answer 1

5

Yes. Such descriptors are referred to as ranged descriptors.

In a descriptor, keys are provided in the form of a Key expression. Key expressions can be individual keys themselves, or BIP 32 extended keys, followed by derivation information. The derivation information can end with a * to indicate that child keys should be derived. In that case, the descriptor is a ranged descriptor and each child key derived becomes a key in the output script.

If you then imagine the ranged descriptor like a higher form of an xpub, then you would have "derived descriptors" at each child index. Child index 0 would be a descriptor with everything the same as the parent except the xpubs. Those are replaced by the key derived at index 0. Index 1 has the keys derived at index 1, and so on.

One thing to note with ranged descriptors is that the indexes move in lockstep to avoid any combinatorial blowup. So if there are multiple xpubs in a descriptor, all of the keys are derived at the same child index. Index 0 has all keys derived using index 0, index 1 has all keys derived using index 1, etc.

3
  • I'm struggling to understand how Miniscript and Descriptors work together? Is the idea that I can replace A and B in the following script with an xpub? Original miniscript: and_v(v:pk(A),pk(B)) Miniscript with embedded descriptors: and_v(v:pk([b33.../44'/0'/0']xpubApf/1/*),pk([f34.../44'/0'/0']xpub6ER.../1/*))
    – max
    Nov 19, 2021 at 14:44
  • @max Descriptors are more than just the pubkeys. They are really the expressions sh(), multi(), tr(), wsh(), etc. Descriptors create the output scripts whereas Miniscript describes the inner scripts. For example, a descriptor would be wsh(and_v(v:pk(xpub..../*),pk(xpub.../*))). The descriptor is the outer wsh(...) expression and the miniscript is the inner and_v(v:pk(xpub..../*),pk(xpub.../*))
    – Ava Chow
    Nov 19, 2021 at 17:20
  • Thanks Andrew, I think I get it now. Descriptors are primarily for understanding what kind of address/output script to use, while miniscript is used to describe contractual logic.
    – max
    Nov 20, 2021 at 20:25

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.