Commit Graph

9731 Commits

Author SHA1 Message Date
Andrew Chow c45cbaf69f Fix stopatheight
Moves stopatheight check into the ActivateBestChain loop so that the block height is actually checked and stopped at the appropriate time.
2017-06-09 13:40:45 -07:00
Pieter Wuille e241a63c23 Clarify prevector::erase and avoid swap-to-clear 2017-06-09 13:23:20 -07:00
Pieter Wuille 76f268b9bd
Merge #10521: Limit variable scope
90593ed92 Limit variable scope (practicalswift)

Tree-SHA512: 4719e303688a31aefbe1d239e86b21dd3c2045524e08bd628c6ba0c6c2a97de14d04305b9beafe0b1dcde7229793e6663168953f192e88ed409be5c30fd2a9a9
2017-06-09 13:09:24 -07:00
Matt Corallo 9417d7a336 Be much more agressive in AccessCoin docs.
While the current implementation is pretty free, there is a lot
of possibility for this to blow up in our face with future changes,
especially as the backing map gets tweaked.
2017-06-09 13:10:08 -04:00
Matt Corallo f58349ca85 Restore some assert semantics in sigop cost calculations
There are some similar asserts which are left removed in policy
and ATMP (policy code being broken isn't a huge deal, but if we
fail to verify some consensus rules, we should most definitely
crash).
2017-06-09 13:10:08 -04:00
Matt Corallo 3533fb4d33 Return a bool in SpendCoin to restore pre-per-utxo assert semantics
Since its free to do so, assert that Spends succeeded when we expect
them to.
2017-06-09 13:10:05 -04:00
practicalswift e53a0fa12a Remove duplicate includes 2017-06-09 15:39:37 +02:00
practicalswift dce82397c1 Comment out unused constant REJECT_DUST 2017-06-09 15:21:28 +02:00
practicalswift 49de096c2a Remove unused Boost includes 2017-06-09 10:25:26 +02:00
Gregory Maxwell bf376eaccc Return early in IsBanned.
I am not aware of any reason that we'd try to stop a ban-list timing
 side-channel and the prior code wouldn't be enough if we were.
2017-06-09 02:05:53 +00:00
practicalswift 3289ef4fe1 Remove unused constant MEMPOOL_GD_VERSION 2017-06-09 01:45:36 +02:00
Alex Morcos 525769853e Change semantics of HaveCoinInCache to match HaveCoin
Previously it was possible for HaveCoinInCache to return true for a spent
coin. It is more clear to keep the semantics the same. HaveCoinInCache is
used for two reasons:
- tracking coins we may want to uncache, in which case it is unlikely there
would be spent coins we could uncache (not dirty)
- optimistically checking whether we have already included a tx in the
blockchain, in which case a spent coin is not a reliable indicator that we have.
2017-06-08 16:56:50 -04:00
Wladimir J. van der Laan 29f80cd230
Merge #10545: Use list initialization (C++11) for maps/vectors instead of boost::assign::map_list_of/list_of
3fb81a8 Use list initialization (C++11) for maps/vectors instead of boost::assign::map_list_of/list_of (practicalswift)

Tree-SHA512: 63a9ac9ec5799472943dce1cd92a4b14e7f1fe12758a5fc4b1efceaf2c85a4ba71dad5ccc50813527f18b192e7714c076e2478ecd6ca0d452b24e88416f872f7
2017-06-08 20:26:40 +02:00
Russell Yanofsky 3ff1fa8c4a Use override keyword on CCoinsView overrides 2017-06-08 09:28:28 -04:00
Wladimir J. van der Laan 9c248e39f2
Merge #10481: Decodehextx scripts sanity check
ac4e438 Sanity check transaction scripts in DecodeHexTx (Andrew Chow)
5b75c47 Add a valid opcode sanity check to CScript (Andrew Chow)

Tree-SHA512: a516e95c274c9d131123150c798cae8bed75925e8a4d59469967dd7f1d49f7f8161e26afb61024b821bd8dcdffdfd0d19b8dcad20b39b1106820326d8d56904d
2017-06-08 13:36:48 +02:00
Wladimir J. van der Laan 35e7f13f68
Merge #10548: Use std::unordered_{map,set} (C++11) instead of boost::unordered_{map,set}
246a02f Use std::unordered_{map,set} (C++11) instead of boost::unordered_{map,set} (practicalswift)

Tree-SHA512: 35cd42012248174751e4b87efbc78689957f731d7710dea7e369974c6ec31b15b32d1537fb0d875c94c7ffb5046d9784735e218e5baeed96d525861dab6d4252
2017-06-08 12:45:34 +02:00
Wladimir J. van der Laan 71ab6e5538
Merge #10547: [tests] Use FastRandomContext instead of boost::random::{mt19937,uniform_int_distribution}
227ae9b [tests] Use FastRandomContext instead of boost::random::{mt19937,uniform_int_distribution} (practicalswift)

Tree-SHA512: 1bde6c8b9498051fa2eae4913eb1f5411adea8dea1511c0df859aea57a2a7db6f5839945ddf2eccdddfa322bceacad35a5d875742db7d15e40dbea83185307bb
2017-06-08 12:39:43 +02:00
practicalswift 30c2d9db48 [tests] Remove unused function InsecureRandBytes(size_t len) 2017-06-08 09:43:54 +02:00
Wladimir J. van der Laan 6c2d81f34d
Merge #10524: [tests] Remove printf(...)
0abc588 [tests] Remove printf(...) (practicalswift)

Tree-SHA512: a56fa1edce050f5a44a53842223fc99e4e8ade413047e04f2064faeb5c4a418864a94471853d5c26a20608d1dcc18b9226d7fe15172f79a66cc5cf6e1443f7e9
2017-06-08 09:43:09 +02:00
Pieter Wuille e801084dec
Merge #10321: Use FastRandomContext for all tests
e94584858 scripted-diff: Use new naming style for insecure_rand* functions (Pieter Wuille)
2fcd9cc86 scripted-diff: Use randbits/bool instead of randrange where possible (Pieter Wuille)
2ada67852 Use randbits instead of ad-hoc emulation in prevector tests (Pieter Wuille)
5f0b04eed Replace rand() & ((1 << N) - 1) with randbits(N) (Pieter Wuille)
3ecabae36 Replace more rand() % NUM by randranges (Pieter Wuille)
efee1db21 scripted-diff: use insecure_rand256/randrange more (Pieter Wuille)
1119927df Add various insecure_rand wrappers for tests (Pieter Wuille)
124d13a58 Merge test_random.h into test_bitcoin.h (Pieter Wuille)
90620d66c scripted-diff: Rename cuckoo tests' local rand context (Pieter Wuille)
37e864eb9 Add FastRandomContext::rand256() and ::randbytes() (Pieter Wuille)

