bitcoin/src/script
laanwj d492dc1cda
Merge bitcoin/bitcoin#24147: Miniscript integration
2da94a4c6f fuzz: add a fuzz target for Miniscript decoding from Script (Antoine Poinsot)
f8369996e7 Miniscript: ops limit and stack size computation (Pieter Wuille)
2e55e88f86 Miniscript: conversion from script (Pieter Wuille)
1ddaa66eae Miniscript: type system, script creation, text notation, tests (Pieter Wuille)
4fe29368c0 script: expose getter for CScriptNum, add a BuildScript helper (Antoine Poinsot)
f4e289f384 script: move CheckMinimalPush from interpreter to script.h (Antoine Poinsot)
31ec6ae92a script: make IsPushdataOp non-static (Antoine Poinsot)

Pull request description:

  Miniscript is a language for writing (a subset of) Bitcoin Scripts in a structured way.

  Miniscript permits:
  - To safely extend the Output Descriptor language to many more scripting features thanks to the typing system (composition).
  - Statical analysis of spending conditions, maximum spending cost of each branch, security properties, third-party malleability.
  - General satisfaction of any correctly typed ("valid" [0]) Miniscript. The satisfaction itself is also analyzable.
  - To extend the possibilities of external signers, because of all of the above and since it carries enough metadata.

  Miniscript guarantees:
  - That for any statically-analyzed as "safe" [0] Script, a witness can be constructed in the bounds of the consensus and standardness rules (standardness complete).
  - That unless the conditions of the Miniscript are met, no witness can be created for the Script (consensus sound).
  - Third-party malleability protection for the satisfaction of a sane Miniscript, which is too complex to summarize here.

  For more details around Miniscript (including the specifications), please refer to the [website](https://bitcoin.sipa.be/miniscript/).

  Miniscript was designed by Pieter Wuille, Andrew Poelstra and Sanket Kanjalkar.
  This PR is an updated and rebased version of #16800. See [the commit history of the Miniscript repository](https://github.com/sipa/miniscript/commits/master) for details about the changes made since September 2019 (TL;DR: bugfixes, introduction of timelock conflicts in the type system, `pk()` and `pkh()` aliases, `thresh_m` renamed to `multi`, all recursive algorithms were made non-recursive).

  This PR is also the first in a series of 3:
  - The first one (here) integrates the backbone of Miniscript.
  - The second one (#24148) introduces support for Miniscript in Output Descriptors, allowing for watch-only support of Miniscript Descriptors in the wallet.
  - The third one (#24149) implements signing for these Miniscript Descriptors, using Miniscript's satisfaction algorithm.

  Note to reviewers:
  - Miniscript is currently defined only for P2WSH. No Taproot yet.
  - Miniscript is different from the policy language (a high-level logical representation of a spending policy). A policy->Miniscript compiler is not included here.
  - The fuzz target included here is more interestingly extended in the 3rd PR to check a script's satisfaction against `VerifyScript`. I think it could be further improved by having custom mutators as we now have for multisig (see https://github.com/bitcoin/bitcoin/issues/23105). A minified corpus of Miniscript Scripts is available at https://github.com/bitcoin-core/qa-assets/pull/85.

  [0] We call "valid" any correctly-typed Miniscript. And "safe" any sane Miniscript, ie one whose satisfaction isn't malleable, which requires a key for any spending path, etc..

ACKs for top commit:
  jb55:
    ACK 2da94a4c6f
  laanwj:
    Light code review ACK 2da94a4c6f (mostly reviewed the changes to the existing code and build system)

Tree-SHA512: d3ef558436cfcc699a50ad13caf1e776f7d0addddb433ee28ef38f66ea5c3e581382d8c748ccac9b51768e4b95712ed7a6112b0e3281a6551e0f325331de9167
2022-04-05 13:22:09 +02:00
..
bitcoinconsensus.cpp Use spans of std::byte in serialize 2022-01-02 11:40:31 +01:00
bitcoinconsensus.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
descriptor.cpp Merge bitcoin/bitcoin#24462: For descriptor pubkey parse errors, include context information 2022-03-23 09:38:54 +01:00
descriptor.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
interpreter.cpp Merge bitcoin/bitcoin#24147: Miniscript integration 2022-04-05 13:22:09 +02:00
interpreter.h script: move CheckMinimalPush from interpreter to script.h 2022-03-17 14:09:06 +01:00
keyorigin.h Implement operator< for KeyOriginInfo and CExtPubKey 2021-12-10 08:29:47 -05:00
miniscript.cpp Miniscript: conversion from script 2022-03-17 14:09:08 +01:00
miniscript.h Miniscript: ops limit and stack size computation 2022-03-17 14:09:08 +01:00
script.cpp script: move CheckMinimalPush from interpreter to script.h 2022-03-17 14:09:06 +01:00
script.h script: expose getter for CScriptNum, add a BuildScript helper 2022-03-17 14:09:07 +01:00
script_error.cpp Implement Tapscript script validation rules (BIP 342) 2020-10-12 17:18:24 -07:00
script_error.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
sigcache.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
sigcache.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
sign.cpp refactor: fix clang-tidy named args usage 2022-04-04 09:01:19 +01:00
sign.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
signingprovider.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
signingprovider.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
standard.cpp script: make IsPushdataOp non-static 2022-03-17 14:09:06 +01:00
standard.h script: make IsPushdataOp non-static 2022-03-17 14:09:06 +01:00