Add tr() descriptor (derivation only, no signing)

This adds a new descriptor with syntax e.g. tr(KEY,{S1,{{S2,S3},S4})
where KEY is a key expression for the internal key and S_i are
script expression for the leaves. They have to be organized in
nested {A,B} groups, with exactly two elements.

tr() only exists at the top level, and inside the script expressions
only pk() scripts are allowed for now.
This commit is contained in:
Pieter Wuille
2021-02-07 19:18:39 -08:00
parent 90fcac365e
commit 7cedafc541
4 changed files with 163 additions and 15 deletions

View File

@@ -34,11 +34,11 @@ Span<const char> Expr(Span<const char>& sp)
int level = 0;
auto it = sp.begin();
while (it != sp.end()) {
if (*it == '(') {
if (*it == '(' || *it == '{') {
++level;
} else if (level && *it == ')') {
} else if (level && (*it == ')' || *it == '}')) {
--level;
} else if (level == 0 && (*it == ')' || *it == ',')) {
} else if (level == 0 && (*it == ')' || *it == '}' || *it == ',')) {
break;
}
++it;