bitcoin-util: Add evalscript subcommand #35788

pull ajtowns wants to merge 4 commits into bitcoin:master from ajtowns:202607-evalscript changing 13 files +560 −17
  1. ajtowns commented at 1:56 AM on July 24, 2026: contributor

    Adds an evalscript subcommand for using bitcoin's consensus logic to evaluate script fragments. Intended for debugging and development.

    Examples:

    # check a script fragment's behaviour
    $ bitcoin-util evalscript '1 2 ADD'
    {
      "script": {
        "asm": "1 2 OP_ADD",
        "hex": "515293",
        "type": "nonstandard"
      },
      "sigversion": "witness_v0",
      "script_flags": [
        "CHECKLOCKTIMEVERIFY",
        "CHECKSEQUENCEVERIFY",
        "DERSIG",
        "NULLDUMMY",
        "P2SH",
        "TAPROOT",
        "WITNESS"
      ],
      "dummy_sig_checker": true,
      "stack_after": [
        "03"
      ],
      "sigop_cost": 0,
      "success": true
    }
    
    # validate a real signature
    $ bitcoin-util -sigversion=base \
        -spentoutput=00f2052a0100000043410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3ac \
        -tx=0100000001c997a5e56e104102fa209c6a852dd90660a20b2d9c352423edce25857fcd3704000000004847304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901ffffffff0200ca9a3b00000000434104ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa28414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6cd84cac00286bee0000000043410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3ac00000000 \
        evalscript '0x410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3 CHECKSIG' \
        '304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901'
    {
      "script": {
        "asm": "0411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3 OP_CHECKSIG",
        "hex": "410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3ac",
        "type": "pubkey"
      },
      "sigversion": "base",
      "script_flags": [
        "CHECKLOCKTIMEVERIFY",
        "CHECKSEQUENCEVERIFY",
        "DERSIG",
        "NULLDUMMY",
        "P2SH",
        "TAPROOT",
        "WITNESS"
      ],
      "dummy_sig_checker": false,
      "stack_after": [
        "01"
      ],
      "sigop_cost": 4,
      "success": true
    }
    
  2. script: expose CastToBool function f3ad9ba72c
  3. [consensus] script/interpreter: Expose OP_SUCCESS logic
    Review with `git diff --color-moved=zebra --color-moved-ws=allow-indentation-change`
    9d1482911d
  4. DrahtBot commented at 1:56 AM on July 24, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35788.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30342 (kernel, logging: Pass Logger instances to kernel objects by ryanofsky)
    • #29247 (CAT in Tapscript (BIP-347) by arminsabouri)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. ajtowns commented at 2:02 AM on July 24, 2026: contributor

    Previously included in bitcoin-inquisition (https://github.com/bitcoin-inquisition/bitcoin/pull/58, also https://github.com/bitcoin-inquisition/bitcoin/pull/64 and https://github.com/bitcoin-inquisition/bitcoin/pull/79).

    Makes minimal changes to consensus logic, but still has to duplicate a bunch of code to get equivalent behaviour, might be worthwhile simplifying that API in followups, and potentially exposing as a kernel API of some sort?

  6. bitcoin-util: Introduce evalscript subcommand f0556b061d
  7. tests: Add functional test for bitcoin-util evalscript a64f2ac5b1
  8. ajtowns force-pushed on Jul 24, 2026
  9. DrahtBot added the label CI failed on Jul 24, 2026
  10. DrahtBot removed the label CI failed on Jul 24, 2026
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-07-31 20:50 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me