Commit graph

634 commits

Author SHA1 Message Date
Pieter Wuille 9e38d0f745 Separate core memory usage computation in core_memusage.h 2015-07-20 11:17:53 -04:00
Wladimir J. van der Laan c52e8b300a
Merge pull request #6379
9cc9152 rpc: Accept scientific notation for monetary amounts in JSON (Wladimir J. van der Laan)
2015-07-10 16:50:46 +02:00
Wladimir J. van der Laan 9cc91523db rpc: Accept scientific notation for monetary amounts in JSON
Add a function `ParseFixedPoint` that parses numbers according
to the JSON number specification and returns a 64-bit integer.

Then this in `AmountFromValue`, rather than `ParseMoney`.

Also add lots of tests (thanks to @jonasschnelli for some of them).

Fixes issue #6297.
2015-07-10 15:43:26 +02:00
Wladimir J. van der Laan 7fc25c2e5d
Merge pull request #6368
cb54d17 CLTV: Add more tests to improve coverage (Esteban Ordano)
2015-07-09 11:20:17 +02:00
Wladimir J. van der Laan 133601f6a5 tests: Fix bitcoin-tx signing testcase
Fixes wrong scriptPubkey problem, which caused the transaction to
not actually be signed.
2015-07-07 18:26:38 +02:00
Esteban Ordano cb54d17355 CLTV: Add more tests to improve coverage
Four cases included:

* The CLTV operand type mismatches the tx locktime. In the script it is
  1 (interpreted as block height), but in the tx is 500000000
  (interpreted as date)
* The stack is empty when executing OP_CLTV
* The tx is final by having only one input with MAX_INT sequence number
* The operand for CLTV is negative (after OP_0 OP_1 OP_SUB)
2015-07-06 13:09:37 -07:00
Wladimir J. van der Laan 9546a977d3
Merge pull request #6335
9238ecb Policy: MOVEONLY: 3 functions to policy.o: (Luke Dashjr)
627b9de Policy: MOVEONLY: Create policy/policy.h with some constants (Jorge Timón)
2015-07-06 18:54:20 +02:00
Jonas Schnelli 177a0e4914 Adding CSubNet constructor over a single CNetAddr 2015-07-02 20:44:27 +02:00
Jonas Schnelli 409bccfbf5 use CBanEntry as object container for banned nodes
- added a reason enum for a ban
- added creation time for a ban

