1
0
mirror of https://github.com/bitcoin/bips.git synced 2024-11-19 01:40:05 +01:00

BIP88: use <code> tags more, instead of double quotes

This commit is contained in:
Dmitry Petukhov 2021-05-16 12:41:40 +05:00
parent 01679c8f29
commit b628a13e21
No known key found for this signature in database
GPG Key ID: 2301D26BDC15160D

View File

@ -91,17 +91,17 @@ installation of malicious or incorrect profiles, though.
The format for the template was choosen to make it easy to read, convenient and visually unambigous.
Template starts with optional prefix "m/", and then one or more sections delimited by the slash character (<code>/</code>).
Template starts with optional prefix <code>m/</code>, and then one or more sections delimited by the slash character (<code>/</code>).
Implementations MAY limit the maximum number of sections.
Each section consists of ''index template'', optionally followed by the hardened marker: either an apostrophe (<code>'</code>) or letter "h".
Each section consists of ''index template'', optionally followed by the hardened marker: either an apostrophe (<code>'</code>) or letter <code>h</code>.
Index template can be:
* An integer value from 0 to 2147483647 ("Unit index template")
* A single "*" character, which denotes any value from 0 to 2147483647 ("Wildcard index template")
* The <nowiki>"{"</nowiki> character, followed by a number of ''index ranges'' delimited by commas (<code>,</code>), followed by <nowiki>"}"</nowiki> character ("Ranged index template")
* A single <code>*</code> character, which denotes any value from 0 to 2147483647 ("Wildcard index template")
* The <code>{</code> character, followed by a number of ''index ranges'' delimited by commas (<code>,</code>), followed by <code>}</code> character ("Ranged index template")
Implementations MAY limit the maximum number of index ranges within the Ranged index template.
@ -110,9 +110,9 @@ If an index template is immediately followed by hardened marker, this means that
Index range can be:
* An integer value from 0 to 2147483647 ("Unit range")
* An integer value from 0 to 2147483647, followed by the "-" character, followed by another integer value from 0 to 2147483647 ("Non-unit range")
* An integer value from 0 to 2147483647, followed by the <code>-</code> character, followed by another integer value from 0 to 2147483647 ("Non-unit range")
For Non-unit range, value on the left side of the "-" character is the range_start, and the value on the right side of the "-" character is the range_end.
For Non-unit range, value on the left side of the <code>-</code> character is the range_start, and the value on the right side of the <code>-</code> character is the range_end.
For Unit range, we say that range_start is equal to range_end, even though there is no start/end in the Unit range.
@ -128,16 +128,16 @@ Constraints:
# To avoid ambiguity, an index range <code>0-2147483647</code> is not allowed, and MUST be specified as Wildcard index template instead
# For Non-unit range, range_end MUST be larger than range_start.
# If there is more than one index range within the Ranged index template, range_start of the second and any subsequent range MUST be larger than the range_end of the preceeding range.
# To avoid ambiguity, all representations of integer values larger than 0 MUST NOT start with character "0" (no leading zeroes allowed).
# To avoid ambiguity, all representations of integer values larger than 0 MUST NOT start with character <code>0</code> (no leading zeroes allowed).
# If hardened marker appears within any section in the path template, all preceding sections MUST also specify hardened matching.
# To avoid ambiguity, if a hardened marker appears within any section in the path template, all preceding sections MUST also use the same hardened marker (either <code>h</code> or <code>'</code>).
# To avoid ambiguity, trailing slashes (for example, "1/2/") and duplicate slashes (for example, "0//1") MUST NOT appear in the template.
# To avoid ambiguity, trailing slashes (for example, <code>1/2/</code>) and duplicate slashes (for example, <code>0//1</code>) MUST NOT appear in the template.
It may be desireable to have fully unambiguous encoding, where for each valid path template string, there is no other valid template string that matches the exact same set of paths. This would enable someone to compare templates for equality through a simple string equality check, without any parsing.
To achieve this, two extra rules are needed:
* Within Ranged index template, subsequent range MUST NOT start with the value that is equal to the end of the previous range plus one. Thus, <nowiki>"{1,2,3-5}"</nowiki> is not allowed, and should be specified as <nowiki>"{1-5}"</nowiki> instead. This rule might make templates less convenient for frequent edits, though.
* Within Ranged index template, subsequent range MUST NOT start with the value that is equal to the end of the previous range plus one. Thus, <code>{1,2,3-5}</code> is not allowed, and should be specified as <code>{1-5}</code> instead. This rule might make templates less convenient for frequent edits, though.
* Only one type of hardened marker should be allowed (either <code>h</code> or <code>'</code>).
@ -145,9 +145,9 @@ Instead of requiring the second extra rule, implementations can simply replace o
==Full and partial templates==
If the template starts with "m/", that means that this is the "full" template, that matches the whole path.
If the template starts with <code>m/</code>, that means that this is the "full" template, that matches the whole path.
If the template does not start with "m/", that means that this is a "partial" template, and it can be used to match a part of the path, in the contexts where this might be appropriate (for example, when constraints for the suffix of the path might be dynamic, while constraints for the prefix of the path are fixed).
If the template does not start with <code>m/</code>, that means that this is a "partial" template, and it can be used to match a part of the path, in the contexts where this might be appropriate (for example, when constraints for the suffix of the path might be dynamic, while constraints for the prefix of the path are fixed).
Full template can be combined with partial template, where partial template extends full template,
resulting in new, longer full template.
@ -205,11 +205,11 @@ The full path template that only contains Unit index templates represents a full
There's no other path template standards that is known to the author currently.
There is a discussion on path templating for bitcoin script descriptors at https://github.com/bitcoin/bitcoin/issues/17190, which proposes the format '''"xpub...{0,1}/*"''', of which the '''"{0,1}/*"''' part would correspond to the partial path template in the format of this BIP.
There is a discussion on path templating for bitcoin script descriptors at https://github.com/bitcoin/bitcoin/issues/17190, which proposes the format <code>xpub...{0,1}/*</code>, of which the <code>{0,1}/*</code> part would correspond to the partial path template in the format of this BIP.
==Examples==
'''"m/{44,49,84}'/0'/0'/{0-1}/{0-50000}"''' specifies a full template that matches both external and internal chains of BIP44, BIP49 and BIP84 paths, with a constraint that the address index cannot be larger than 50000
<code>m/{44,49,84}'/0'/0'/{0-1}/{0-50000}</code> specifies a full template that matches both external and internal chains of BIP44, BIP49 and BIP84 paths, with a constraint that the address index cannot be larger than 50000
Its representation after parsing can be (using Python syntax, ignoring full/partial distinction):
[[(2147483692, 2147483692), (2147483697, 2147483697), (2147483732, 2147483732)),
@ -218,12 +218,12 @@ Its representation after parsing can be (using Python syntax, ignoring full/part
[(0, 1)],
[(0, 50000)]]
'''"{0-2,33,123}/*"''' specifies a partial template that matches non-hardened values 0, 1, 2, 33, 123 as first index, and any non-hardened value at second index
<code>{0-2,33,123}/*</code> specifies a partial template that matches non-hardened values 0, 1, 2, 33, 123 as first index, and any non-hardened value at second index
Its representation after parsing can be:
[[(0, 2), (33, 33), (123, 123)], [(0, 2147483647)]]
'''"*h/0"''' specifies a partial template that matches any hardened index followed by any non-hardened index
<code>*h/0</code> specifies a partial template that matches any hardened index followed by any non-hardened index
Its representation after parsing can be:
[[(2147483648, 4294967295)], [(0, 0)]]