BIP 0385: Difference between revisions

From Bitcoin Wiki
Jump to navigation Jump to search
934 (talk | contribs)
Update BIP text with latest version from https://github.com/bitcoin/bips/blob/4c6389f8431f6778/bip-0385.mediawiki
934 (talk | contribs)
Update BIP text with latest version from https://github.com/bitcoin/bips/blob/83a1afd985984862/bip-0385.mediawiki
 
(2 intermediate revisions by the same user not shown)
Line 7: Line 7:
   Title: raw() and addr() Output Script Descriptors
   Title: raw() and addr() Output Script Descriptors
   Author: Pieter Wuille <pieter@wuille.net>
   Author: Pieter Wuille <pieter@wuille.net>
           Andrew Chow <andrew@achow101.com>
           Ava Chow <me@achow101.com>
   Comments-Summary: No comments yet.
   Comments-Summary: No comments yet.
   Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0385
   Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0385
   Status: Draft
   Status: Final
   Type: Informational
   Type: Informational
   Created: 2021-06-27
   Created: 2021-06-27
Line 48: Line 48:
==Test Vectors==
==Test Vectors==


TBD
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==
==Backwards Compatibility==

Latest revision as of 19:26, 9 October 2024

This page describes a BIP (Bitcoin Improvement Proposal).
Please see BIP 2 for more information about BIPs and creating them. Please do not just create a wiki page.

Please do not modify this page. This is a mirror of the BIP from the source Git repository here.

  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: Final
  Type: Informational
  Created: 2021-06-27
  License: BSD-2-Clause

Abstract

This document specifies raw() and addr() output script descriptors. raw() encapsulates a raw script as a descriptor. addr() 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: raw() and addr().

raw()

The raw(HEX) 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 HEX.

addr()

The addr(ADDR) 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 ADDR.

Test Vectors

Valid descriptors followed by the scripts they produce.

  • raw(deadbeef)
    • deadbeef
  • raw(512103a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd4104a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea23552ae)
    • 512103a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd4104a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea23552ae
  • raw(a9149a4d9901d6af519b2a23d4a2f51650fcba87ce7b87)
    • a9149a4d9901d6af519b2a23d4a2f51650fcba87ce7b87
  • addr(3PUNyaW7M55oKWJ3kDukwk9bsKvryra15j)
    • a914eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee87

Invalid descriptors

  • Non-hex script: raw(asdf)
  • Invalid address: addr(asdf)
  • raw nested in sh: sh(raw(deadbeef))
  • raw nested in wsh: wsh(raw(deadbeef))
  • addr nested in sh: sh(addr(3PUNyaW7M55oKWJ3kDukwk9bsKvryra15j))
  • addr nested in wsh: wsh(addr(3PUNyaW7M55oKWJ3kDukwk9bsKvryra15j))

Backwards Compatibility

raw() and addr() descriptors use the format and general operation specified in 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

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