#35788 bitcoin-util: Add evalscript subcommand

full analysis

https://github.com/bitcoin/bitcoin/pull/35788 · ajtowns · +560/-17 in 13 files, 4 commits · labels: none

Goal

  • Let script developers evaluate isolated script fragments offline using node consensus rules
  • Avoids needing to construct full transactions in test harnesses to debug scripts

Adds an evalscript subcommand to bitcoin-util for executing Bitcoin script fragments and validating transactions directly using the consensus interpreter. It also exposes CastToBool and extracts CheckTapscriptOpSuccess from ExecuteWitnessScript in src/script/interpreter.cpp to support this utility.

Problem: Developers designing or debugging Bitcoin scripts currently lack a lightweight standalone command-line tool within Bitcoin Core to evaluate arbitrary script fragments against consensus rules.

Category: Tools and scripts (#6 of 22)

P3 · new feature

  • P3 because it adds an offline CLI tool for developers to evaluate scripts directly
  • Reduces reliance on custom test scripts and third-party interpreters

P3 because it adds a new developer productivity feature to bitcoin-util. As stated in the description, it is 'intended for debugging and development' of script fragments.

Membership: Directly modifies src/bitcoin-util.cpp to add the evalscript subcommand and associated command-line options.

Factors: security/stability 0, bug 0, performance 0, user value 2, leverage 0

Reviewability: Ready

  • Worth reviewing now with a clean mergeable state and passing CI
  • Open test coverage feedback is an optional improvement rather than a blocker

The PR has passing CI, clean merge status, and is ready for review.

Author status: silent since 2026-07-24

Agreement: Strong

  • Positive sentiment with no objections raised
  • Verified by testing script unit tests and taproot features (jeanpablojp)
  • Suggested adding test coverage for the transaction option (jeanpablojp)

Positive: tested ACK with successful reproduction of examples (jeanpablojp)

One contributor posted a tested ACK confirming the command works as advertised, with a question on adding coverage for the -tx argument.

  • jeanpablojp (2026-08-19): 'tACK a64f2ac5b1... Ran tool_utils, the script unit tests and feature_taproot on the head, and both examples from the description reproduce here.'

Objections: none enumerated.

Support:

  • jeanpablojp: Ran tool_utils, script unit tests, and confirmed description examples reproduce successfully

Participants: jeanpablojp (support)

State derived from the lists: substantive support, no open objection (jeanpablojp) (model's own read: Positive)

Review verdicts (DrahtBot): 1

Files

237 lines under test/bench/ci.

  • src/bitcoin-util.cpp +290/-0
  • test/functional/data/util/bitcoin-util-test.json +66/-0
  • src/script/interpreter.cpp +24/-15
  • test/functional/data/util/evalscript-tapscript.json +24/-0
  • test/functional/data/util/evalscript-add.json +23/-0
  • test/functional/data/util/evalscript-empty.json +23/-0
  • test/functional/data/util/evalscript-op1.json +23/-0
  • test/functional/data/util/evalscript-opsuccess.json +23/-0
  • test/functional/data/util/evalscript-customflags.json +18/-0
  • test/functional/data/util/evalscript-opsuccess-discouraged.json +18/-0
  • test/functional/data/util/evalscript-base-noflags.json +17/-0
  • src/script/interpreter.h +11/-0
  • src/test/fuzz/script_interpreter.cpp +0/-2

Card

Adds an evalscript subcommand to bitcoin-util to execute script fragments and check signatures directly against consensus interpreter logic. This solves the lack of a standalone offline script execution and debugging tool for Bitcoin script developers. Interpreter changes are limited to exposing helper routines without altering validation rules. The PR is ready for review and has received a tested ACK verifying basic functionality.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T21:40, confidence high, input hash 14eafeb8eac29e3e