Using CBanEntry as container will keep banlist.dat extenable.
2015-07-02 20:29:36 +02: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
Jorge Timón 627b9deff4 Policy: MOVEONLY: Create policy/policy.h with some constants 2015-06-26 17:59:07 +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
Jonas Schnelli 77aeb7c964 UniValue: don't escape solidus, keep espacing of reverse solidus 2015-06-25 08:10:08 +02:00
Wladimir J. van der Laan 91389e51c7
Merge pull request #6088
2085895 fundrawtransaction tests (Jonas Schnelli)
21bbd92 Add fundrawtransaction RPC method (Matt Corallo)
1e0d1a2 Add FundTransaction method to wallet (Matt Corallo)
2d84e22 Small tweaks to CCoinControl for fundrawtransaction (Matt Corallo)
9b4e7d9 Add DummySignatureCreator which just creates zeroed sigs (Pieter Wuille)
2015-06-23 12:40:00 +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
Jonas Schnelli 932687bc10 setban: add IPv6 tests 2015-06-19 13:51:42 +02:00
Jonas Schnelli 4e36e9bcc7 setban: rewrite to UniValue, allow absolute bantime 2015-06-17 21:40:55 +02:00
Jonas Schnelli 433fb1a95d [RPC] extend setban to allow subnets 2015-06-17 21:40:55 +02:00
Jonas Schnelli 1086ffba26 [QA] add setban/listbanned/clearbanned tests 2015-06-17 21:40:55 +02:00
Wladimir J. van der Laan 8ccc07c077
Merge pull request #6256
65b9454 Use best header chain timestamps to detect partitioning (Gavin Andresen)
2015-06-12 16:44:36 +02:00
Daniel Kraft 0cc7b2352e Fix univalue handling of \u0000 characters.
Univalue's parsing of \u escape sequences did not handle NUL characters
correctly.  They were, effectively, dropped.  The extended test-case
fails with the old code, and is fixed with this patch.
2015-06-11 12:09:05 +02:00
Matt Corallo 21bbd920e5 Add fundrawtransaction RPC method 2015-06-11 01:03:23 -07:00
Wladimir J. van der Laan 8d9f0a6069
Merge pull request #5927
dce8360 Reduce checkpoints' effect on consensus. (Pieter Wuille)
2015-06-10 10:33:12 +02:00
Wladimir J. van der Laan 9c93ee5ceb
Merge pull request #6222
efd4444 Explicitly set tx.nVersion for the genesis block and mining tests (Mark Friedenbach)
2015-06-10 09:48:00 +02:00
Wladimir J. van der Laan 643114f539
Merge pull request #6239
7d8ffac Changes necessary now that zero values accepted in AmountFromValue (Wladimir J. van der Laan)
a04bdef Get rid of fPlus argument to FormatMoney (Wladimir J. van der Laan)
4b4b9a8 Don't go through double in AmountFromValue and ValueFromAmount (Wladimir J. van der Laan)
2015-06-09 18:38:33 +02:00
Gavin Andresen 65b9454503
Use best header chain timestamps to detect partitioning
The partition checking code was using chainActive timestamps
to detect partitioning; with headers-first syncing, it should use
(and with this pull request, does use) pIndexBestHeader timestamps.

Fixes issue #6251
2015-06-08 16:34:58 -04:00
Jonas Schnelli c946ebed5e fix util_tests.cpp clang warnings
was introduced with #6121
2015-06-06 10:12:12 +02:00
Wladimir J. van der Laan 7d8ffac186 Changes necessary now that zero values accepted in AmountFromValue
- Add an accept test for zero amounts, and a reject test for negative
  amounts
- Remove ugly hack in `settxfee` that is no longer necessary
- Do explicit zero checks in wallet RPC functions
- Don't add a check for zero amounts in `createrawtransaction` - this
  could be seen as a feature
2015-06-06 09:41:12 +02:00
Wladimir J. van der Laan a04bdefbeb Get rid of fPlus argument to FormatMoney
It's never used with any other value than false, the default.
2015-06-06 09:30:41 +02:00
Jonas Schnelli 44c7474446 univalue: add type check unit tests 2015-06-04 13:58:14 +02:00
Wladimir J. van der Laan 7e98a3c642 util: Add ParseInt64 and ParseDouble functions
Strict parsing functions for other numeric types.

- ParseInt64 analogous to ParseInt32, but for 64-bit values.
- ParseDouble for doubles.
- Make all three Parse* functions more strict (e.g. reject whitespace on
  the inside)

