Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/ctest/test_descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2490,6 +2490,44 @@ static const descriptor_test g_descriptor_cases[] = {
"descriptor errchk - uncompressed binding key",
"ct(uncompressed,elwpkh(key_4))",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, 0, NULL, "", VARS_STD
}, {
/* Only the outermost expression (or ct() script) has the el prefix */
"descriptor errchk - el prefix on a nested descriptor",
"elsh(elwpkh(key_1))",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, 0, NULL, "", VARS_STD
}, {
"descriptor errchk - el prefix on a nested miniscript",
"wsh(elpk(key_1))",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, 0, NULL, "", VARS_STD
}, {
"descriptor errchk - el prefix on both expressions",
"elwsh(elpk(key_1))",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, 0, NULL, "", VARS_STD
}, {
"descriptor errchk - el prefix on a tapscript leaf",
"eltr(key_1,elpk(key_1))",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, 0, NULL, "", VARS_STD
}, {
"descriptor errchk - el prefix on a nested ct() descriptor",
"ct(slip77(slip77_key),elsh(elwpkh(key_1)))",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, 0, NULL, "", VARS_STD
}, {
/* ct() and its blinding key are not script expressions */
"descriptor errchk - el prefix on ct()",
"elct(slip77(slip77_key),elwpkh(key_1))",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, 0, NULL, "", VARS_STD
}, {
"descriptor errchk - el prefix on slip77()",
"ct(elslip77(slip77_key),elwpkh(key_1))",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, 0, NULL, "", VARS_STD
}, {
"descriptor errchk - el prefix after a wrapper",
"c:elpk_k(key_1)",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, 0, NULL, "", VARS_STD
}, {
"miniscript errchk - el prefix",
"elpk(key_1)",
WALLY_NETWORK_LIQUID, 0, 0, 0, NULL, WALLY_MINISCRIPT_ONLY, NULL, "", VARS_STD
}
/* Elements/Confidential wallet policy error cases */
, {
Expand Down
12 changes: 12 additions & 0 deletions src/descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -3256,6 +3256,18 @@ static int analyze_miniscript(ms_ctx *ctx, const char *str, size_t str_len,
/* Not a pure descriptor */
ctx->features &= ~WALLY_MS_IS_DESCRIPTOR;
}
if (builtin_is_elements(str + offset, i - offset) &&
((parent && parent->kind != KIND_DESCRIPTOR_CT) ||
node->kind == KIND_DESCRIPTOR_CT ||
node->kind == KIND_DESCRIPTOR_SLIP77 ||
node->wrapper_str[0] || !(kind & KIND_DESCRIPTOR))) {
/* Only the outermost script expression of a descriptor
* can be prefixed, e.g. elsh(wpkh()) or ct(k,elsh(wpkh())),
* but not elsh(elwpkh()), elct(), ct(elslip77(k),wpkh()),
* c:elpk_k() or a miniscript-only expression */
ret = WALLY_EINVAL;
break;
}
if (builtin_is_elements(str + offset, i - offset) ||
node->kind == KIND_DESCRIPTOR_CT) {
/* ct() is Elements-only: treat its descriptor as Elements
Expand Down
Loading