summaryrefslogtreecommitdiff
path: root/bip-0385.mediawiki
blob: 3e922b3bd1850abbf1f1ea23ad1fdab60a5fee11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<pre>
  BIP: 385
  Layer: Applications
  Title: raw() and addr() Output Script Descriptors
  Author: Pieter Wuille <pieter@wuille.net>
          Ava Chow <me@achow101.com>
  Comments-Summary: No comments yet.
  Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0385
  Status: Draft
  Type: Informational
  Created: 2021-06-27
  License: BSD-2-Clause
</pre>

==Abstract==

This document specifies <tt>raw()</tt> and <tt>addr()</tt> output script descriptors.
<tt>raw()</tt> encapsulates a raw script as a descriptor.
<tt>addr()</tt> encapsulates an address as a descriptor.

==Copyright==

This BIP is licensed under the BSD 2-clause license.

==Motivation==

In order to make descriptors maximally compatible with scripts in use today, it is useful to be able to wrap any arbitrary output script or an address into a descriptor.

==Specification==

Two new script expressions are defined: <tt>raw()</tt> and <tt>addr()</tt>.

===<tt>raw()</tt>===

The <tt>raw(HEX)</tt> expression can only be used as a top level descriptor.
As the argument, it takes a hex string representing a Bitcoin script.
The output script produced by this descriptor is the script represented by <tt>HEX</tt>.

===<tt>addr()</tt>===

The <tt>addr(ADDR)</tt> expression can only be used as a top level descriptor.
It takes an address as its single argument.
The output script produced by this descriptor is the output script produced by the address <tt>ADDR</tt>.

==Test Vectors==

Valid descriptors followed by the scripts they produce.

* <tt>raw(deadbeef)</tt>
** <tt>deadbeef</tt>
* <tt>raw(512103a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd4104a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea23552ae)</tt>
** <tt>512103a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd4104a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea23552ae</tt>
* <tt>raw(a9149a4d9901d6af519b2a23d4a2f51650fcba87ce7b87)</tt>
** <tt>a9149a4d9901d6af519b2a23d4a2f51650fcba87ce7b87</tt>
* <tt>addr(3PUNyaW7M55oKWJ3kDukwk9bsKvryra15j)</tt>
** <tt>a914eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee87</tt>

Invalid descriptors

* Non-hex script: <tt>raw(asdf)</tt>
* Invalid address: <tt>addr(asdf)</tt>
* <tt>raw</tt> nested in <tt>sh</tt>: <tt>sh(raw(deadbeef))</tt>
* <tt>raw</tt> nested in <tt>wsh</tt>: <tt>wsh(raw(deadbeef))</tt>
* <tt>addr</tt> nested in <tt>sh</tt>: <tt>sh(addr(3PUNyaW7M55oKWJ3kDukwk9bsKvryra15j))</tt>
* <tt>addr</tt> nested in <tt>wsh</tt>: <tt>wsh(addr(3PUNyaW7M55oKWJ3kDukwk9bsKvryra15j))</tt>

==Backwards Compatibility==

<tt>raw()</tt> and <tt>addr()</tt> descriptors use the format and general operation specified in [[bip-0380.mediawiki|380]].
As this is a wholly new descriptor, it is not compatible with any implementation.
The reuse of existing Bitcoin addresses allows for this to be more easily implemented.

==Reference Implementation==

<tt>raw()</tt> and <tt>addr()</tt> descriptors have been implemented in Bitcoin Core since version 0.17.