Also add tests.
2015-06-04 13:18:46 +02:00
Wladimir J. van der Laan 043df2b568 Simplify RPCclient, adapt json_parse_error test
# Conflicts:
#	src/test/rpc_tests.cpp
2015-06-04 13:18:35 +02:00
Jonas Schnelli 519eedeba7 fix univalue json parse tests 2015-06-04 10:35:36 +02:00
Jonas Schnelli 9a8897f4ac Remove JSON Spirit wrapper, remove JSON Spirit leftovers
- implement find_value() function for UniValue
- replace all Array/Value/Object types with UniValues, remove JSON Spirit to UniValue wrapper
- remove JSON Spirit sources
2015-06-04 09:16:21 +02:00
Jonas Schnelli 3df0411ad9 remove JSON Spirit UniValue wrapper 2015-06-04 09:16:06 +02:00
Jonas Schnelli 1f263c899e fix rpc unit test, plain numbers are not JSON compatible object
UniValues read() does only read valid json.
2015-06-04 09:16:06 +02:00
Jonas Schnelli 0c5b2cf69a univalue: add support for real, fix percision and make it json_spirit compatible
- avoid breaking the API because of different number/percision handling
2015-06-04 09:16:06 +02:00
Jonas Schnelli 6c7bee0624 expicit set UniValue type to avoid empty values 2015-06-04 09:16:05 +02:00
Jonas Schnelli 53b4671a9d extend conversion to UniValue 2015-06-04 09:16:05 +02:00
Jeff Garzik 15982a8b69 Convert tree to using univalue. Eliminate all json_spirit uses. 2015-06-04 09:16:05 +02:00
Jeff Garzik efc7883772 UniValue: prefer .size() to .count(), to harmonize w/ existing tree 2015-06-04 09:16:05 +02:00
Wladimir J. van der Laan 9d60602444
Merge pull request #5875
aa8c827 P2P regression test for new AcceptBlock behavior (Suhas Daftuar)
9be0e68 Be stricter in processing unrequested blocks (Suhas Daftuar)
2015-06-03 16:20:58 +02:00
Wladimir J. van der Laan 4e157fc60d json: fail read_string if string contains trailing garbage
Change `read_string` to fail when not the entire input has been
consumed. This avoids unexpected, even dangerous behavior (fixes #6223).

The new JSON parser adapted in #6121 also solves this problem so in
master this is a temporary fix, but should be backported to older releases.

Also adds tests for the new behavior.
2015-06-03 12:18:40 +02:00
Mark Friedenbach efd44440d8 Explicitly set tx.nVersion for the genesis block and mining tests
If/when CTransaction::CURRENT_VERSION is incremented, this will break CChainParams and the miner tests. This fix sets the transaction version explicitly where we depend on the hash value (genesis block, proof of work checks).
2015-06-02 16:39:34 -07:00
Suhas Daftuar 9be0e6837b Be stricter in processing unrequested blocks
AcceptBlock will no longer process an unrequested block, unless it has not
been previously processed and has more work than chainActive.Tip()
2015-06-02 13:54:29 -04:00
Wladimir J. van der Laan 87550eefc1
Merge pull request #6183
28bf062 Fix off-by-one error w/ nLockTime in the wallet (Peter Todd)
2015-06-01 11:33:33 +02:00
Wladimir J. van der Laan c7c9af381c
Merge pull request #5669
da29ecb Consensus: MOVEONLY: Move CValidationState from main consensus/validation (jtimon)
27afcd8 Consensus: Refactor: Decouple CValidationState from main::AbortNode() (Cory Fields)
2015-05-27 15:00:02 +02:00
Peter Todd 28bf06236d
Fix off-by-one error w/ nLockTime in the wallet
Previously due to an off-by-one error the wallet ignored
nLockTime-by-height transactions that would be valid in the next block
even though they are accepted into the mempool. The transactions
wouldn't show up until confirmed, nor would they be included in the
unconfirmed balance. Similar to the mempool behavior fix in 665bdd3b,
the wallet code was calling IsFinalTx() directly without taking into
account the fact that doing so tells you if the transaction could have
been mined in the *current* block, rather than the next block.

To fix this we strip IsFinalTx() of non-consensus-critical
functionality, removing the default arguments, and add CheckFinalTx() to
check if a transaction will be final in the next block.
2015-05-27 05:51:33 -04:00
Wladimir J. van der Laan 182686cdbd
Merge pull request #6186
b45c50c Fix two problems in CSubNet parsing (Wladimir J. van der Laan)
19e8d7b Simplify code for CSubnet (Wladimir J. van der Laan)
2015-05-27 09:08:39 +02:00
Michael Ford 8697ff33ed Remove duplicate chainparams.h include from alert_tests 2015-05-26 17:16:21 +08:00