Commit graph

47 commits

Author SHA1 Message Date
Pieter Wuille
605e8473a7 BIP143: Signing logic 2016-06-22 15:43:01 +02:00
Pieter Wuille
3dd410294d BIP143: Verification logic
Includes simplifications by Eric Lombrozo.
2016-06-22 15:43:00 +02:00
Pieter Wuille
0ef1dd3e11 Refactor script validation to observe amounts
This is a preparation for BIP143 support.
2016-06-22 15:43:00 +02:00
Pieter Wuille
449f9b8deb BIP141: Witness program 2016-06-22 15:42:59 +02:00
Wladimir J. van der Laan
a25a4f5b04 wallet_ismine.h → script/ismine.h
Removes conditional dependency of `src/test` on wallet.

Makes multisig and P2SH tests complete without wallet built-in.
2016-04-18 15:14:36 +02:00
MarcoFalke
fa7e4c0919 Bump copyright headers to 2014 2016-01-05 21:01:39 +01:00
Luke Dashjr
9238ecb417 Policy: MOVEONLY: 3 functions to policy.o:
- [script/standard.o] IsStandard
- [main.o] IsStandardTx
- [main.o] AreInputsStandard

Also, don't use namespace std in policy.cpp
2015-06-26 17:59:10 +02:00
Wladimir J. van der Laan
05f17d4eaa
Merge pull request #5745
50c72f2 [Move Only] Move wallet related things to src/wallet/ (Jonas Schnelli)
2015-03-20 16:08:35 +01:00
Jonas Schnelli
50c72f23ad [Move Only] Move wallet related things to src/wallet/
could once be renamed from /src/wallet to /src/legacywallet.
2015-03-12 14:13:02 +01:00
Wladimir J. van der Laan
92fd887fd4 tests: add a BasicTestingSetup and apply to all tests
Make sure that chainparams and logging is properly initialized. Doing
this for every test may be overkill, but this initialization is so
simple that that does not matter.

This should fix the travis issues.
2015-03-12 09:45:22 +01:00
Pieter Wuille
9fddceda44 Avoid storing a reference passed to SignatureChecker constructors 2015-02-02 20:19:46 -08:00
Pieter Wuille
858809a33e Use separate SignatureChecker for CMutableTransaction 2015-02-02 20:19:12 -08:00
Peter Todd
2fa9a8ec86
Make empty byte arrays pass CheckSignatureEncoding()
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.
2015-01-09 06:03:22 -05:00
Cory Fields
9b1ab860ff namespace: drop boost::assign altogether here
Standard functions are even simpler
2015-01-02 15:12:03 -05:00
Michael Ford
78253fcbad Remove references to X11 licence 2014-12-16 15:56:50 +08:00
Cory Fields
219a1470c4 script: check ScriptError values in script tests 2014-11-14 16:25:53 -05: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
Pieter Wuille
e790c370b5 Replace SCRIPT_VERIFY_NOCACHE by flag directly to checker 2014-10-02 20:26:58 +02:00
jtimon
2b23a87599 Don't pass nHashType to VerifyScript 2014-09-12 20:04:31 +02:00
jtimon
c1e433b717 Rename scriptutils.o to wallet_ismine.o 2014-09-10 12:48:35 +02:00
jtimon
0d2fa14a34 Move scriptutils.o to wallet 2014-09-10 12:42:56 +02:00
jtimon
e088d65acb Separate script/sign 2014-09-08 20:21:35 +02:00
jtimon
da03e6ed7c Separate script/interpreter 2014-09-08 20:21:33 +02:00
jtimon
cbd22a50c4 Move CScript class and dependencies to script/script 2014-09-08 20:19:31 +02:00
jtimon
86dbeea2cd Rename script.h/.cpp to scriptutils.h/.cpp (plus remove duplicated includes) 2014-09-08 20:19:31 +02:00
jtimon
87d9819d4d fix comments ExtractAddress() -> ExtractDestination() 2014-08-28 01:54:45 +02:00
jtimon
f5745fa52a Declare SignatureHash() in script.h 2014-08-01 17:45:09 +02:00
Pieter Wuille
4949004d68 Add CMutableTransaction and make CTransaction immutable.
In addition, introduce a cached hash inside CTransaction, to prevent
recalculating it over and over again.
2014-06-21 22:59:03 +02:00
Wladimir J. van der Laan
3fc6846181 Add licenses for tests and test data
- Add license headers to source files (years based on commit dates)
  in `src/test` as well as `qa`
- Add `README.md` to `src/test/data` specifying MIT license

