aboutsummaryrefslogtreecommitdiff
path: root/src/script/script.h
Commit message (Collapse)AuthorAgeFilesLines
* Implement Tapscript script validation rules (BIP 342)Johnson Lau2020-10-121-0/+12
| | | | | | This adds a new `SigVersion::TAPSCRIPT`, makes the necessary interpreter changes to make it implement BIP342, and uses them for leaf version 0xc0 in Taproot script path spends.
* Implement Taproot signature hashing (BIP 341)Johnson Lau2020-10-121-0/+5
| | | | | | | This implements the new sighashing scheme from BIP341, with all relevant whole-transaction values precomputed once and cached. Includes changes to PrecomputedTransactionData by Pieter Wuille.
* Merge #19004: refactor: Replace const char* to std::stringMarcoFalke2020-05-271-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | c57f03ce1741b38af448bec7b22ab9f8ac21f067 refactor: Replace const char* to std::string (Calvin Kim) Pull request description: Rationale: Addresses #19000 Some functions should be returning std::string instead of const char*. This commit changes that. Main benefits/reasoning: 1. The functions never return nullptr, so returning a string makes code at call sites easier to review (reviewers don't have to read the source code to verify that a nullptr is never returned) 2. All call sites convert to string anyway ACKs for top commit: MarcoFalke: re-ACK c57f03ce17 (no changes since previous review) 🚃 Empact: Fair enough, Code Review ACK https://github.com/bitcoin/bitcoin/pull/19004/commits/c57f03ce1741b38af448bec7b22ab9f8ac21f067 practicalswift: ACK c57f03ce1741b38af448bec7b22ab9f8ac21f067 -- patch looks correct hebasto: re-ACK c57f03ce1741b38af448bec7b22ab9f8ac21f067 Tree-SHA512: 9ce99bb38fe399b54844315048204cafce0f27fd8f24cae357fa7ac6f5d8094d57bbf5f5c1f5878a65f2d35e4a3f95d527eb17f49250b690c591c0df86ca84fd
| * refactor: Replace const char* to std::stringCalvin Kim2020-05-221-1/+1
| | | | | | | | | | Some functions should be returning std::string instead of const char*. This commit changes that.
* | Merge #18317: Serialization improvements step 6 (all except wallet/gui)MarcoFalke2020-05-201-6/+1
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | f9ee0f37c28f604bc82dab502ce229c66ef5b3b9 Add comments to CustomUintFormatter (Pieter Wuille) 4eb5643e3538863c9d2ff261f49a9a1b248de243 Convert everything except wallet/qt to new serialization (Pieter Wuille) 2b1f85e8c52c8bc5a17eae4c809eaf61d724af98 Convert blockencodings_tests to new serialization (Pieter Wuille) 73747afbbeb013669faf4c4d2c0903cec4526fb0 Convert merkleblock to new serialization (Pieter Wuille) d06fedd1bc26bf5bf2b203d4445aeaebccca780e Add SER_READ and SER_WRITE for read/write-dependent statements (Russell Yanofsky) 6f9a1e5ad0a270d3b5a715f3e3ea0911193bf244 Extend CustomUintFormatter to support enums (Russell Yanofsky) 769ee5fa0011ae658770586442715452a656559d Merge BigEndian functionality into CustomUintFormatter (Pieter Wuille) Pull request description: The next step of changes from #10785. This: * Adds support for enum serialization to `CustomUintFormatter`, used in `CAddress` for service flags. * Merges `BigEndian` into `CustomUintFormatter`, used in `CNetAddr` for port numbers. * Converts everything (except wallet and gui) to use the new serialization framework. ACKs for top commit: MarcoFalke: re-ACK f9ee0f37c2, only change is new documentation commit for CustomUintFormatter 📂 ryanofsky: Code review ACK f9ee0f37c28f604bc82dab502ce229c66ef5b3b9. Just new commit adding comment since last review jonatack: Code review re-ACK f9ee0f37c28f604bc82dab502ce229c6 only change since last review is an additional commit adding Doxygen documentation for `CustomUintFormatter`. Tree-SHA512: e7a0a36afae592d5a4ff8c81ae04d858ac409388e361f2bc197d9a78abca45134218497ab2dfd6d031e0cce0ca586cf857077b7c6ce17fccf67e2d367c1b6cd4
| * Convert everything except wallet/qt to new serializationPieter Wuille2020-03-301-6/+1
| |
* | Merge #18413: script: prevent UB when computing abs value for num opcode ↵fanquake2020-05-021-1/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | serialize 2748e8793267126c5b40621d75d1930e358f057e script: prevent UB when computing abs value for num opcode serialize (pierrenn) Pull request description: This was reported by practicalswift here #18046 It seems that the original author of the line used a reference to glibc `abs`: https://github.com/lattera/glibc/blob/master/stdlib/abs.c However depending on some implementation details this can be undefined behavior for unusual values. A detailed explanation of the UB is provided here : https://stackoverflow.com/questions/17313579/is-there-a-safe-way-to-get-the-unsigned-absolute-value-of-a-signed-integer-with (by [Billy O'Neal](https://twitter.com/malwareminigun)) Simple relevant godbolt example : https://godbolt.org/z/yRwtCG Thanks! ACKs for top commit: sipa: ACK 2748e8793267126c5b40621d75d1930e358f057e MarcoFalke: ACK 2748e8793267126c5b40621d75d1930e358f057e, only checked that the bitcoind binary does not change with clang -O2 🎓 practicalswift: ACK 2748e8793267126c5b40621d75d1930e358f057e Tree-SHA512: 539a34c636c2674c66cb6e707d9d0dfdce63f59b5525610ed88da10c9a8d59d81466b111ad63b850660cef3750d732fc7755530c81a2d61f396be0707cd86dec
| * | script: prevent UB when computing abs value for num opcode serializepierrenn2020-04-091-1/+1
| |/
* | Merge #18612: script: Remove undocumented and unused operator+Wladimir J. van der Laan2020-04-221-25/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ccccd5190898ece3ac17aa3178f320d091f221df script: Remove undocumented and unused operator+ (MarcoFalke) Pull request description: This operator has no documented use case and is also unused outside of test code. The test code and all other (imaginary) code that might use this operator is written more clear and concise by the existing CScript push operators for opcodes and data. Removing the operator is also going to protect against accidentally reintroducing bugs like this https://github.com/bitcoin/bitcoin/commit/6ff5f718b6a67797b2b3bab8905d607ad216ee21#diff-8458adcedc17d046942185cb709ff5c3L1135 (last time it was used). ACKs for top commit: laanwj: ACK ccccd5190898ece3ac17aa3178f320d091f221df Tree-SHA512: 43898ac77e4d9643d9f8ac6f8f65497a4f0bbb1fb5dcaecc839c3719aa36181ba77befb213e59a9f33a20a29e0173a0e9c4763b1930940b32c3d1598b3e39af9
| * | script: Remove undocumented and unused operator+MarcoFalke2020-04-151-25/+2
| | |
* | | scripted-diff: Bump copyright headersMarcoFalke2020-04-161-1/+1
|/ / | | | | | | | | | | -BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
* / script: Disallow silent bool -> CScript conversionMarcoFalke2020-04-131-1/+1
|/
* scripted-diff: Bump copyright of files changed in 2019MarcoFalke2019-12-301-1/+1
| | | | | | -BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
* Delete error-prone CScript constructorGregory Sanders2019-06-131-1/+3
|
* [cleanup] Remove unused CReserveKeyJohn Newbery2019-04-101-9/+0
|
* Avoid using numeric_limits for sequence numbers and lock timesRussell Yanofsky2018-11-011-0/+6
| | | | | | | | | | | | Switches to named constants, because numeric_limits calls can be harder to read and less portable. Change was suggested by James O'Beirne <[email protected]> in https://github.com/bitcoin/bitcoin/pull/10973#discussion_r213473620 There are no changes in behavior except on some platforms we don't support (ILP64, IP16L32, I16LP32), where SignalsOptInRBF() and MutateTxAddInput() functions would now work correctly.
* Update copyright headers to 2018DrahtBot2018-07-271-1/+1
|
* Remove template matching and pseudo opcodesPieter Wuille2018-05-291-7/+0
| | | | | | | | | | | | | The current code contains a rather complex script template matching engine, which is only used for 3 particular script types (P2PK, P2PKH, multisig). The first two of these are trivial to match for otherwise, and a specialized matcher for multisig is both more compact and more efficient than a generic one. The goal is being more flexible, so that for example larger standard multisigs inside SegWit outputs are more easy to implement. As a side-effect, it also gets rid of the pseudo opcodes hack.
* [MOVEONLY] Turn CScript::GetOp2 into a function and move to cppPieter Wuille2018-04-131-53/+4
|
* [MOVEONLY] Move CSCript::FindAndDelete to interpreterPieter Wuille2018-04-131-28/+0
|
* Delete unused non-const-iterator CSCript::GetOp overloadsPieter Wuille2018-04-131-17/+0
|
* Make iterators in CScript::FindAndDelete constPieter Wuille2018-04-131-3/+3
|
* Drop dead code CScript::FindBen Woosley2018-04-121-9/+0
| | | | Last use removed in 922e8e2929a2e78270868385aa46f96002fbcff3 (2012!)
* Support serialization as another type without castingPieter Wuille2018-03-201-1/+1
| | | | | | | | | This adds a READWRITEAS(type, obj) macro which serializes obj as if it were casted to (const type&) when const, and to (type&) when non-const. This makes it usable in serialization code that uses a single implementation for both serialization and deserializing, which doesn't know the constness of the object involved.
* Merge #10498: Use static_cast instead of C-style casts for non-fundamental typesMarcoFalke2018-02-071-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 9ad6746ccd Use static_cast instead of C-style casts for non-fundamental types (practicalswift) Pull request description: A C-style cast is equivalent to try casting in the following order: 1. `const_cast(...)` 2. `static_cast(...)` 3. `const_cast(static_cast(...))` 4. `reinterpret_cast(...)` 5. `const_cast(reinterpret_cast(...))` By using `static_cast<T>(...)` explicitly we avoid the possibility of an unintentional and dangerous `reinterpret_cast`. Furthermore `static_cast<T>(...)` allows for easier grepping of casts. For a more thorough discussion, see ["ES.49: If you must use a cast, use a named cast"](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es49-if-you-must-use-a-cast-use-a-named-cast) in the C++ Core Guidelines (Stroustrup & Sutter). Tree-SHA512: bd6349b7ea157da93a47b8cf238932af5dff84731374ccfd69b9f732fabdad1f9b1cdfca67497040f14eaa85346391404f4c0495e22c467f26ca883cd2de4d3c
| * Use static_cast instead of C-style casts for non-fundamental typespracticalswift2017-09-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A C-style cast is equivalent to try casting in the following order: 1. const_cast(...) 2. static_cast(...) 3. const_cast(static_cast(...)) 4. reinterpret_cast(...) 5. const_cast(reinterpret_cast(...)) By using static_cast<T>(...) explicitly we avoid the possibility of an unintentional and dangerous reinterpret_cast. Furthermore static_cast<T>(...) allows for easier grepping of casts.
* | Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa2018-01-031-1/+1
| |
* | scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider2017-11-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
* | Fix invalid memory access in CScript::operator+=Anthony Towns2017-09-111-0/+1
|/
* Merge #11011: [Trivial] Add a comment on the use of prevector in script.MarcoFalke2017-08-161-0/+6
|\ | | | | | | | | | | | | | | 08f71c29e [Trivial] Add a comment on the use of prevector in script. (Gregory Maxwell) Pull request description: Tree-SHA512: 020981516e67e576685eb9a8532178fb97d1780af409fc86d869cd05c293c0c823c26e838cf544d18610f5a3f479ce3e47d2ccb95fb1c4e55fe9e7ceb354f20b
| * [Trivial] Add a comment on the use of prevector in script.Gregory Maxwell2017-08-121-0/+6
| |
* | scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal ↵practicalswift2017-08-071-2/+2
|/ | | | | | | | | | | | | instead of the macro NULL -BEGIN VERIFY SCRIPT- sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp -END VERIFY SCRIPT-
* Avoid dereference-of-casted-pointerPieter Wuille2017-07-071-0/+8
|
* Merge #10534: Clarify prevector::erase and avoid swap-to-clearWladimir J. van der Laan2017-06-131-2/+3
|\ | | | | | | | | | | e241a63 Clarify prevector::erase and avoid swap-to-clear (Pieter Wuille) Tree-SHA512: fa7602038feb4417158df13ee7c0351673acf38f8a824e75889710344c46a9b8d5f6059faeb521f73e48b7ad3e1a238a9e433e4b44f7c3b9085ff08ef65271fa
| * Clarify prevector::erase and avoid swap-to-clearPieter Wuille2017-06-091-2/+3
| |
* | Sanity check transaction scripts in DecodeHexTxAndrew Chow2017-06-071-0/+3
| | | | | | | | Make sure that the scripts of decoded transactions are valid scripts.
* | Add a valid opcode sanity check to CScriptAndrew Chow2017-06-071-0/+3
|/ | | | | | Added a function in CScript that checks if the script contains valid opcodes. Add a test for that function
* Add constant for maximum stack sizeGregory Sanders2017-05-021-0/+3
|
* Merge #8808: Do not shadow variables (gcc set)Wladimir J. van der Laan2017-03-031-6/+6
|\ | | | | | | | | | | | | ad1ae7a Check and enable -Wshadow by default. (Pavel Janík) 9de90bb Do not shadow variables (gcc set) (Pavel Janík) Tree-SHA512: 9517feb423dc8ddd63896016b25324673bfbe0bffa97f22996f59d7a3fcbdc2ebf2e43ac02bc067546f54e293e9b2f2514be145f867321e9031f895c063d9fb8
| * Do not shadow variables (gcc set)Pavel Janík2016-12-051-6/+6
| |
* | Increment MIT Licence copyright header year on files modified in 2016isle29832016-12-311-1/+1
| | | | | | | | | | | | Edited via: $ contrib/devtools/copyright_header.py update .
* | Make CScript (and prevector) c++11 movable.Pieter Wuille2016-12-211-1/+0
| | | | | | | | | | Such moves are used when reallocating vectors that contain them, for example.
* | Move CTxInWitness inside CTxInPieter Wuille2016-12-041-0/+2
|/
* Rename OP_NOP3 to OP_CHECKSEQUENCEVERIFYBtcDrak2016-06-281-2/+2
|
* [RPC] signrawtransaction can sign P2WSHNicolasDorier2016-06-221-0/+1
|
* BIP141: Witness programPieter Wuille2016-06-221-0/+1
|
* BIP144: Serialization, hashes, relay (sender side)Pieter Wuille2016-06-221-0/+14
| | | | | | Contains refactorings by Eric Lombrozo. Contains fixup by Nicolas Dorier. Contains cleanup of CInv::GetCommand by Alex Morcos
* Merge #7907: Optimize and Cleanup CScript::FindAndDeleteWladimir J. van der Laan2016-05-051-3/+12
|\ | | | | | | | | | | | | d1d7775 Improve worst-case behavior of CScript::FindAndDelete (Patrick Strateman) e2a30bc Unit test for CScript::FindAndDelete (Gavin Andresen) c0f660c Replace c-style cast with c++ style static_cast. (Patrick Strateman) ec9ad5f Replace memcmp with std::equal in CScript::FindAndDelete (Patrick Strateman)
| * Improve worst-case behavior of CScript::FindAndDeletePatrick Strateman2016-04-211-2/+11
| | | | | | | | Thanks to Sergio Lerner for identifying this issue and suggesting this kind of solution.
| * Replace c-style cast with c++ style static_cast.Patrick Strateman2016-04-191-1/+1
| |