Commit graph

54 commits

Author SHA1 Message Date
Andrew Chow
5b75c47784 Add a valid opcode sanity check to CScript
Added a function in CScript that checks if the script contains valid opcodes.

Add a test for that function
2017-06-07 12:40:01 -07:00
Gregory Sanders
cb184b3a54 Add constant for maximum stack size 2017-05-02 13:37:41 -04:00
Wladimir J. van der Laan
75d012e8c7
Merge #8808: Do not shadow variables (gcc set)
ad1ae7a Check and enable -Wshadow by default. (Pavel Janík)
9de90bb Do not shadow variables (gcc set) (Pavel Janík)

Tree-SHA512: 9517feb423dc8ddd63896016b25324673bfbe0bffa97f22996f59d7a3fcbdc2ebf2e43ac02bc067546f54e293e9b2f2514be145f867321e9031f895c063d9fb8
2017-03-03 15:48:53 +01:00
isle2983
27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Pieter Wuille
2ddfcfd2d6 Make CScript (and prevector) c++11 movable.
Such moves are used when reallocating vectors that contain them,
for example.
2016-12-21 18:28:33 -08:00
Pavel Janík
9de90bb749 Do not shadow variables (gcc set) 2016-12-05 11:41:46 +01:00
Pieter Wuille
f6fb7acda4 Move CTxInWitness inside CTxIn 2016-12-04 23:47:12 -08:00
BtcDrak
14d01309be Rename OP_NOP3 to OP_CHECKSEQUENCEVERIFY 2016-06-28 17:17:36 +01:00
NicolasDorier
745eb678ef [RPC] signrawtransaction can sign P2WSH 2016-06-22 15:43:01 +02:00
Pieter Wuille
449f9b8deb BIP141: Witness program 2016-06-22 15:42:59 +02:00
Pieter Wuille
7030d9eb47 BIP144: Serialization, hashes, relay (sender side)
Contains refactorings by Eric Lombrozo.
Contains fixup by Nicolas Dorier.
Contains cleanup of CInv::GetCommand by Alex Morcos
2016-06-22 15:42:59 +02:00
Wladimir J. van der Laan
006cdf64dc
Merge #7907: Optimize and Cleanup CScript::FindAndDelete
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)
2016-05-05 19:01:32 +02:00
Pieter Wuille
4f87af6fc7 Treat overly long scriptPubKeys as unspendable 2016-04-25 14:22:30 +02:00
Pieter Wuille
f8e6fb1800 Introduce constant for maximum CScript length 2016-04-25 14:22:30 +02:00
Patrick Strateman
d1d7775587 Improve worst-case behavior of CScript::FindAndDelete
Thanks to Sergio Lerner for identifying this issue and suggesting this kind of solution.
2016-04-21 17:24:36 -07:00
Patrick Strateman
c0f660c3a3 Replace c-style cast with c++ style static_cast. 2016-04-19 13:22:20 -07:00
Patrick Strateman
ec9ad5f199 Replace memcmp with std::equal in CScript::FindAndDelete
Function is stl; std::equal just makes more sense.
2016-04-19 13:22:03 -07:00
Mark Friedenbach
53e53a33c9 BIP112: Implement CHECKSEQUENCEVERIFY
- Replace NOP3 with CHECKSEQUENCEVERIFY (BIP112)
  <nSequence> CHECKSEQUENCEVERIFY -> <nSequence>
- Fails if txin.nSequence < nSequence, allowing funds of a txout to be locked for a number of blocks or a duration of time after its inclusion in a block.
- Pull most of CheckLockTime() out into VerifyLockTime(), a local function that will be reused for CheckSequence()
- Add bitwise AND operator to CScriptNum
- Enable CHECKSEQUENCEVERIFY as a standard script verify flag
- Transactions that fail CSV verification will be rejected from the mempool, making it easy to test the feature. However blocks containing "invalid" CSV-using transactions will still be accepted; this is *not* the soft-fork required to actually enable CSV for production use.
2016-02-14 11:29:38 +00:00
Wladimir J. van der Laan
605c17844e
Merge pull request #7205
fa71669 [devtools] Use git pretty-format for year parsing (MarcoFalke)
fa24439 Bump copyright headers to 2015 (MarcoFalke)
fa6ad85 [devtools] Rewrite fix-copyright-headers.py (MarcoFalke)
2016-01-05 14:11:40 +01:00
mb300sd
37d271d7cc Rename OP_NOP2 to OP_CHECKLOCKTIMEVERIFY. 2015-12-15 02:01:45 -05:00
MarcoFalke
fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Pieter Wuille
114b5812f6 Prevector type 2015-11-13 18:15:20 +01:00
David Hill
b48da5c189 script: Remove magic numbers
This adds two new constants, MAX_OPS_PER_SCRIPT and
MAX_PUBKEYS_PER_MULTISIG.
2015-10-15 09:48:15 -04:00
Peter Todd
da894ab5da Accept any sequence of PUSHDATAs in OP_RETURN outputs
Previously only one PUSHDATA was allowed, needlessly limiting
applications such as matching OP_RETURN contents with bloom filters that
operate on a per-PUSHDATA level. Now any combination that passes
IsPushOnly() is allowed, so long as the total size of the scriptPubKey
is less than 42 bytes. (unchanged modulo non-minimal PUSHDATA encodings)

