Fixing count_m variable use: a non-regression unit test
What changed, and why it matters
This commit only adds a new unit test to the Ledger Bitcoin app. It does not change any production code. The test checks that a specific type of Bitcoin Miniscript expression is correctly classified as not 'non-malleable' (NONMAL). Because no actual wallet or signing logic is modified, this change by itself does not introduce or fix a live security vulnerability.
No immediate action is required for this commit alone. If reviewing a related series, locate the companion commit that changes the production Miniscript type-checking code and assess whether the 'count_m' fix correctly enforces non-malleability for thresh expressions.
Security signals we found
Regression test added for Miniscript 'm' (non-malleable) property handling
Commit message references 'count_m variable use', suggesting a prior/related logic fix
No production code changes in the supplied diff
Evidence from the diff
The diff adds one regression test case in unit-tests/test_wallet.c inside test_miniscript_types. The test verifies that thresh(1,or_b(sha256(…),a:sha256(…)),a:0) is parsed as TESTMODE_VALID but not as TESTMODE_NONMAL. The commit message frames this as ‘Fixing count_m variable use: a non-regression unit test’, implying a prior or accompanying fix to the production Miniscript type-checking logic (likely around the ‘m’ property count). However, only the test file is changed in this commit, so the actual logic fix is not visible here.
Changed components
unit-tests/test_wallet.cMiniscript type-checking / thresh expression handling (referenced but not modified in diff)Inspect captured patch +4 / −0
diff --git a/unit-tests/test_wallet.c b/unit-tests/test_wallet.c
index 39c30c9..0e5a30a 100644
--- a/unit-tests/test_wallet.c
+++ b/unit-tests/test_wallet.c
@@ -669,6 +669,10 @@ static void test_miniscript_types(void **state) {
// Since 'd:' is 'u' we can use it directly inside a thresh. But we can't under P2WSH.
Test("thresh(2,dv:older(42),s:pk(@0/**),s:pk(@1/**))", "7663012ab269687c205cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bcac937c20d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65ac935287", TESTMODE_VALID | TESTMODE_NONMAL | TESTMODE_NEEDSIG | TESTMODE_P2WSH_INVALID, 12, 4);
+ // Regression test: thresh 'm' (non-malleable) must require all children to have 'm'.
+ // or_b(sha256,a:sha256) has e=1 but m=0 (children lack 's'), so thresh must NOT be NONMAL.
+ Test("thresh(1,or_b(sha256(e38990d0c7fc009880a9c07c23842e886c6bbdc964ce6bdd5817ad357335ee6f),a:sha256(d1ec675902ef1633427ca360b290b0b3045a0d9058ddb5e648b4c3c3224c5c68)),a:0)", "?", TESTMODE_VALID, -1, -1);
+
// clang-format on
}
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.