Tree-SHA512: d09705a3ec718ae792f7d66a75401903ba7b9c9d3fc36669d6e3b9242f0194738106be26baefc8a8e3fa6df7c9a35978c71c0c430278a028b331df23a3ea3070
2017-06-07 15:12:14 -07:00
John Newbery 6294f3283a gettxoutproof() should return consistent result
We can call gettxoutproof() with a list of transactions. Currently, if
the first transaction is unspent (and all other transactions are in the
same block), then the call will succeed. If the first transaction has
been spent, then the call will fail. The means that the following two
calls will return different results:

gettxoutproof(unspent_tx1, spent_tx1)
gettxoutproof(spent_tx1, unspent_tx1)

This commit makes behaviour independent of transaction ordering by looping
through all transactions provided and trying to find which block they're in.

This commit also increases the test coverage and tests more failure
cases for gettxoutproof()
2017-06-07 17:38:21 -04:00
Andrew Chow c8914b9dbb Have `make cov` optionally include branch coverage statistics
Added an option to configure to allow for branch coverage statistics gathering.

Disabled logprint macro when coverage testing is on so that unnecessary branches are not analyzed.
2017-06-07 14:19:01 -07:00
Andrew Chow ac4e438229 Sanity check transaction scripts in DecodeHexTx
Make sure that the scripts of decoded transactions are valid scripts.
2017-06-07 14:07:26 -07:00
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
Pieter Wuille e945848582 scripted-diff: Use new naming style for insecure_rand* functions
-BEGIN VERIFY SCRIPT-
sed -i 's/\<insecure_randbits(/InsecureRandBits(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_randbool(/InsecureRandBool(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_randrange(/InsecureRandRange(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_randbytes(/InsecureRandBytes(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_rand256(/InsecureRand256(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_rand(/InsecureRand32(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<seed_insecure_rand(/SeedInsecureRand(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
-END VERIFY SCRIPT-
2017-06-07 12:08:39 -07:00
practicalswift 0abc58890c [tests] Remove printf(...) 2017-06-07 20:42:54 +02:00
practicalswift 227ae9b34d [tests] Use FastRandomContext instead of boost::random::{mt19937,uniform_int_distribution} 2017-06-07 20:38:03 +02:00
Pieter Wuille 2fcd9cc86b scripted-diff: Use randbits/bool instead of randrange where possible
-BEGIN VERIFY SCRIPT-
sed -i 's/insecure_randbits(1)/insecure_randbool()/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(2)/insecure_randbool()/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(4)/insecure_randbits(2)/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(32)/insecure_randbits(5)/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(256)/insecure_randbits(8)/g' src/test/*_tests.cpp
-END VERIFY SCRIPT-
2017-06-07 11:35:16 -07:00
Pieter Wuille 2ada678521 Use randbits instead of ad-hoc emulation in prevector tests 2017-06-07 11:35:16 -07:00
Pieter Wuille 5f0b04eedc Replace rand() & ((1 << N) - 1) with randbits(N) 2017-06-07 11:35:13 -07:00
Pieter Wuille 3ecabae363 Replace more rand() % NUM by randranges 2017-06-07 11:34:55 -07:00
Pavlos Antoniou e5c616888b Fix instantiation and array accesses in class base_uint<BITS>
The implementation of base_uint::operator++(int) and base_uint::operator--(int) is now safer.
Array pn is accessed via index i after bounds checking has been performed on the index, rather than before.
The logic of the while loops has also been made more clear.

A compile time assertion has been added in the class constructors to ensure that BITS is a positive multiple of 32.
2017-06-07 17:21:29 +00:00
Russell Yanofsky 24e44c354d Don't return stale data from CCoinsViewCache::Cursor()
CCoinsViewCache doesn't actually support cursor iteration returning the
current contents of the cache, so raise an error when the cursor method is
called instead of returning a cursor that iterates over stale data.

Also update the gettxoutsetinfo RPC which was relying on the old behavior to be
explicit about which view it is returning data about.
2017-06-07 13:00:11 -04:00
Wladimir J. van der Laan 46311e792f
Merge #9672: Opt-into-RBF for RPC & bitcoin-tx
9a5a1d7 RPC/rawtransaction: createrawtransaction: Check opt_into_rbf when provided with either value (Luke Dashjr)
23b0fe3 bitcoin-tx: rbfoptin: Avoid touching nSequence if the value is already opting in (Luke Dashjr)
b005bf2 Introduce MAX_BIP125_RBF_SEQUENCE constant (Luke Dashjr)
575cde4 [bitcoin-tx] add rbfoptin command (Jonas Schnelli)
5d26244 [Tests] extend the replace-by-fee test to cover RPC rawtx features (Jonas Schnelli)
36bcab2 RPC/Wallet: Add RBF support for fundrawtransaction (Luke Dashjr)
891c5ee Wallet: Refactor FundTransaction to accept parameters via CCoinControl (Luke Dashjr)
578ec80 RPC: rawtransaction: Add RBF support for createrawtransaction (Luke Dashjr)

Tree-SHA512: 446e37c617c188cc3b3fd1e2841c98eda6f4869e71cb3249c4a9e54002607d0f1e6bef92187f7894d4e0746ab449cfee89be9f6a1a8831e25c70cf912eac1570
2017-06-07 15:31:40 +02:00
practicalswift 246a02fb14 Use std::unordered_{map,set} (C++11) instead of boost::unordered_{map,set} 2017-06-07 15:04:54 +02:00
Pieter Wuille be3e042c20
Merge #10523: Perform member initialization in initialization lists where possible
656dbd871 Perform member initialization in initialization lists where possible (practicalswift)

Tree-SHA512: 048380f4da23ab1eaaf471801a01dbd76f2235afb686c1489b30a6bac109195134afc83414b8378d3482a9042d537ec62d30136dadb9347cf06b07fb5c693208
2017-06-06 17:00:19 -07:00
MarcoFalke 75e898c094
Merge #10331: Share config between util and functional tests
8ad5bde Merge bctest.py into bitcoin-util-test.py (John Newbery)
95836c5 Use shared config file for functional and util tests (John Newbery)
89fcd35 Use an .ini config file for environment vars in bitcoin-util-test.py (John Newbery)
e9265df Change help_text in bitcoin-util-test.py to a docstring. (John Newbery)
ce58e93 Change bitcoin-util-test.py to use Python3 (John Newbery)

Tree-SHA512: 66dab0b4a8546aee0dfaef134a165f1447aff4c0ec335754bbc7d9e55909721c62f09cdbf4b22d02ac1fcd5a9b66780f91e1cc4d8687fae7288cc9072a23a78f
2017-06-06 23:55:24 +02:00
MarcoFalke 2805d606bc
Merge #10522: [wallet] Remove unused variables
a8c09af Remove unused variables (practicalswift)

Tree-SHA512: 34807dc3a0471c83b086f430b66465602c8f6a3a158b54ace2ec8afb746f1f5907f7dfcde5a4bad4041df9721ec46b61681b2dbf89725c9c8c4c5ad0ca99f78f
2017-06-06 23:51:33 +02:00
MarcoFalke 32751807c9
Merge #10538: [trivial] Fix typo: "occurrences" (misspelled as "occurrances")
b083db6 [trivial] Fix typo: "occurrences" (misspelled as "occurrances") (practicalswift)

Tree-SHA512: 5141526dbbbbe797ef103fcbdc0a1318648214973214607e35cc0e99abfc4dd547e3ef15fe21976c53a78b03dff140fe76e5c92a0f7e7d2b08081215983a8616
2017-06-06 23:48:10 +02:00
Luke Dashjr c237bd750e wallet: Update formatting 2017-06-06 21:20:22 +00:00
Luke Dashjr 9cbe8c80ba wallet: Forbid -salvagewallet, -zapwallettxes, and -upgradewallet with multiple wallets 2017-06-06 21:20:22 +00:00
Luke Dashjr a2a5f3f0f0 wallet: Base backup filenames on original wallet filename 2017-06-06 21:20:22 +00:00
Luke Dashjr b823a4c9f6 wallet: Include actual backup filename in recovery warning message 2017-06-06 21:17:09 +00:00
Luke Dashjr 84dcb45017 Bugfix: wallet: Fix warningStr, errorStr argument order 2017-06-06 21:17:09 +00:00
Luke Dashjr 008c360083 Wallet: Move multiwallet sanity checks to CWallet::Verify, and do other checks on all wallets 2017-06-06 21:17:09 +00:00
Luke Dashjr 0f08575be2 Wallet: Support loading multiple wallets if -wallet used more than once 2017-06-06 21:17:09 +00:00
Luke Dashjr b124cf04ea Wallet: Replace pwalletMain with a vector of wallet pointers 2017-06-06 21:17:09 +00:00
practicalswift 3fb81a8480 Use list initialization (C++11) for maps/vectors instead of boost::assign::map_list_of/list_of 2017-06-06 21:29:16 +02:00
Matt Corallo 40796e1a9d Remove references to priority that snuck back in in 870824e9.
The "priority" field should be appropriately marked as a "dummy"
value and noted that it is deprecated and will likely be removed.
2017-06-06 15:13:37 -04:00
Mario Dian 24980a3e40 Make functions in validation.cpp static and pass chainparams
Fix bugs as per PR comment

Change bool static to static bool
2017-06-06 22:21:30 +08:00
Wladimir J. van der Laan 300f8e7a82
Merge #9909: tests: Add FindEarliestAtLeast test for edge cases
cf66f04 Add FindEarliestAtLeast test for edge cases (Russell Yanofsky)

Tree-SHA512: bed2e9b2eefe0014414f1be8f0ba236b1dcc6744a670ffa546100c62817dd06a117cc62cdff80c4988d2b374cae9a57f2bb135fc582ffb51ca2d34ab07bb3fe0
2017-06-06 15:51:45 +02:00
Wladimir J. van der Laan 980deaf0b1
Merge #10252: RPC/Mining: Restore API compatibility for prioritisetransaction
870824e RPC/Mining: Restore API compatibility for prioritisetransaction (Luke Dashjr)

Tree-SHA512: eb507500dc5ba8d17521f34f3d6eae45aa9259c38d15a75dc3e3ad45774ffb53db943be1720a97e6cd5f08e7832801e27ffb636da081a58955018b6f8f9d8fba
2017-06-06 15:49:38 +02:00
practicalswift b083db617a [trivial] Fix typo: "occurrences" (misspelled as "occurrances")
Typo introduced in 000391132608343c66488d62625c714814959bc9:

$ git blame src/coins.cpp | grep occurrances
00039113 (2017-04-25 11:29:29 -0700  89)         // deal with the pre-BIP30 occurrances of duplicate coinbase transactions.
2017-06-06 15:06:23 +02:00
Wladimir J. van der Laan 67700b3924
Merge #10345: [P2P] Timeout for headers sync
76f7481 Add timeout for headers sync (Suhas Daftuar)
e265200 Delay parallel block download until chain has sufficient work (Suhas Daftuar)

Tree-SHA512: e7f5468b7defe67d4d2d5c976bc129dba2b32b2ea52d3ff33b9cbff5c3b5b799be867653f1bcd354340d707d76dcadf2da4588abf6d6ec4a06672cdc5e1101eb
2017-06-06 12:23:56 +02:00
Wladimir J. van der Laan 16f6c98fa8
Merge #10426: Replace bytes_serialized with bogosize
8b22af3 Replace bytes_serialized with bogosize (Pieter Wuille)

Tree-SHA512: e70a981bbb977329f9e324c45f9a1346ec9aacfbbad5474e608cdd1f852257502bb7db8003fd578260a609e45d1a9cf87ce96df9c4187d92d50f60a209e232ce
2017-06-06 11:46:31 +02:00
Wladimir J. van der Laan 323a46e034
Merge #10463: Names: BIP9 vs versionbits
b463bc9 scripted-diff: s/BIP9DeploymentInfo/VBDeploymentInfo/ (Jorge Timón)
29c0719 Rename -bip9params to -vbparams (shaolinfry)

Tree-SHA512: a8a2bf6e24a4a7fc82f784c78c0cd92472e9ba55ce3fb22dafef3eccdcfccb2da5a6078fbeec1a8a4b6ab1f1b226976c5aba964dd5e3d029a21b109a7c044374
2017-06-06 10:18:02 +02:00
Matt Corallo ec1271f2be Remove useless mapNextTx lookup in CTxMemPool::TrimToSize.
Prior to per-utxo CCoins, we checked that no other in-mempool tx
spent any of the given transaction's outputs, as we don't want to
uncache that entire tx in such a case. However, we now are checking
only that there exists no other mempool spends of the same output,
which should clearly be impossible after we removed the transaction
which was spending said output (barring massive mempool
inconsistency).

Thanks to @sdaftuar for the suggestion.
2017-06-05 21:46:14 -04:00
Luke Dashjr 9a5a1d7d45 RPC/rawtransaction: createrawtransaction: Check opt_into_rbf when provided with either value 2017-06-05 23:14:34 +00:00
Luke Dashjr 23b0fe34f5 bitcoin-tx: rbfoptin: Avoid touching nSequence if the value is already opting in 2017-06-05 23:14:34 +00:00
Luke Dashjr b005bf21a7 Introduce MAX_BIP125_RBF_SEQUENCE constant 2017-06-05 23:14:34 +00:00
Jonas Schnelli 575cde4605 [bitcoin-tx] add rbfoptin command 2017-06-05 23:13:24 +00:00
Luke Dashjr 36bcab2356 RPC/Wallet: Add RBF support for fundrawtransaction 2017-06-05 23:12:29 +00:00
Luke Dashjr 891c5eeec2 Wallet: Refactor FundTransaction to accept parameters via CCoinControl 2017-06-05 23:12:03 +00:00
Luke Dashjr 578ec80d4f RPC: rawtransaction: Add RBF support for createrawtransaction 2017-06-05 23:09:01 +00:00
Luke Dashjr 19b3648bb5 CWalletDB: Store the update counter per wallet 2017-06-05 22:27:57 +00:00
Luke Dashjr 74e8738961 Bugfix: ForceSetArg should replace entr(ies) in mapMultiArgs, not append 2017-06-05 21:04:42 +00:00
Luke Dashjr 23fb9adaea wallet: Move nAccountingEntryNumber from static/global to CWallet 2017-06-05 21:04:42 +00:00
Luke Dashjr 9d15d5548d Bugfix: wallet: Increment "update counter" when modifying account stuff 2017-06-05 21:04:42 +00:00
Luke Dashjr f28eb8020e Bugfix: wallet: Increment "update counter" only after actually making the applicable db changes to avoid potential races
Also does all "update counter" access via IncrementUpdateCounter
2017-06-05 21:04:42 +00:00
Suhas Daftuar 76f74811c4 Add timeout for headers sync
At startup, we choose one peer to serve us the headers chain, until
our best header is close to caught up.  Disconnect this peer if more
than 15 minutes + 1ms/expected_header passes and our best header
is still more than 1 day away from current time.
2017-06-05 16:33:35 -04:00
Pieter Wuille efee1db21a scripted-diff: use insecure_rand256/randrange more
-BEGIN VERIFY SCRIPT-
sed -i "s/\<GetRandHash(/insecure_rand256(/" src/test/*_tests.cpp
sed -i "s/\<GetRand(/insecure_randrange(/" src/test/*_tests.cpp src/test/test_bitcoin.cpp
sed -i 's/\<insecure_rand() % \([0-9]\+\)/insecure_randrange(\1)/g' src/test/*_tests.cpp
-END VERIFY SCRIPT-
2017-06-05 12:45:44 -07:00
Pieter Wuille 1119927df0 Add various insecure_rand wrappers for tests 2017-06-05 12:44:44 -07:00
Pieter Wuille 124d13a58c Merge test_random.h into test_bitcoin.h 2017-06-05 12:44:44 -07:00
Pieter Wuille 90620d66c9 scripted-diff: Rename cuckoo tests' local rand context
-BEGIN VERIFY SCRIPT-
sed -i 's/insecure_rand/local_rand_ctx/g' src/test/cuckoocache_tests.cpp
-END VERIFY SCRIPT-
2017-06-05 12:44:44 -07:00
Pieter Wuille 37e864eb9f Add FastRandomContext::rand256() and ::randbytes()
FastRandomContext now provides all functionality that the real Rand* functions
provide.
2017-06-05 12:44:44 -07:00
Pieter Wuille 8b22af3ee5 Replace bytes_serialized with bogosize 2017-06-05 12:43:45 -07:00
Jorge Timón 1238f13cf6
scripted-diff: Remove PAIRTYPE
-BEGIN VERIFY SCRIPT-
sed -i 's/PAIRTYPE(\([^,]*\), \([^\)]*\))/std::pair<\1, \2>/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
sed -i ':a;N;$!ba;s/#define std::pair<t1, t2>    std::pair<t1, t2>\n//' ./src/utilstrencodings.h ;
-END VERIFY SCRIPT-
2017-06-05 20:14:53 +02:00
Jorge Timón 18dc3c3962
scripted-diff: Remove Q_FOREACH
-BEGIN VERIFY SCRIPT-
sed -i 's/Q_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
2017-06-05 20:11:01 +02:00
Jorge Timón 7c00c26726
scripted-diff: Fully remove BOOST_FOREACH
-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
2017-06-05 20:10:50 +02:00
Jorge Timón a5410ac5ec
Small preparations for Q_FOREACH, PAIRTYPE and #include <boost/foreach.hpp> removal 2017-06-05 20:02:30 +02:00
Wladimir J. van der Laan 9fec4da0be
Merge #9740: Add friendly output to dumpwallet
164019d Add dumpwallet output test (aideca)
9f82134 Add friendly output to dumpwallet refs #9564 (aideca)

Tree-SHA512: 913fcf18d42eebe34173f1f2519973494b1ad2d86d125ff4bf566d6c64aa501c02f8831e6f44812cd87a46916f61c6f510146af406865b31856d8336c173569f
2017-06-05 18:06:34 +02:00
Russell Yanofsky 9bb66ab660 Add RescanFromTime method and use from rpcdump
No change in behavior.
2017-06-05 09:59:58 -05:00
Russell Yanofsky ccf84bb9c1 Move birthday optimization out of ScanForWalletTransactions
This change has no effect on wallet behavior.

On wallet startup, the transaction scan avoids reading any blocks with
timestamps older than the wallet birthday (less than nTimeFirstKey -
TIMESTAMP_WINDOW). This block skipping code currently resides in
CWallet::ScanForWalletTransactions but it doesn't really belong there because
it makes the implementation unnecessarily fragile and hard to understand, and
it never has any effect except at startup (because all other callers do their
rescans based on timestamps other than, but always greater or equal to,
nTimeFirstKey).
2017-06-05 09:59:58 -05:00
Wladimir J. van der Laan 08d0390a5f
Merge #10403: Fix importmulti failure to return rescan errors
4d2d604 Fix importmulti failure to return rescan errors (Russell Yanofsky)

Tree-SHA512: e5e6d6c5a2bb7230e1bcac1903a4b766cd57bf781fade50c6c9cd5713cd3e768db0987cfda9699b57a53d3a0a60951b96dce5283b3d3ec1f954162c439bc932b
2017-06-05 16:41:02 +02:00
Wladimir J. van der Laan 0747d33498
Merge #10455: Simplify feebumper minimum fee code slightly
88b8f0b Simplify feebumper minimum fee code slightly (Russell Yanofsky)

Tree-SHA512: 4465daef63936860d016a7fd7fd31ce62878d87cb943a90f321b07a40accdc5e7970d99de46b2bc924eb0b422144d6f01649855949395518790ecd05d300ee52
2017-06-05 16:38:07 +02:00
Wladimir J. van der Laan cec9e1ea61
Merge #10422: Fix timestamp in fee estimate debug message
8d4f401 Fix timestamp in fee estimate debug message (Alex Morcos)

Tree-SHA512: eb015ddbb9f52f0f84706a16e503d2894dceed4e796979858ca8bdd7f0ec15bf7646ca3f411b06ff099308c91ca498916778e6bd52db00365baaae1d2f4218f2
2017-06-05 16:24:26 +02:00
Wladimir J. van der Laan e103b3ff1e
Merge #10514: Bugfix: missing == 0 after randrange
9aa215b Bugfixes: missing == 0 after randrange (Pieter Wuille)

Tree-SHA512: 160657ac09553f23ad7a3966c753a30ba938ce6f7ccfd34a4ef0d05d73d712362f7eef97e44a96e37a181b8347caa9d8e1584cc4485f69674ab2de3d8a247373
2017-06-05 16:09:59 +02:00
Wladimir J. van der Laan a7e3c2814c rpc: Add listen address to incoming connections in `getpeerinfo`
This adds the listening address on which incoming connections were received to the
CNode and CNodeStats structures.

The address is reported in `getpeerinfo`.

This can be useful for distinguishing connections received on different listening ports
(e.g. when using a different listening port for Tor hidden service connections)
or different networks.
2017-06-05 13:35:30 +02:00
practicalswift 90593ed92c Limit variable scope 2017-06-05 00:52:36 +02:00
Pieter Wuille 400fdd08cc
Merge #10471: Denote functions CNode::GetRecvVersion() and CNode::GetRefCount() as const
5f672ca8c net: Denote some CNode functions const (Pavlos Antoniou)

Tree-SHA512: f6d13d8002a4145fd87b34b35a739284e4a9b1af834bba109d324eccddb684eccb817553ba76102eb5b5819cab37f938b4ba74fdbda7c5386d00747b3024cd81
2017-06-04 11:32:06 -07:00
practicalswift 656dbd871a Perform member initialization in initialization lists where possible 2017-06-04 01:09:48 +02:00
practicalswift a8c09affce Remove unused variables 2017-06-03 23:54:24 +02:00
Pieter Wuille 098b01dc58
Merge #10500: Avoid CWalletTx copies in GetAddressBalances and GetAddressGroupings
b9b814a38 Avoid CWalletTx copies in GetAddressBalances and GetAddressGroupings (Russell Yanofsky)

Tree-SHA512: 96a0612ca460ba1bfb3921f3aa348400fd3afa12c40f2ca1f3f04068b1574fe824d577e0123013d8898a4990084316dc1dfb541331849f0996ceff7f4eb25e6b
2017-06-02 16:10:33 -07:00
Pieter Wuille 9aa215bff9 Bugfixes: missing == 0 after randrange 2017-06-02 13:47:59 -07:00
Wladimir J. van der Laan 00d3692396
Merge #10323: Update to latest libsecp256k1 master
e7c1b44 Squashed 'src/secp256k1/' changes from 8225239..84973d3 (Pieter Wuille)

Tree-SHA512: 3e1ba6e6ad9d68170a1a60bd963f2dbaa8b0ae592cc562e6cd23b2c7653f0b8016e4c682681ae2fb3714106a41f8b89708e16e8f52a42ff3db59fc28262eea0b
2017-06-02 10:58:49 +02:00
Pieter Wuille d9bec888f1 Use REJECT_DUPLICATE for already known and conflicted txn 2017-06-02 00:18:47 -07:00
Pieter Wuille cf68a488a4 Deduplicate addrdb.cpp and use CHashWriter/Verifier 2017-06-01 16:42:07 -07:00
Pieter Wuille 7cc2c670e3
Merge #10506: Fix bumpfee test after #10449
8906a9a0d Fix bumpfee test after #10449 (Russell Yanofsky)

Tree-SHA512: 0838c7696499baf0fb5ee6edf0b081752d6c37578360a7f24a7e9c700598cbc14ff95826f2f5124cca805d2609470a052bc7309211874b13be7ac1ff9e911a34
2017-06-01 16:28:37 -07:00
Pieter Wuille 1088b02f0c
Merge #10195: Switch chainstate db and cache to per-txout model
589827975 scripted-diff: various renames for per-utxo consistency (Pieter Wuille)
a5e02bc7f Increase travis unit test timeout (Pieter Wuille)
73de2c1ff Rename CCoinsCacheEntry::coins to coin (Pieter Wuille)
119e552f7 Merge CCoinsViewCache's GetOutputFor and AccessCoin (Pieter Wuille)
580b02309 [MOVEONLY] Move old CCoins class to txdb.cpp (Pieter Wuille)
8b25d2c0c Upgrade from per-tx database to per-txout (Pieter Wuille)
b2af357f3 Reduce reserved memory space for flushing (Pieter Wuille)
41aa5b79a Pack Coin more tightly (Pieter Wuille)
97072d668 Remove unused CCoins methods (Pieter Wuille)
ce23efaa5 Extend coins_tests (Pieter Wuille)
508307968 Switch CCoinsView and chainstate db from per-txid to per-txout (Pieter Wuille)
4ec0d9e79 Refactor GetUTXOStats in preparation for per-COutPoint iteration (Pieter Wuille)
13870b56f Replace CCoins-based CTxMemPool::pruneSpent with isSpent (Pieter Wuille)
05293f3cb Remove ModifyCoins/ModifyNewCoins (Pieter Wuille)
961e48397 Switch tests from ModifyCoins to AddCoin/SpendCoin (Pieter Wuille)
8b3868c1b Switch CScriptCheck to use Coin instead of CCoins (Pieter Wuille)
c87b957a3 Only pass things committed to by tx's witness hash to CScriptCheck (Matt Corallo)
f68cdfe92 Switch from per-tx to per-txout CCoinsViewCache methods in some places (Pieter Wuille)
000391132 Introduce new per-txout CCoinsViewCache functions (Pieter Wuille)
bd83111a0 Optimization: Coin&& to ApplyTxInUndo (Pieter Wuille)
cb2c7fdac Replace CTxInUndo with Coin (Pieter Wuille)
422634e2f Introduce Coin, a single unspent output (Pieter Wuille)
7d991b55d Store/allow tx metadata in all undo records (Pieter Wuille)
c3aa0c119 Report on-disk size in gettxoutsetinfo (Pieter Wuille)
d34242430 Remove/ignore tx version in utxo and undo (Pieter Wuille)
7e0032290 Add specialization of SipHash for 256 + 32 bit data (Pieter Wuille)
e484652fc Introduce CHashVerifier to hash read data (Pieter Wuille)
f54580e7e error() in disconnect for disk corruption, not inconsistency (Pieter Wuille)
e66dbde6d Add SizeEstimate to CDBBatch (Pieter Wuille)

Tree-SHA512: ce1fb1e40c77d38915cd02189fab7a8b125c7f44d425c85579d872c3bede3a437760997907c99d7b3017ced1c2de54b2ac7223d99d83a6658fe5ef61edef1de3
2017-06-01 16:20:27 -07:00
Pieter Wuille 589827975f scripted-diff: various renames for per-utxo consistency
Thanks to John Newberry for pointing these out.

-BEGIN VERIFY SCRIPT-
sed -i 's/\<GetCoins\>/GetCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<HaveCoins\>/HaveCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<HaveCoinsInCache\>/HaveCoinInCache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<IsPruned\>/IsSpent/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<FetchCoins\>/FetchCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<CoinsEntry\>/CoinEntry/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<vHashTxnToUncache\>/coins_to_uncache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<vHashTxToUncache\>/coins_to_uncache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<fHadTxInCache\>/had_coin_in_cache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<coinbaseids\>/coinbase_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<disconnectedids\>/disconnected_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<duplicateids\>/duplicate_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<oldcoins\>/old_coin/g' src/test/coins_tests.cpp
sed -i 's/\<origcoins\>/orig_coin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
-END VERIFY SCRIPT-
2017-06-01 13:15:25 -07:00
Pieter Wuille 73de2c1ff3 Rename CCoinsCacheEntry::coins to coin 2017-06-01 13:15:25 -07:00
Pieter Wuille 119e552f7c Merge CCoinsViewCache's GetOutputFor and AccessCoin
They're doing the same thing now.
2017-06-01 13:15:25 -07:00
Pieter Wuille 580b023092 [MOVEONLY] Move old CCoins class to txdb.cpp
It's only used for upgrading from the old database anymore.
2017-06-01 13:15:25 -07:00
Pieter Wuille 8b25d2c0ce Upgrade from per-tx database to per-txout 2017-06-01 13:15:24 -07:00
Pieter Wuille b2af357f39 Reduce reserved memory space for flushing
As the maximum amount of data that can be pulled into the cache due to
a block validation is much lower now (at most one CCoin entry per input
and per output), reduce the conservative estimate used to determine
flushing time.
2017-06-01 13:15:06 -07:00
Pieter Wuille 41aa5b79a3 Pack Coin more tightly 2017-06-01 13:15:06 -07:00
Pieter Wuille 97072d6685 Remove unused CCoins methods 2017-06-01 13:15:03 -07:00
Pieter Wuille ce23efaa5c Extend coins_tests 2017-06-01 12:59:41 -07:00
Pieter Wuille 5083079688 Switch CCoinsView and chainstate db from per-txid to per-txout
This patch makes several related changes:
* Changes the CCoinsView virtual methods (GetCoins, HaveCoins, ...)
  to be COutPoint/Coin-based rather than txid/CCoins-based.
* Changes the chainstate db to a new incompatible format that is also
  COutPoint/Coin based.
* Implements reconstruction code for hash_serialized_2.
* Adapts the coins_tests unit tests (thanks to Russell Yanofsky).

A side effect of the new CCoinsView model is that we can no longer
use the (unreliable) test for transaction outputs in the UTXO set
to determine whether we already have a particular transaction.
2017-06-01 12:59:38 -07:00
Pieter Wuille 4ec0d9e794 Refactor GetUTXOStats in preparation for per-COutPoint iteration 2017-06-01 12:43:16 -07:00
Pieter Wuille 13870b56fc Replace CCoins-based CTxMemPool::pruneSpent with isSpent 2017-06-01 12:43:16 -07:00
Pieter Wuille 05293f3cb7 Remove ModifyCoins/ModifyNewCoins 2017-06-01 12:43:16 -07:00
Pieter Wuille 961e483979 Switch tests from ModifyCoins to AddCoin/SpendCoin 2017-06-01 12:43:12 -07:00
Russell Yanofsky 8906a9a0d2 Fix bumpfee test after #10449
Failure reported by Jorge Timón <jtimon@jtimon.cc>
https://github.com/bitcoin/bitcoin/pull/10449#issuecomment-305556569
2017-06-01 15:35:44 -04:00
Pieter Wuille 8b3868c1b4 Switch CScriptCheck to use Coin instead of CCoins 2017-06-01 11:56:06 -07:00
Matt Corallo c87b957a32 Only pass things committed to by tx's witness hash to CScriptCheck
This clarifies a bit more the ways in which the new script execution
cache could break consensus in the future if additional data from
the CCoins object were to be used as a part of script execution.

After this change, any such consensus breaks should be very visible
to reviewers, hopefully ensuring no such changes can be made.
2017-06-01 11:56:06 -07:00
Pieter Wuille f68cdfe92b Switch from per-tx to per-txout CCoinsViewCache methods in some places 2017-06-01 11:56:06 -07:00
Pieter Wuille 0003911326 Introduce new per-txout CCoinsViewCache functions
The new functions are:
* CCoinsViewCache::AddCoin: Add a single COutPoint/Coin pair.
* CCoinsViewCache::SpendCoin: Remove a single COutPoint.
* AddCoins: utility function that invokes CCoinsViewCache::AddCoin for
  each output in a CTransaction.
* AccessByTxid: utility function that searches for any output with
  a given txid.
* CCoinsViewCache::AccessCoin: retrieve the Coin for a COutPoint.
* CCoinsViewCache::HaveCoins: check whether a non-empty Coin exists
  for a given COutPoint.

The AddCoin and SpendCoin methods will eventually replace ModifyCoins
and ModifyNewCoins, AddCoins will replace CCoins::FromTx, and the new
AccessCoins and HaveCoins functions will replace their per-txid
counterparts.

Note that AccessCoin for now returns a copy of the Coin object. In a
later commit it will be change to returning a const reference (which
keeps working in all call sites).
2017-06-01 11:56:06 -07:00
Pieter Wuille bd83111a0f Optimization: Coin&& to ApplyTxInUndo
This avoids a prevector copy in ApplyTxInUndo.
2017-06-01 11:56:06 -07:00
Pieter Wuille cb2c7fdac2 Replace CTxInUndo with Coin
The earlier CTxInUndo class now holds the same information as the Coin
class. Instead of duplicating functionality, replace CTxInUndo with a
serialization adapter for Coin.
2017-06-01 11:56:06 -07:00
Wladimir J. van der Laan 39039b12a7
Merge #10475: [RPC] getmempoolinfo mempoolminfee is a BTC/KB feerate
f128f78 getmempool mempoolminfee is a BTC/KB feerate (Gregory Sanders)

Tree-SHA512: 5b32ffc0d2ba7ca623d4ce450fb67855d17b4fa8c3ffb8570a63dc53b3d476d52b39ad6190ac4357dbf01f6b535fa187cd8c34175a16469e9b00097e3bf2e2bc
2017-06-01 19:21:26 +02:00
Russell Yanofsky b9b814a38e Avoid CWalletTx copies in GetAddressBalances and GetAddressGroupings 2017-06-01 11:48:29 -04:00
Pavlos Antoniou 5f672ca8c1 net: Denote some CNode functions const 2017-06-01 17:21:03 +02:00
Jonas Schnelli 64beb13179
Merge #10449: Overhaul Qt fee bumper
6d7104c99 [Qt] make sure transaction table entry gets updated after bump (Jonas Schnelli)
32325a3f5 [Qt] hide bump context menu action if tx already has been bumped (Jonas Schnelli)

Tree-SHA512: d3e5991145879b7f6b212d9d9c6f423609dc8e6fa7f6feb7df931691f1dec2acb6ab162c2fb7e758d3ca3f3fb14363df2f50f0e83e83068da5cc7e6de35e69d2
2017-06-01 16:05:02 +02:00
Wladimir J. van der Laan cb1716acc7
Merge #10441: net: only enforce expected services for half of outgoing connections
b6fbfc2 net: only enforce the services required to connect (Cory Fields)

Tree-SHA512: 88943bff63213a734f3c96c45760cadaeb9ba18287c8a20c279851ebaf058a334c969028fb2180f155508e3eea4b838147382e4f2b655e7a9aa098eadc81d53e
2017-06-01 13:24:36 +02:00
Wladimir J. van der Laan b6b150b016
Merge #10469: Fixing typo in rpcdump.cpp
16d94d3 Fixing typo in rpcdump.cpp (James Evans)

Tree-SHA512: 84ef1b91c719131196ebed6b865e282b77bee7699614e15884ba59010239a3bbc1380dc8f856c83338f071e3eb3ca41c6b10f830816e6c794531cf6a965d63a9
2017-06-01 13:19:36 +02:00
Wladimir J. van der Laan f259263a7b
Merge #10447: Make bitcoind invalid argument error message specific
cd5622d Make bitcoind invalid argument error message specific (Wladimir J. van der Laan)

Tree-SHA512: 78999b9359685c4090f9a112e1d02bdddac22173f5f04600773b042acb9481ebb54d0f73d9d6d74249f845f497927a58d59de69bf33e3dccf096c3c80c7ebf6b
2017-06-01 10:51:03 +02:00
Wladimir J. van der Laan ef2d062c9f
Merge #10450: Fix bumpfee rpc "errors" return value
1b6602f Fix bumpfee rpc "errors" return value (Russell Yanofsky)

Tree-SHA512: a55d4dbe28c75f31fde3b7de60479265bb8f3777f432d1db321f1dd848d5274c353f757b09ed3cad9c69c08acbf3906679d27052267db943ab2b19629f79bd81
2017-06-01 10:48:19 +02:00
practicalswift 5a9b508279 [trivial] Add end of namespace comments 2017-05-31 22:21:25 +02:00
Wladimir J. van der Laan 18ba984140
Merge #10467: add SeedNodes to CConnman::Options
5d67526 add SeedNodes to CConnman::Options (Marko Bencun)

Tree-SHA512: d732ab08697419f896d9598fa3c30030ddbe3b82a99a398d813ebcd5e1fc610ad1043fe0f4c51a7ec5c4d70ce93a9ac5a5c7a91fcaae046ec4f1f7c41523a360
2017-05-31 17:41:10 +02:00
Wladimir J. van der Laan 5dd69ce551
Merge #10479: [trivial] Fix comment for ForceSetArg()
42a83e5 [trivial] Fix comment for ForceSetArg() (John Newbery)

Tree-SHA512: 596db8b4bb01bca18908e254e5b364d3d4fcb0ea49d7d54314c65106e497efed65a877d80740bff88e090aeb772be1e46d4571ecca9b9263578f3f680f0bd0ce
2017-05-31 17:16:16 +02:00
Jonas Schnelli c1c9a95379
Merge #10454: Fix broken q4 test build
620444bd5 Fix broken q4 test build (Russell Yanofsky)

Tree-SHA512: 3247458541e5586e5a2cfc0abda3c54f140c676603ea5a3bdc0d11aae335d0221bbc818fc5fa458242fd4bacd326fca1013fc0320d5c91b672b8ca9684fb7bf8
2017-05-31 10:38:30 +02:00
Pieter Wuille f94b7d5bfa
Merge #10464: Introduce static DoWarning (simplify UpdateTip)
f28514576 Introduce static DoWarning (simplify UpdateTip) (Jorge Timón)

Tree-SHA512: 58b39f00bc921d47d199ef1cc15e9e36f918ec86e9182de46dc2f24fa9474853a92b18d330a274a3ea7c9b001681fdfa3d86aa2bbebb5c92ac8c5a6f7690dfc1
2017-05-30 17:23:30 -07:00
Jorge Timón b463bc9215
scripted-diff: s/BIP9DeploymentInfo/VBDeploymentInfo/
-BEGIN VERIFY SCRIPT-
sed -i 's/BIP9DeploymentInfo/VBDeploymentInfo/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
2017-05-30 19:21:52 +02:00
shaolinfry 29c07196d0
Rename -bip9params to -vbparams 2017-05-30 19:21:51 +02:00
Wladimir J. van der Laan acd9957b72
Merge #9208: Improve DisconnectTip performance
c1235e3 Add RecursiveDynamicUsage overload for std::shared_ptr (Russell Yanofsky)
71f1903 Store disconnected block transactions outside mempool during reorg (Suhas Daftuar)
9decd64 [qa] Relax assumptions on mempool behavior during reorg (Suhas Daftuar)

Tree-SHA512: c160ad853a5cd060d0307af7606a0c77907497ed7033c9599b95e73d83f68fdfcd4214bd8a83db1c5b7a58022722b9de1ed2e6ea2e02f38a7b6c717f079dd0c6
2017-05-30 18:43:03 +02:00
John Newbery 42a83e5455 [trivial] Fix comment for ForceSetArg() 2017-05-30 08:21:16 -04:00
Marko Bencun 5d67526026 add SeedNodes to CConnman::Options
Start of a series of changes to clean up the instantiation of connman
by decoupling the command line arguments.
2017-05-30 09:21:47 +02:00
Wladimir J. van der Laan 5c63d665e5
Merge #10460: Broadcast address every day, not 9 hours
010d68e Broadcast address every day, not 9 hours (Pieter Wuille)

Tree-SHA512: 73a8b44b4b48784616e722b1e63561e35d669c2ee890dbc44e40191fdfd8fc1ef56710f4769ab6ea1f1a48fec0576f200c0b3812ca58fb143e7524006d1afed4
2017-05-30 07:17:02 +02:00
Gregory Sanders f128f78ddb getmempool mempoolminfee is a BTC/KB feerate 2017-05-29 14:14:07 -04:00
Cory Fields b6fbfc2282 net: only enforce the services required to connect
also once half of all outgoing nodes have our preferred flags, require only
minimal flags from the rest.
2017-05-28 10:20:07 -04:00
James Evans 16d94d3d03 Fixing typo in rpcdump.cpp 2017-05-27 16:44:10 +01:00
Jorge Timón f285145764
Introduce static DoWarning (simplify UpdateTip) 2017-05-27 06:33:39 +02:00
Pieter Wuille 422634e2f5 Introduce Coin, a single unspent output 2017-05-26 13:33:40 -07:00
Pieter Wuille 7d991b55db Store/allow tx metadata in all undo records
Previously, transaction metadata (height, coinbase or not, and before
the previous commit also nVersion) was only stored for undo records
that correspond to the last output of a transaction being spent.

This only saves 2 bytes per undo record. Change this to storing this
information for every undo record, and stop complaining for having it
in non-last output spends. This means that undo dat written with
this patch won't be readable by older versions anymore.
2017-05-26 13:33:39 -07:00
Pieter Wuille c3aa0c1194 Report on-disk size in gettxoutsetinfo 2017-05-26 13:33:39 -07:00
Pieter Wuille d342424301 Remove/ignore tx version in utxo and undo
This makes the following changes:
* In undo data and the chainstate database, the transaction nVersion
  field is removed from the data structures, always written as 0, and
  ignored when reading.
* The definition of hash_serialized in gettxoutsetinfo is changed to no
  longer incude the nVersion field. It is renamed to hash_serialized_2
  to avoid confusion. The new definition also includes transaction
  height and coinbase information, as this information was missing
  before.

This depends on having a CHashVerifier-based undo data checksum
verifier.

Apart from changing the definition of serialized_hash, downgrading
after using this patch is supported, as no release ever used the value
of nVersion field in UTXO entries.
2017-05-26 13:27:50 -07:00
Pieter Wuille 7e00322906 Add specialization of SipHash for 256 + 32 bit data
We'll need a version of SipHash for tuples of 256 bits and 32 bits
data, when CCoinsViewCache switches from using txids to COutPoints as
keys.
2017-05-26 13:24:25 -07:00
Pieter Wuille e484652fc3 Introduce CHashVerifier to hash read data
This is necessary later, when we drop the nVersion field from the undo
data. At that point deserializing and reserializing the data won't
roundtrip anymore, and thus that approach can't be used to verify
checksums anymore.

With this CHashVerifier approach, we can deserialize while hashing the
exact serialized form that was used. This is both more efficient and
more correct in that case.
2017-05-26 13:24:25 -07:00
Pieter Wuille f54580e7e4 error() in disconnect for disk corruption, not inconsistency
The error() function unconditionally reports an error. It should only
be used for actually exception situations, and not for the type of
inconsistencies that ApplyTxInUndo/DisconnectBlock can graciously deal
with.

This also makes a subtle semantics change: in ApplyTxInUndo, when a
record with metadata is encountered (indicating it is the last spend
from a tx), don't wipe the CCoins record if it wasn't empty at that
point. This makes sure that UTXO operations never affect any other
UTXOs (including those from the same tx).
2017-05-26 13:24:25 -07:00