BIP Proposals for Output Script Descriptors



Summary:

Bitcoin Core has introduced seven BIPs to formalize its Output Script Descriptors, with one describing descriptors in general and the remaining six specifying actual descriptors. The purpose of this separation is to make it easier for implementers to select which descriptors they want to support without making it too complex to comprehend. These descriptors provide a generic solution to problems in Bitcoin wallets by allowing script types to be explicitly specified through Script Expressions and key derivation paths explicitly in Key Expressions.Traditional Bitcoin wallets store a set of keys that are later serialized and mutated to produce output scripts. However, this approach is insufficient for restored wallets to know which kinds of output scripts and addresses to produce. The use of common terminology and existing standards allows for Output Script Descriptors to be engineer-readable so that the results can be understood at a glance.The first BIP specifies the general operation, key expressions, and the descriptor checksum, while the other six specify non-segwit descriptor (pk, pkh, sh), segwit descriptors (wpkh, wsh), multisig descriptors (multi, sortedmulti), the taproot descriptor (tr), the combo descriptor, and opaque descriptors (raw, addr).The wpkh() and wsh() output script descriptors have been specified in this document, which allows for the specification of P2WPKH and P2WSH formats as a descriptor. Only keys with compressed public keys can be contained in a wpkh() expression. Any key expression found in any script expression contained by a wsh() expression must only produce compressed public keys.This document also specifies the non-segwit output script descriptors pk(), pkh(), and sh(). The pk() expression takes a key and produces a P2PK output script. The pkh() expression takes a key and produces a P2PKH output script. The sh() expression takes a script and produces a P2SH output script. The tr() expression specifies tr() output script descriptors which take a key and optionally a tree of scripts, producing a P2TR output script. All key expressions under any tr() expression must create x-only public keys.Output script descriptors for multi(), and sortedmulti() have also been specified in this document, with both functions taking a threshold and one or more public keys to produce a multisig output script. Combo() output script descriptors are specified to produce P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH output scripts if applicable to the key. Raw() and addr() output script descriptors are also specified to encapsulate a raw script or an address as a descriptor.All these descriptors have been implemented in Bitcoin Core since version 0.17, except for tr() expressions which have been implemented since version 22.0. Valid descriptor strings with a checksum must pass the criteria for validity specified by the Python3 code snippet provided in the context. Future BIPs may specify script expressions that can be used in tree expressions, defined using the format and general operation specified in bip-descriptor-general.mediawiki. They are not compatible with any implementation, but the scripts produced are standard scripts so existing software is likely to be familiar with them.


Updated on: 2023-05-21T02:57:39.444754+00:00