Fixes #3848
2014-03-18 10:20:55 +01:00
Brandon Dahler
51ed9ec971 Cleanup code using forward declarations.
Use misc methods of avoiding unnecesary header includes.
Replace int typedefs with int##_t from stdint.h.
Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h.
Normalize QT_VERSION ifs where possible.
Resolve some indirect dependencies as direct ones.
Remove extern declarations from .cpp files.
2013-11-10 09:36:28 -06:00
Gavin Andresen
be484db274 Merge pull request #2738 from jgarzik/op_return
Relay OP_RETURN data TxOut as standard transaction type.
2013-10-21 22:47:24 -07:00
Jeff Garzik
a79342479f Relay OP_RETURN data TxOut as standard transaction type 2013-10-02 11:49:43 -04:00
Pieter Wuille
f5857e5cb5 Inline signature serializer
Instead of building a full copy of a CTransaction being signed, and
then modifying bits and pieces until its fits the form necessary
for computing the signature hash, use a wrapper serializer that
only serializes the necessary bits on-the-fly.

This makes it easier to see which data is actually being hash,
reduces load on the heap, and also marginally improves performances
(around 3-4us/sigcheck here). The performance improvements are much
larger for large transactions, though.

The old implementation of SignatureHash is moved to a unit tests,
to test whether the old and new algorithm result in the same value
for randomly-constructed transactions.
2013-09-28 18:37:00 +02:00
Pieter Wuille
dfa23b94c2 CSecret/CKey -> CKey/CPubKey split/refactor 2013-05-30 05:20:21 +02:00
Gavin Andresen
87b9931bed Fix signed/unsigned comparison warnings 2013-04-03 14:04:21 -04:00
Pieter Wuille
99d0d0f356 Introduce script verification flags
These flags select features to be enabled/disabled during script
evaluation/checking, instead of several booleans passed along.
Currently these flags are defined:
* SCRIPT_VERIFY_P2SH: enable BIP16-style subscript evaluation
* SCRIPT_VERIFY_STRICTENC: enforce strict adherence to pubkey/sig encoding standards.
2012-11-15 23:00:16 +01:00
Pieter Wuille
58bc86e37f Check for canonical public keys and signatures
Only enabled inside tests for now.
2012-09-21 01:24:25 +02:00
xanatos
fdfdb5cd7d = instead of == in multisig_tests.cpp 2012-06-21 21:37:49 +03:00
Pieter Wuille
1025440184 Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
This introduces internal types:
* CKeyID: reference (hash160) of a key
* CScriptID: reference (hash160) of a script
* CTxDestination: a boost::variant of the former two

CBitcoinAddress is retrofitted to be a Base58 encoding of a
CTxDestination. This allows all internal code to only use the
internal types, and only have RPC and GUI depend on the base58 code.

Furthermore, the header dependencies are a lot saner now. base58.h is
at the top (right below rpc and gui) instead of at the bottom. For the
rest: wallet -> script -> keystore -> key. Only keystore still requires
a forward declaration of CScript. Solving that would require splitting
script into two layers.
2012-05-24 20:26:19 +02:00
Pieter Wuille
fd61d6f506 Encapsulate public keys in CPubKey 2012-05-24 19:58:12 +02:00
Pieter Wuille
0d56f11ada Fix tests after 38067c18 2012-02-20 18:32:33 +01:00
Gavin Andresen
922e8e2929 Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16). 2012-01-13 10:22:23 -05:00
coderrr
6ec76ca09e make sure IsMine only returns true when we own all keys 2012-01-03 06:24:52 +07:00
Gavin Andresen
2e17ac83c6 Fix broken ExtractAddress (refactored, made callers check for addresses in keystore if they care) 2011-12-22 15:57:31 -05:00
Gavin Andresen
2a45a494b0 Use block times for 'hard' OP_EVAL switchover, and refactored EvalScript
so it takes a flag for how to interpret OP_EVAL.
Also increased IsStandard size of scriptSigs to 500 bytes, so
a 3-of-3 multisig transaction IsStandard.
2011-12-19 13:24:48 -05:00
Gavin Andresen
e679ec969c OP_EVAL implementation
OP_EVAL is a new opcode that evaluates an item on the stack as a script.
It enables a new type of bitcoin address that needs an arbitrarily
complex script to redeem.
2011-12-19 12:40:19 -05:00
Gavin Andresen
bf798734db Support 3 new multisignature IsStandard transactions
Initial support for (a and b), (a or b), and 2-of-3 escrow
transactions (where a, b, and c are keys).
2011-12-19 12:40:19 -05:00