bitcoin/src/script
fanquake 695ca641a4
Merge bitcoin/bitcoin#24860: Miniscript integration follow-ups
f3a50c9dfe miniscript: rename IsSane and IsSaneSubexpression to prevent misuse (Antoine Poinsot)
c5fe5163dc miniscript: nit: don't return after assert(false) (Antoine Poinsot)
7bbaca9d8d miniscript: explicit the threshold size computation in multi() (Antoine Poinsot)
8323e4249d miniscript: add an OpCode typedef for readability (Antoine Poinsot)
7a549c6c59 miniscript: mark nodes with duplicate keys as insane (Antoine Poinsot)
8c0f8bf7bc fuzz: add a Miniscript target for string representation roundtripping (Antoine Poinsot)
be34d5077b fuzz: rename and improve the Miniscript Script roundtrip target (Antoine Poinsot)
7eb70f0ac0 miniscript: tiny doc fixups (Antoine Poinsot)
5cea85f12c miniscript: split ValidSatisfactions from IsSane (Antoine Poinsot)
a0f064dc14 miniscript: introduce a CheckTimeLocksMix helper (Antoine Poinsot)
ed45ee3882 miniscript: use optional instead of bool/outarg (Antoine Poinsot)
1ab8d89fd1 miniscript: make equality operator non-recursive (Antoine Poinsot)
5922c662c0 scripted-diff: miniscript: rename 'nodetype' variables to 'fragment' (Antoine Poinsot)
c5f65db0f0 miniscript: remove a workaround for a GCC 4.8 bug (Antoine Poinsot)

Pull request description:

  The Miniscript repository and the Miniscript integration PR here have been a moving target for the past months, and some final cleanups were done there that were not included here. I initially intended to add some small followup commits to #24148 but i think there are enough of them to be worth a followup PR on its own.

  Some parts of the code did not change since it was initially written in 2019, and the code could use some modernization. (Use std::optional instead of out args, remove old compiler workarounds).
  We refactored the helpers to be more meaningful, and also did some renaming. A new fuzz target was also added and both were merged in a single file. 2 more will be added in #24149 that will be contained in this file too.

  The only behaviour change in this PR is to rule out Miniscript with duplicate keys from sane Miniscripts. In a P2WSH context, signatures can be rebounded (Miniscript does not use CODESEPARATOR) and it's reasonable to assume that reusing keys across the Script drops the malleability guarantees.
  It was previously assumed such Miniscript would never exist in the first place since a compiler should never create them. We finally agreed that if one were to exist (say, written by hand or from a buggy compiler) it would be very confusing if an imported Miniscript descriptor (after #24148) with duplicate keys was deemed sane (ie, "safe to use") by Bitcoin Core. We now check for duplicate keys in the constructor.

  This is (still) joint work with Pieter Wuille. (Actually he entirely authored the cleanups and code modernization.)

ACKs for top commit:
  sipa:
    utACK f3a50c9dfe (with the caveat that a lot of it is my own code)
  sanket1729:
    code review ACK f3a50c9dfe. Did not review the fuzz tests.

Tree-SHA512: c043325e4936fe25e8ece4266b46119e000c6745f88cea530fed1edf01c80f03ee6f9edc83b6e9d42ca01688d184bad16bfd967c5bb8037744e726993adf3deb
2022-06-04 20:54:20 +01: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 Add BIP-341 specified constraints to ComputeTaprootMerkleRoot 2022-05-25 12:51:01 -07:00
interpreter.h Precomputed hashes are note #16 in BIP341 2022-04-25 11:58:42 -04:00
keyorigin.h Implement operator< for KeyOriginInfo and CExtPubKey 2021-12-10 08:29:47 -05:00
miniscript.cpp miniscript: nit: don't return after assert(false) 2022-05-30 15:16:45 +02:00
miniscript.h miniscript: rename IsSane and IsSaneSubexpression to prevent misuse 2022-05-30 15:16:46 +02: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: use C++11 default initializers 2022-05-17 17:18:58 +01:00
sign.h refactor: Change * to & in MutableTransactionSignatureCreator 2022-05-04 11:49:29 +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 refactor: Remove defunct attributes.h includes 2022-05-21 13:54:33 -05:00