Also, this fixes the odd bug where previously the PUSHDATA could be
replaced by any single opcode, even sigops consuming opcodes such as
CHECKMULTISIG. (20 sigops!)
2015-10-01 18:28:13 +02:00
Peter Todd
5d8709c3b7 Add IsPushOnly(const_iterator pc)
Allows IsPushOnly() to be applied to just part of the script for
OP_RETURN outputs.
2015-10-01 18:28:11 +02:00
mruddy
af3208bfa6 Resolve issue 3166.
These changes decode valid SIGHASH types on signatures in assembly (asm) representations of scriptSig scripts.
This squashed commit incorporates substantial helpful feedback from jtimon, laanwj, and sipa.
2015-07-30 19:56:00 -04:00
Pieter Wuille
9e38d0f745 Separate core memory usage computation in core_memusage.h 2015-07-20 11:17:53 -04:00
Pieter Wuille
5098c47b24 Implement accurate memory accounting for mempool 2015-07-10 10:49:31 -04:00
Jonas Schnelli
5496253966 add CReserveScript to allow modular script keeping/returning
- use one CReserveScript per mining thread
2015-07-01 16:06:14 +02:00
Wladimir J. van der Laan
41076aad0c
Merge pull request #6124
ffd75ad Enable CHECKLOCKTIMEVERIFY as a standard script verify flag (Peter Todd)
bc60b2b Replace NOP2 with CHECKLOCKTIMEVERIFY (BIP65) (Peter Todd)
48e9c57 Move LOCKTIME_THRESHOLD to src/script/script.h (Peter Todd)
99088d6 Make CScriptNum() take nMaxNumSize as an argument (Peter Todd)
2015-06-26 14:42:45 +02:00
Peter Todd
bc60b2b4b4 Replace NOP2 with CHECKLOCKTIMEVERIFY (BIP65)
<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.
2015-06-21 23:56:28 -04:00
Philip Kaufmann
5207f33f45 fix header include groups 2015-05-14 01:02:01 -04:00
Peter Todd
48e9c57cf0 Move LOCKTIME_THRESHOLD to src/script/script.h
Will now be needed by CHECKLOCKTIMEVERIFY code.
2015-05-09 04:33:49 -04:00
Peter Todd
99088d60d8 Make CScriptNum() take nMaxNumSize as an argument
While the existing numeric opcodes are all limited to 4-byte bignum
arguments, new opcodes will need different limits.
2015-05-09 04:29:47 -04:00
Wladimir J. van der Laan
4e853aa163 src/script/script.h: endian compatibility for PUSHDATA sizes 2015-03-06 17:21:58 +01:00
Pavel Janík
5262fde0ec Remove whitespaces before double colon in errors and logs 2015-01-31 17:38:28 -05:00
sandakersmann
f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Michael Ford
b9a36b15bf Make comments in /src/script doxygen compatible 2014-11-10 14:51:55 +08:00
Pavel Janík
84738627ce Fix all header defines 2014-11-03 16:16:40 +01:00
Peter Todd
6004e77b92 Improve CScriptNum() comment
Edited-by: Pieter Wuille <pieter.wuille@gmail.com>
2014-10-25 03:03:20 -07:00
Pieter Wuille
698c6abb25 Add SCRIPT_VERIFY_MINIMALDATA (BIP62 rules 3 and 4)
Also use the new flag as a standard rule, and replace the IsCanonicalPush
standardness check with it (as it is more complete).
2014-10-25 03:03:20 -07:00
Pieter Wuille
d752ba86c1 Add SCRIPT_VERIFY_SIGPUSHONLY (BIP62 rule 2) 2014-10-25 03:03:16 -07:00
Cory Fields
3a757c5294 fix build with libc++ after 85c579e 2014-10-23 14:24:22 -04:00
Cory Fields
85c579e3a6 script: add a slew of includes all around and drop includes from script.h
Lots of files ended up with indirect includes from script.h.
2014-10-17 13:44:57 -04:00
Cory Fields
db8eb54bd7 script: move ToString and ValueString out of the header 2014-10-17 13:44:14 -04:00
Cory Fields
e9ca4280f3 script: add ToByteVector() for converting anything with begin/end
This should move to a util header once their dependencies are cleaned up.
2014-10-17 13:44:14 -04:00
Cory Fields
066e2a1403 script: move CScriptID to standard.h and add a ctor for creating them from 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-17 13:44:14 -04:00
Wladimir J. van der Laan
4b2b78b9f2
Merge pull request #4969
cda45b5 Reinitializing list's begin iterator after few elements were erased from the head (ENikS)
2014-09-25 15:58:56 +02:00
ENikS
1e73504865
Fixing C4146 warning
Rebased-By: Wladimir J. van der Laan <laanwj@gmail.com>
2014-09-25 15:24:36 +02:00
ENikS
cda45b5131 Reinitializing list's begin iterator after few elements were erased from the head 2014-09-23 18:33:16 -04:00