What changed, and why it matters
This commit only changes a test file so that btcd's internal test suite correctly reads the latest Bitcoin Core reference test vectors. It does not alter any production transaction-validation code, consensus rules, or network-facing behavior. There is no security issue here.
No action required. This is a test-harness maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff updates txscript/reference_test.go to add a new helper parseTxValidTestFlags() and a constant allScriptFlags. Bitcoin Core’s tx_valid.json format changed from listing flags to enable to listing flags to exclude; this commit makes btcd’s test harness interpret the new format. The production parseScriptFlags() is unchanged, and the only call site affected is TestTxValidTests.
Changed components
txscript/reference_test.goInspect captured patch +35 / −1
diff --git a/txscript/reference_test.go b/txscript/reference_test.go
index 67930b7..9f421f0 100644
--- a/txscript/reference_test.go
+++ b/txscript/reference_test.go
@@ -30,6 +30,29 @@ const (
scriptTestCommentOffset
)
+// allScriptFlags is the set of all currently defined script flags.
+const allScriptFlags = ScriptBip16 |
+ ScriptStrictMultiSig |
+ ScriptDiscourageUpgradableNops |
+ ScriptVerifyCheckLockTimeVerify |
+ ScriptVerifyCheckSequenceVerify |
+ ScriptVerifyCleanStack |
+ ScriptVerifyDERSignatures |
+ ScriptVerifyLowS |
+ ScriptVerifyMinimalData |
+ ScriptVerifyNullFail |
+ ScriptVerifySigPushOnly |
+ ScriptVerifyStrictEncoding |
+ ScriptVerifyWitness |
+ ScriptVerifyDiscourageUpgradeableWitnessProgram |
+ ScriptVerifyMinimalIf |
+ ScriptVerifyWitnessPubKeyType |
+ ScriptVerifyTaproot |
+ ScriptVerifyDiscourageUpgradeableTaprootVersion |
+ ScriptVerifyDiscourageOpSuccess |
+ ScriptVerifyDiscourageUpgradeablePubkeyType |
+ ScriptVerifyConstScriptCode
+
// scriptTestWitnessOffset returns the field offset caused by optional witness
// data at the beginning of a script_tests.json entry.
func scriptTestWitnessOffset(test []interface{}) int {
@@ -229,6 +252,17 @@ func parseScriptFlags(flagStr string) (ScriptFlags, error) {
return flags, nil
}
+// parseTxValidTestFlags parses the tx_valid flag field. Modern Bitcoin Core
+// tx_valid vectors encode flags to exclude from the full set of script flags.
+func parseTxValidTestFlags(flagStr string) (ScriptFlags, error) {
+ excluded, err := parseScriptFlags(flagStr)
+ if err != nil {
+ return 0, err
+ }
+
+ return allScriptFlags &^ excluded, nil
+}
+
// hasTaprootScriptTest returns whether the reference script test is one of the
// newer taproot cases embedded in script_tests.json. Those vectors rely on
// Bitcoin Core-specific placeholder macros, while btcd covers taproot via the
@@ -790,7 +824,7 @@ testloop:
continue
}
- flags, err := parseScriptFlags(verifyFlags)
+ flags, err := parseTxValidTestFlags(verifyFlags)
if err != nil {
t.Errorf("bad test %d: %v", i, err)
continue
Why this scored 15/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.