From 3c294e0800450784f5955d0edf2c041fd57959cd Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Wed, 12 Mar 2025 00:00:13 +1300 Subject: [PATCH 1/2] descriptor: allow U type children for thresh() expressions The reference implementation at https://bitcoin.sipa.be/miniscript/ allows these as shown in the upcoming test case. --- src/descriptor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/descriptor.c b/src/descriptor.c index 23cf186a6..0e68a8301 100644 --- a/src/descriptor.c +++ b/src/descriptor.c @@ -962,7 +962,7 @@ static int verify_thresh(ms_ctx *ctx, ms_node *node) for (child = top->next; child; child = child->next) { const uint32_t expected_type = count ? TYPE_W : TYPE_B; - if (!child->builtin || (~child->type_properties & (expected_type | PROP_D | PROP_U))) + if (!child->builtin || (~child->type_properties & (expected_type | PROP_D))) return WALLY_EINVAL; if (~child->type_properties & PROP_E) From fde2ab19726a352d2027c6f9775c621200e1a49c Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Wed, 12 Mar 2025 00:04:13 +1300 Subject: [PATCH 2/2] add a test for thresh/U children from the reference impl --- src/ctest/test_descriptor.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ctest/test_descriptor.c b/src/ctest/test_descriptor.c index ccc966b03..65199eed3 100644 --- a/src/ctest/test_descriptor.c +++ b/src/ctest/test_descriptor.c @@ -511,6 +511,16 @@ static const struct descriptor_test { "02d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e", "ks05yr6p" }, + /* + * Miniscript: https://bitcoin.sipa.be/miniscript/ + */ + { + "miniscript - A 3-of-3 that turns into a 2-of-3 after 90 days", + "thresh(3,pk(key_1),s:pk(key_2),s:pk(key_3),sln:older(12960))", + WALLY_NETWORK_NONE, 0, 0, 0, NULL, WALLY_MINISCRIPT_ONLY, + "21038bc7431d9285a064b0328b6333f3a20b86664437b6de8f4e26e6bbdee258f048ac7c2103a22745365f673e658f0d25eb0afa9aaece858c6a48dfe37a67210c2e23da8ce7ac937c2103b428da420cd337c7208ed42c5331ebb407bb59ffbe3dc27936a227c619804284ac937c63006702a032b29268935387", + "2sw64huw" + }, /* * Miniscript: Randomly generated test set that covers the majority of type and node type combinations */