Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add miniscript implementation #1987

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

guggero
Copy link
Collaborator

@guggero guggero commented May 27, 2023

Adds the Golang miniscript implementation authored by @benma in https://github.com/benma/miniscript-go to txscript/miniscript (as requested by the author, see #1986).

TODOs:

  • Address TODOs in code
  • Add usage examples and documentation

@coveralls
Copy link

coveralls commented May 27, 2023

Pull Request Test Coverage Report for Build 5099410036

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 1482 of 1966 (75.38%) changed or added relevant lines in 3 files are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.8%) to 56.06%

Changes Missing Coverage Covered Lines Changed/Added Lines %
txscript/miniscript/opcount.go 157 160 98.13%
txscript/miniscript/satisfactions.go 278 456 60.96%
txscript/miniscript/miniscript.go 1047 1350 77.56%
Files with Coverage Reduction New Missed Lines %
peer/peer.go 7 73.2%
Totals Coverage Status
Change from base Build 5075515644: 0.8%
Covered Lines: 28149
Relevant Lines: 50212

💛 - Coveralls

benma and others added 2 commits April 24, 2024 08:59
Currently, only the P2WSH context is supported. Miniscript for Taproot
was not yet well specified at the time of writing. Currently, there is
an open PR for Bitcoin Core at
bitcoin/bitcoin#27255 which, when merged, can
be taken as a reference.

This implementation contains:

- miniscript parser
- type checker
- malleability check
- script length limit check (P2WSH standardness rule)
- op count check (P2WSH consensus rule)
- duplicate pubkey check
- script generation
- witness generation (satisfactions)
- unit tests that create receive addresses based on some miniscripts and spend from them again (see
`TestRedeem()`).

Unit tests exist to check that this implementation's type checking passes some of the unit tests of
rust-miniscript. See [./testdata](./testdata).

Missing/todo:
- timelock mixing check
- stack size check (P2WSH standardness rule)
- witness generation for thresh/multi currently has a naive implementation that is very inefficient
(exponential runtime). This should be replaced with a fast algorithm.
- maybe more

Co-authored-by: Oliver Gugger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants