-
Notifications
You must be signed in to change notification settings - Fork 5.6k
BIP draft: Raw() as subscript for descriptors #1721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
furszy
wants to merge
1
commit into
bitcoin:master
Choose a base branch
from
furszy:2024_descriptors_raw_as_subscript
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<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: Standards Track | ||
Created: ? | ||
License: BSD-2-Clause | ||
</pre> | ||
|
||
==Abstract== | ||
|
||
This document specifies `raw()` as subscript for output script descriptors. | ||
`raw()` encapsulates a raw hex script. This BIP allows `raw()` 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 representation of currently | ||
inexpressible information in 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 [here](https://github.com/bitcoin/bitcoin/issues/24114#issuecomment-1127978154), | ||
there are other useful scenarios for this feature. For example, it allows representing | ||
in a descriptor that we lack complete knowledge of all solvability paths but can still | ||
solve the output. This includes cases like a taproot tree where we know only one of its | ||
paths. Or, participating in signing a script without knowing all participants' keys, | ||
relying solely on the script structure. | ||
|
||
==Specification== | ||
|
||
### For `sh()` and `wsh()` descriptors: | ||
`raw(HEX)` must represent the arbitrary script data within the provided context. | ||
This for example means that a P2SH output script (OP_HASH160 <hash160(HEX_script)> OP_EQUAL) | ||
must be created from the provided hex data when a `sh(raw(HEX))` descriptor is provided. | ||
|
||
Parallelly, a P2WSH output script (OP_0 <hash160(HEX_script)>) must be created from the provided | ||
hex data when a `wsh(raw(HEX))` descriptor is provided. | ||
|
||
### For `tr(KEY, TREE)` descriptors: | ||
Two new fragments are allowed within the taproot `TREE` context: `rawnode(HEX)` and `raw(HEX)`. | ||
|
||
#### `rawnode(HEX)`: | ||
Indicating a tree node with specified 32-bit hash, but no specified subtree. | ||
This can serve as either a tree branch or the root of the Merkle tree. | ||
|
||
#### `raw(HEX)`: | ||
Defines a tree leaf containing the specified script in hex. | ||
Note: The leaf version must be internally fixed at the existing `0xC0` to prevent introducing | ||
unsupported or undefined functionality. | ||
If a different version is required for any use case, a new BIP could introduce `raw(HEX, VERSION)` | ||
in the future. | ||
Comment on lines
+63
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should just support |
||
|
||
==Test Vectors== | ||
|
||
Valid descriptors followed by the scripts they produce. | ||
|
||
* `sh(raw(5387))` | ||
** `a9149e02f205612b4d7fe9466a789764b0eafe7eb07287` | ||
* `sh(wsh(raw(5387)))` | ||
** `a9140d1a6a9fd7e20b6e4091e2c10284fb1130afd46787` | ||
* `wsh(raw(5387))` | ||
** `00205c5fc1afc3d712a8e8602cee8590234ab2213be58943fca65436439f08017a64` | ||
# TODO: Complete examples: | ||
1) tr(key, rawnode()) | ||
2) tr(key, {pk(), raw()}) | ||
3) tr(key, {pk(), rawnode()}) | ||
4) tr(key, {pk(), sortedmulti_a(2,key1,key2,raw())}) | ||
5) tr(key, {pk(raw())}) | ||
|
||
Invalid descriptors | ||
|
||
* Non-hex script: `sh(raw(asdf))` | ||
* Non 32-bit hash in `rawnode`: `tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd, rawnode(kjke))` | ||
* Non-hex in `rawnode`: `tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd, rawnode(<complete me with a 32-bit non-hex hash>))` | ||
* `raw` in the key path `tr`: `tr(raw(asdf), pk(key))` | ||
|
||
==Backwards Compatibility== | ||
|
||
`raw()` as 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.. | ||
|
||
==Acknowledgements== | ||
|
||
Thanks to Pieter Wuille who came up with the original idea (https://github.com/bitcoin/bitcoin/issues/24114) and brainstorming support. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit unclear for me, can you clarify what do you mean by can still solve the output?