Skip to content

Commit

Permalink
Raw() as subscript for descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Dec 18, 2024
1 parent 671c462 commit 1b3ef5c
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions bip-0391.mediawiki
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<pre>
BIP: ???
Layer: Applications
Title: raw() as subscript in Output Script Descriptors
Author: Matias Furszyfer [email protected]
Comments-Summary: No comments yet.
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-???
Status: Draft
Type: Informational
Created: 2024-12-16
License: BSD-2-Clause
</pre>

==Abstract==

This document specifies <tt>raw()</tt> as subscript for output script descriptors.
<tt>raw()</tt> encapsulates a raw hex script. This BIP allows <tt>raw()</tt> to be used in
the context of other descriptors.

==Copyright==

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

==Motivation==

Allowing arbitrary hex data to be wrapped in sh(), wsh(), or even within the TREE argument
of a tr(KEY, TREE) descriptor enables the expression of information that is currently
inexpressible by the descriptors' language.

Specifically, the absence of this feature limits the representation of non-standard redeem
and witness scripts. This occurs because they can currently only be represented as top-level
raw(HEX) descriptors, which retain only the output script information and lack the ability
to preserve the actual script.

Additionally, as noted [https://github.com/bitcoin/bitcoin/issues/24114#issuecomment-1127978154 here],
there are other useful scenarios for this feature. For example, it allows representing
in a descriptor that we lack full knowledge of all solvability paths but can still solve
the output, such as a taproot tree where we know only one of its paths, or even also
participating in signing a script without knowing all participants' keys, relying solely
on the script structure.

==Specification==

Allow raw(HEX) to be accepted within the context of sh(), wsh() and tr() descriptors.
The output script produced by this descriptor must represent the arbitrary data within
the provided context. For example, a P2SH output script (OP_HASH160 <hash160(script)> OP_EQUAL)
must be created from the provided hex data when a sh(raw(HEX)) descriptor is provided.

==Test Vectors==

Valid descriptors followed by the scripts they produce.

* <tt>sh(raw(5387))</tt>
** <tt>a9149e02f205612b4d7fe9466a789764b0eafe7eb07287</tt>
* <tt>sh(wsh(raw(5387)))</tt>
** <tt>a9140d1a6a9fd7e20b6e4091e2c10284fb1130afd46787</tt>
* <tt>wsh(raw(5387))</tt>
** <tt>00205c5fc1afc3d712a8e8602cee8590234ab2213be58943fca65436439f08017a64</tt>
* <tt>tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,raw(5387))</tt>
** <tt>51206f108fa13b6f1cdd89d8de731712e2357e3b833f1959c0a93c26127c3a6264bb</tt>
* <tt>tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,{pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5),raw(%s)})</tt>
** <tt>51206f4954bd11741938d74e744be6b6fa87076660696ddfa3c41c1f834906e17c8e</tt>
Invalid descriptors

* Non-hex script: <tt>sh(raw(asdf))</tt>
* <tt>raw</tt> in the key path <tt>tr</tt>: <tt>tr(raw(5387), pk(key))</tt>
==Backwards Compatibility==

<tt>raw()</tt> as a subscript 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.

==Reference Implementation==

# TODO: add Bitcoin-Core PR..

0 comments on commit 1b3ef5c

Please sign in to comment.