aboutsummaryrefslogtreecommitdiff
path: root/src/script
AgeCommit message (Collapse)Author
2015-10-08Add CHECKLOCKTIMEVERIFY (BIP65) soft-fork logicPeter Todd
Based on the earlier BIP66 soft-fork logic implemented by Pieter Wuille's 5a47811da5158df763aa2fca09ce646ee0c51e7b Rebased-From: 287f54fc90c29301faede8d4ac2ea24a91441917
2015-10-08Enable CHECKLOCKTIMEVERIFY as a standard script verify flagPeter Todd
Transactions that fail CLTV verification will be rejected from the mempool, making it easy to test the feature. However blocks containing "invalid" CLTV-using transactions will still be accepted; this is *not* the soft-fork required to actually enable CLTV for production use. Rebased-From: ffd75adce01a78b3461b3ff05bcc2b530a9ce994
2015-10-08Replace NOP2 with CHECKLOCKTIMEVERIFY (BIP65)Peter Todd
<nLockTime> CHECKLOCKTIMEVERIFY -> <nLockTime> Fails if tx.nLockTime < nLockTime, allowing the funds in a txout to be locked until some block height or block time in the future is reached. Only the logic and unittests are implemented; this commit does not have any actual soft-fork logic in it. Thanks to Pieter Wuille for rebase. Credit goes to Gregory Maxwell for the suggestion of comparing the argument against the transaction nLockTime rather than the current time/blockheight directly. Rebased-From: bc60b2b4b401f0adff5b8b9678903ff8feb5867b
2015-10-08Move LOCKTIME_THRESHOLD to src/script/script.hPeter Todd
Will now be needed by CHECKLOCKTIMEVERIFY code. Rebased-From: 48e9c57cf06352f890eac4285ae022d8746cf3fd
2015-10-08Make CScriptNum() take nMaxNumSize as an argumentPeter Todd
While the existing numeric opcodes are all limited to 4-byte bignum arguments, new opcodes will need different limits. Rebased-From: 99088d60d8a7747c6d1a7fd5d8cd388be1b3e138
2015-10-07Test LowS in standardness, removes nuisance malleability vector.Gregory Maxwell
This adds SCRIPT_VERIFY_LOW_S to STANDARD_SCRIPT_VERIFY_FLAGS which will make the node require the canonical 'low-s' encoding for ECDSA signatures when relaying or mining. Consensus behavior is unchanged. The rational is explained in a81cd96805ce6b65cca3a40ebbd3b2eb428abb7b: Absent this kind of test ECDSA is not a strong signature as given a valid signature {r, s} both that value and {r, -s mod n} are valid. These two encodings have different hashes allowing third parties a vector to change users txids. These attacks are avoided by picking a particular form as canonical and rejecting the other form(s); in the of the LOW_S rule, the smaller of the two possible S values is used. If widely deployed this change would eliminate the last remaining known vector for nuisance malleability on boring SIGHASH_ALL p2pkh transactions. On the down-side it will block most transactions made by sufficiently out of date software. Unlike the other avenues to change txids on boring transactions this one was randomly violated by all deployed bitcoin software prior to its discovery. So, while other malleability vectors where made non-standard as soon as they were discovered, this one has remained permitted. Even BIP62 did not propose applying this rule to old version transactions, but conforming implementations have become much more common since BIP62 was initially written. Bitcoin Core has produced compatible signatures since a28fb70e in September 2013, but this didn't make it into a release until 0.9 in March 2014; Bitcoinj has done so for a similar span of time. Bitcoinjs and electrum have been more recently updated. This does not replace the need for BIP62 or similar, as miners can still cooperate to break transactions. Nor does it replace the need for wallet software to handle malleability sanely[1]. This only eliminates the cheap and irritating DOS attack. [1] On the Malleability of Bitcoin Transactions Marcin Andrychowicz, Stefan Dziembowski, Daniel Malinowski, Łukasz Mazurek http://fc15.ifca.ai/preproceedings/bitcoin/paper_9.pdf Conflicts: src/policy/policy.h Rebased-From: b196b685c9089b74fd4ff3d9a28ea847ab36179b Github-Pull: #6769
2015-02-03Merge pull request #5714Wladimir J. van der Laan
3916a81 Increase coverage of DERSIG edge cases (Pieter Wuille) 6da2028 Add RPC test for DERSIG BIP switchover logic (Pieter Wuille) 773c30d BIP66 changeover logic (Pieter Wuille) 18695f0 Example unit tests from BIP66 (Pieter Wuille) abfbeaf Change IsDERSignature to BIP66 implementation (Pieter Wuille)
2015-02-03Avoid storing a reference passed to SignatureChecker constructorsPieter Wuille
Rebased-From: 9fddceda44fb5592be179d783f0e5ac616c51c0d Github-Pull: #5719
2015-02-03Use separate SignatureChecker for CMutableTransactionPieter Wuille
Conflicts: src/main.cpp src/script/bitcoinconsensus.cpp Rebased-From: 858809a33e4f690c4ad213f44a6c4465fc2ef025 Github-Pull: #5719
2015-02-01BIP66 changeover logicPieter Wuille
2015-02-01Change IsDERSignature to BIP66 implementationPieter Wuille
2015-01-26Make empty byte arrays pass CheckSignatureEncoding()Peter Todd
Makes it possible to compactly provide a delibrately invalid signature for use with CHECK(MULTI)SIG. For instance with BIP19 if m != n invalid signatures need to be provided in the scriptSig; prior to this change those invalid signatures would need to be large DER-encoded signatures. Note that we may want to further expand on this change in the future by saying that only OP_0 is a "valid" invalid signature; BIP19 even with this change is inherently malleable as the invalid signatures can be any validly encoded DER signature. Rebased-From: 2fa9a8ec86033b809a1c48f0396c3482c0d5d33c Github-Pull: #5627
2014-12-27Fix CScriptID(const CScript& in) in empty script casePeter Todd
Previously an empty script wouldn't be hashed, and CScriptID would be assigned the incorrect value of 0 instead. This bug can be seen in the RPC decodescript command: $ btc decodescript "" { "asm" : "", "type" : "nonstandard", "p2sh" : "31h1vYVSYuKP6AhS86fbRdMw9XHieotbST" } Correct output: $ btc decodescript "" { "asm" : "", "type" : "nonstandard", "p2sh" : "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy" } Rebased-From: d78f0dafd520f481f909cca7e361a4e482cbea72 Github-Pull: #5541
2014-12-05Normalize header guard of script_error.hPavel Janík
2014-12-03MOVEONLY: core/ -> primitives/Luke Dashjr
2014-12-01Merge pull request #5227Wladimir J. van der Laan
4cdaa95 Resize after succesful result (Pieter Wuille) 9d8604f Header define style cleanups (Pieter Wuille) a53fd41 Deterministic signing (Pieter Wuille) 3060e36 Add the RFC6979 PRNG (Pieter Wuille) a8f5087 Add HMAC-SHA256 (Pieter Wuille) 36fa4a7 Split up crypto/sha2 (Pieter Wuille)
2014-11-24libbitcoinconsensus: don't require any global constructorsCory Fields
These static objects are only used in once place, so declare them there instead.
2014-11-20Split up crypto/sha2Pieter Wuille
2014-11-20Test the exact order of CHECKMULTISIG sig/pubkey evaluationPeter Todd
Possible with STRICTENC
2014-11-20Make STRICTENC invalid pubkeys fail the script rather than the opcode.Pieter Wuille
This turns STRICTENC turn into a softforking-safe change (even though it is not intended as a consensus rule), and as a result guarantee that using it for mempool validation only results in consensus-valid transactions in the mempool.
2014-11-20Merge pull request #5000Pieter Wuille
0391423 Discourage NOPs reserved for soft-fork upgrades (Peter Todd)
2014-11-19build: add libbitcoinconsensus files and hook up the lib buildCory Fields
Credit BlueMatt for libbitcoinsonsensus.h/cpp
2014-11-17Discourage NOPs reserved for soft-fork upgradesPeter Todd
NOP1 to NOP10 are reserved for future soft-fork upgrades. In the event of an upgrade such NOPs have *VERIFY behavior, meaning that if their arguments are not correct the script fails. Discouraging these NOPs by rejecting transactions containing them from the mempool ensures that we'll never accept transactions, nor mine blocks, with scripts that are now invalid according to the majority of hashing power even if we're not yet upgraded. Previously this wasn't an issue as the IsStandard() rules didn't allow upgradable NOPs anyway, but 7f3b4e95 relaxed the IsStandard() rules for P2SH redemptions allowing any redeemScript to be spent. We *do* allow upgradable NOPs in scripts so long as they are not executed. This is harmless as there is no opportunity for the script to be invalid post-upgrade.
2014-11-14script: create sane error return codes for script validation and remove loggingCory Fields
Attempt to codify the possible error statuses associated with script validation. script/types.h has been created with the expectation that it will be part of the public lib interface. The other flag enums will be moved here in a future commit. Logging has also been removed in order to drop the dependency on core.h. It can be re-added to bitcoind as-needed. This makes script verification finally free of application state and boost!
2014-11-10Make comments in /src/script doxygen compatibleMichael Ford
2014-11-04Avoid a bunch of copying/conversion in script/signPieter Wuille
2014-11-04minor code style cleanup after recent mergesPhilip Kaufmann
- add a missing license header - correct some header orderings etc.
2014-11-04Merge pull request #5196Wladimir J. van der Laan
8473862 Fix all header defines (Pavel Janík)
2014-11-04Merge pull request #5162Wladimir J. van der Laan
d2e74c5 boost: moveonly: split CPubKey and friends to new files (Cory Fields) 78c228c boost: moveonly: move BIP32Hash to hash.h (Cory Fields) 900078a boost: moveonly: create eccryptoverify.h|cpp and move helper functions there (Cory Fields)
2014-11-03Fix all header definesPavel Janík
2014-10-31Merge pull request #5077Wladimir J. van der Laan
2aa6329 Enable customising node policy for datacarrier data size with a -datacarriersize option (Luke Dashjr)
2014-10-31boost: moveonly: split CPubKey and friends to new filesCory Fields
2014-10-31boost: moveonly: create eccryptoverify.h|cpp and move helper functions thereCory Fields
Eventually (after 0.10) these files will hold the logic for crypto verification routines, and CKey/CPubKey will call into them.
2014-10-28Merge pull request #5100Pieter Wuille
99f41b9 MOVEONLY: core.o -> core/block.o (jtimon) 561e9e9 MOVEONLY: Move script/compressor out of script and put CTxOutCompressor (from core) with it (jtimon) 999a2ab MOVEONLY: separate CTxUndo out of core (jtimon) 4a3587d MOVEONLY: Separate CTransaction and dependencies from core (jtimon) eda3733 MOVEONLY: Move CFeeRate and Amount constants to amount.o (jtimon)
2014-10-27MOVEONLY: Move script/compressor out of script and put CTxOutCompressor (fromjtimon
core) with it
2014-10-27MOVEONLY: Separate CTransaction and dependencies from corejtimon
2014-10-27Enable customising node policy for datacarrier data size with a ↵Luke Dashjr
-datacarriersize option
2014-10-25Improve CScriptNum() commentPeter Todd
Edited-by: Pieter Wuille <pieter.wuille@gmail.com>
2014-10-25Add SCRIPT_VERIFY_MINIMALDATA (BIP62 rules 3 and 4)Pieter Wuille
Also use the new flag as a standard rule, and replace the IsCanonicalPush standardness check with it (as it is more complete).
2014-10-25Add SCRIPT_VERIFY_SIGPUSHONLY (BIP62 rule 2)Pieter Wuille
2014-10-23fix build with libc++ after 85c579eCory Fields
2014-10-17script: add a slew of includes all around and drop includes from script.hCory Fields
Lots of files ended up with indirect includes from script.h.
2014-10-17script: move ToString and ValueString out of the headerCory Fields
2014-10-17script: add ToByteVector() for converting anything with begin/endCory Fields
This should move to a util header once their dependencies are cleaned up.
2014-10-17script: move CScriptID to standard.h and add a ctor for creating them from ↵Cory Fields
CScripts This allows for a reversal of the current behavior. This: CScript foo; CScriptID bar(foo.GetID()); Becomes: CScript foo; CScriptID bar(foo); This way, CScript is no longer dependent on CScriptID or Hash();
2014-10-08Make SCRIPT_VERIFY_STRICTENC compatible with BIP62Pieter Wuille
* Delete canonical_tests.cpp, and move the tests to script_tests.cpp. * Split off SCRIPT_VERIFY_DERSIG from SCRIPT_VERIFY_STRICTENC (the BIP62 part of it). * Change signature STRICTENC/DERSIG semantics to fail the script entirely rather than the CHECKSIG result (softfork safety, and BIP62 requirement). * Add many autogenerated tests for several odd cases. * Mention specific BIP62 rules in the script verification flags.
2014-10-07Merge pull request #4954Wladimir J. van der Laan
9d7cd4c Don't return an address for invalid pubkeys (Andy Alness)
2014-10-06Don't return an address for invalid pubkeysAndy Alness
2014-10-06minor license, header end comment etc. cleanup in /scriptPhilip Kaufmann
- ensure all licenses are just MIT - add a missing header end comment - ensure alphabetical ordering
2014-10-02Replace SCRIPT_VERIFY_NOCACHE by flag directly to checkerPieter Wuille