Skip to content

Make bitcoin-util evalscript functionality available as library call #71

@ajtowns

Description

@ajtowns

From bitcoin#29189 (comment)

Would something along the lines of https://github.com/ajtowns/bitcoin/commits/202309-evalscript/ be an interesting alternative?

For my part I would rather have a library function than a CLI tool.

Is having functionality like this available as a library function worth exploring as a feature in inquisition, to potentially eventually upstream to core?

The evalscript subcommand takes the following options:

  • script
  • arguments
  • script_flags (array of strings matching core's internal SCRIPT_FLAG_* names)
  • sigversion (base, witness_v0, tapscript, representing the different script versions supported)
  • spent_output, tx, input, ipk (data about the tx that can be introspected in some way via signature operations)

It outputs a json object that looks like:

{
  "script": {
    "asm": "1 1 OP_ADD",
    "hex": "515193",
    "type": "nonstandard"
  },
  "sigversion": "witness_v0",
  "script_flags": [
    "CHECKLOCKTIMEVERIFY",
    "CHECKSEQUENCEVERIFY",
    "DERSIG",
    "NULLDUMMY",
    "P2SH",
    "TAPROOT",
    "WITNESS"
  ],
  "stack-after": [
    "02"
  ],
  "sigop-count": 0,
  "success": true
}

If it is interesting to make this available via a library, what should API look like? Should it be C++ or C?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions