|
| 1 | +<pre> |
| 2 | + BIP: 381 |
| 3 | + Layer: Applications |
| 4 | + Title: Non-Segwit Output Script Descriptors |
| 5 | + Author: Pieter Wuille < [email protected]> |
| 6 | + |
| 7 | + Comments-Summary: No comments yet. |
| 8 | + Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0381 |
| 9 | + Status: Draft |
| 10 | + Type: Informational |
| 11 | + Created: 2021-06-27 |
| 12 | + License: BSD-2-Clause |
| 13 | +</pre> |
| 14 | + |
| 15 | +==Abstract== |
| 16 | + |
| 17 | +This document specifies <tt>pk()</tt>, <tt>pkh()</tt>, and <tt>sh()</tt> output script descriptors. |
| 18 | +<tt>pk()</tt> descriptors take a key and produces a P2PK output script. |
| 19 | +<tt>pkh()</tt> descriptors take a key and produces a P2PKH output script. |
| 20 | +<tt>sh()</tt> descriptors take a script and produces a P2SH output script. |
| 21 | + |
| 22 | +==Copyright== |
| 23 | + |
| 24 | +This BIP is licensed under the BSD 2-clause license. |
| 25 | + |
| 26 | +==Motivation== |
| 27 | + |
| 28 | +Prior to the activation of Segregated Witness, there were 3 main standard output script formats: P2PK, P2PKH, and P2SH. |
| 29 | +These expressions allow specifying those formats as a descriptor. |
| 30 | + |
| 31 | +==Specification== |
| 32 | + |
| 33 | +Three new script expressions are defined: <tt>pk()</tt>, <tt>pkh()</tt>, and <tt>sh()</tt>. |
| 34 | + |
| 35 | +===<tt>pk()</tt>=== |
| 36 | + |
| 37 | +The <tt>pk(KEY)</tt> expression can be used in any context or level of a descriptor. |
| 38 | +It takes a single key expression as an argument and produces a P2PK output script. |
| 39 | +Depending on the higher level descriptors, there may be restrictions on the type of public keys that can be included. |
| 40 | +Such restrictions will be specified by those descriptors. |
| 41 | + |
| 42 | +The output script produced is: |
| 43 | +<pre> |
| 44 | +<KEY> OP_CHECKSIG |
| 45 | +</pre> |
| 46 | + |
| 47 | +===<tt>pkh()</tt>=== |
| 48 | + |
| 49 | +The <tt>pkh(KEY)</tt> expression can be used as a top level expression, or inside of a <tt>sh()</tt> descriptor. |
| 50 | +It takes a single key expression as an argument and produces a P2PKH output script. |
| 51 | +Depending on the higher level descriptors, there may be restrictions on the type of public keys that can be included. |
| 52 | +Such restrictions will be specified by those descriptors. |
| 53 | + |
| 54 | +The output script produced is: |
| 55 | +<pre> |
| 56 | +OP_DUP OP_HASH160 <KEY_hash160> OP_EQUALVERIFY OP_CHECKSIG |
| 57 | +</pre> |
| 58 | + |
| 59 | +===<tt>sh()</tt>=== |
| 60 | + |
| 61 | +The <tt>sh(SCRIPT)</tt> expression can only be used as a top level expression. |
| 62 | +It takes a single script expression as an argument and produces a P2SH output script. |
| 63 | +<tt>sh()</tt> expressions also create a redeemScript which is required in order to spend outputs which use its output script. |
| 64 | +This redeemScript is the output script produced by the <tt>SCRIPT</tt> argument to <tt>sh()</tt>. |
| 65 | + |
| 66 | +The output script produced is: |
| 67 | +<pre> |
| 68 | +OP_HASH160 <SCRIPT_hash160> OP_EQUAL |
| 69 | +</pre> |
| 70 | + |
| 71 | +==Test Vectors== |
| 72 | + |
| 73 | +TBD |
| 74 | + |
| 75 | +==Backwards Compatibility== |
| 76 | + |
| 77 | +<tt>pk()</tt>, <tt>pkh()</tt>, and <tt>sh()</tt> descriptors use the format and general operation specified in [[bip-0380.mediawiki|380]]. |
| 78 | +As these are a wholly new descriptors, they are not compatible with any implementation. |
| 79 | +However the scripts produced are standard scripts so existing software are likely to be familiar with them. |
| 80 | + |
| 81 | +==Reference Implemntation== |
| 82 | + |
| 83 | +<tt>pk()</tt>, <tt>pkh()</tt>, and <tt>sh()</tt> descriptors have been implemented in Bitcoin Core since version 0.17. |
0 commit comments