Commit Graph

8555 Commits

Author SHA1 Message Date
Peter Todd 6af25b0f64
Add BIP65 to getblockchaininfo softforks list
Rebased-From: 54a200ac9ad8909303ccf1ac49c291e0c2b5fb23
2015-10-08 17:50:02 +02:00
Wladimir J. van der Laan ba1da90b33 Show softfork status in getblockchaininfo
Rebased-From: 5ed10793c2df970d07cecd760c42205e68779e83
2015-10-08 17:49:00 +02:00
Esteban Ordano 70a427b2b5 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)

Rebased-From: cb54d17355864fa08826d6511a0d7692b21ef2c9
2015-10-08 17:49:00 +02:00
Peter Todd c5a27f4fb3 Add RPC tests for the CHECKLOCKTIMEVERIFY (BIP65) soft-fork
bip65-cltv.py is based on the earlier BIP66 soft-fork RPC test
implemented by Pieter Wuille's 819bcf9b99

bip65-cltv-p2p.py is based on the earlier BIP66 P2P test by Suhas
Daftuar's d76412b068

Rebased-From: 308257856099e82e91881ba97f741d840184727c
2015-10-08 17:49:00 +02:00
Peter Todd 5e82e1c8f5 Add CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic
Based on the earlier BIP66 soft-fork logic implemented by Pieter
Wuille's 5a47811da5

Rebased-From: 287f54fc90c29301faede8d4ac2ea24a91441917
2015-10-08 17:48:51 +02:00
Peter Todd 6ea5ca4b4e Enable CHECKLOCKTIMEVERIFY as a standard script verify flag
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-08 17:48:10 +02:00
Peter Todd 4fa7a048d1 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.

Rebased-From: bc60b2b4b401f0adff5b8b9678903ff8feb5867b
2015-10-08 17:46:55 +02:00
Peter Todd 6ec08db338 Move LOCKTIME_THRESHOLD to src/script/script.h
Will now be needed by CHECKLOCKTIMEVERIFY code.

Rebased-From: 48e9c57cf06352f890eac4285ae022d8746cf3fd
2015-10-08 17:46:55 +02:00
Peter Todd 684636ba67 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.

Rebased-From: 99088d60d8a7747c6d1a7fd5d8cd388be1b3e138
2015-10-08 17:46:55 +02:00
Gregory Maxwell 71cc9d9fe8
Test LowS in standardness, removes nuisance malleability vector.
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

Rebased-From: b196b685c9089b74fd4ff3d9a28ea847ab36179b
Github-Pull: #6769
2015-10-07 11:21:03 +02:00
Wladimir J. van der Laan 5ed8d0b37e
Merge pull request #6750
5094a81 Move recentRejects initialization to top of InitBlockIndex (Wladimir J. van der Laan)
ec9b6c3 Keep track of recently rejected transactions (Peter Todd)
6eed52e Only use randomly created nonces in CRollingBloomFilter. (Pieter Wuille)
83671ef Make CRollingBloomFilter set nTweak for you (Peter Todd)
25cf122 Reuse vector hashing code for uint256 (Pieter Wuille)
2983fe0 Add uint256 support to CRollingBloomFilter (Peter Todd)
2015-10-06 16:18:48 +02:00
Wladimir J. van der Laan 5094a81d3b
Move recentRejects initialization to top of InitBlockIndex
This avoids that premature return in the condition that a new chain is initialized
results in NULL pointer errors due to recentReject not being constructed.

Also add assertions where it is used.

(cherry picked from commit a8d0407c4fcf7c4e8ed0e8edabd204f7a4efa477)
2015-10-02 12:27:20 +02:00
Peter Todd ec9b6c33e8 Keep track of recently rejected transactions
Nodes can have divergent policies on which transactions they will accept
and relay.  This can cause you to repeatedly request and reject the same
tx after its inved to you from various peers which have accepted it.
Here we add rolling bloom filter to keep track of such rejections,
clearing the filter every time the chain tip changes.

Credit goes to Alex Morcos, who created the patch that this code is
based on.

Original code by Peter Todd. Refactored to not construct the
filter at startup time by Pieter Wuille.

(cherry picked from commit 0847d9cb5fcd2fdd5a21bde699944d966cf5add9)
2015-10-02 12:17:54 +02:00
Pieter Wuille 6eed52e05b Only use randomly created nonces in CRollingBloomFilter.
(cherry picked from commit d741371d7d27e228aa64c618c50b23fb5449c3e1)
2015-10-02 12:17:49 +02:00
Peter Todd 83671efe99 Make CRollingBloomFilter set nTweak for you
While CBloomFilter is usually used with an explicitly set nTweak,
CRollingBloomFilter is only used internally. Requiring every caller to
set nTweak is error-prone and redundant; better to have the class handle
that for you with a high-quality randomness source.

Additionally when clearing the filter it makes sense to change nTweak as
well to recover from a bad setting, e.g. due to insufficient randomness
at initialization, so the clear() method is replaced by a reset() method
that sets a new, random, nTweak value.

(cherry picked from commit d2d7ee0e863b286e1c9f9c54659d494fb0a7712d)
2015-10-02 12:17:44 +02:00
Pieter Wuille 25cf1220e6 Reuse vector hashing code for uint256
(cherry picked from commit a3d65fedaa18686f0cc007d0a13dba6545250300)
2015-10-02 12:17:38 +02:00
Peter Todd 2983fe0484 Add uint256 support to CRollingBloomFilter
(cherry picked from commit bbe41088c61f2ad328766e851ffe6169aa80935a)
2015-10-02 12:17:21 +02:00
Wladimir J. van der Laan 8a915e56f4
qt: periodic translation update 2015-09-29 12:54:05 +02:00
Wladimir J. van der Laan 1cd7952dde
Merge pull request #6703
45bfa13 PARTIAL: typofixes (found by misspell_fixer) (Veres Lajos)
21c406e add support for miniupnpc api version 14 (Pavel Vasin)
13bd5a7 rpc-tests: re-enable rpc-tests for Windows (Cory Fields)
ccc4ad6 net: Set SO_REUSEADDR for Windows too (Cory Fields)
1f6772e add unit test for CNetAddr::GetGroup. (Alex Morcos)
13642a5 Fix masking of irrelevant bits in address groups. (Alex Morcos)
6b51b9b Replace boost::reverse_lock with our own. (Casey Rodarmor)
626c5e6 Make sure we re-acquire lock if a task throws (Casey Rodarmor)
4877053 Add missing files to files.md (fanquake)
f171fee Handle leveldb::DestroyDB() errors on wipe failure (Adam Weiss)
c5b89fe Fix race condition on test node shutdown (Casey Rodarmor)
4a37410 Handle no chain tip available in InvalidChainFound() (Ross Nicoll)
f6d29a6 Use unique name for AlertNotify tempfile (Casey Rodarmor)
e6adac7 Delay initial pruning until after wallet init (Adam Weiss)
e0020d4 Make sure LogPrint strings are line-terminated (J Ross Nicoll)
7ff9d12 Make sure LogPrintf strings are line-terminated (Wladimir J. van der Laan)
5a39133 build: fix libressl detection (Cory Fields)
f6355e6 Avoid leaking file descriptors in RegisterLoad (Casey Rodarmor)
60457d3 locking: fix a few small issues uncovered by -Wthread-safety (Cory Fields)
a496e11 Remove bash test note from rpc-tests readme (fanquake)
49c6a64 tests: Remove old sh-based test framework (Wladimir J. van der Laan)
a37567d Add autogen.sh to source tarball. (randy-waterhouse)
1f4d7cf travis: for travis generating an extra build (Cory Fields)
2015-09-23 14:12:55 +02:00
Jonas Schnelli 834e299564
[QT] fix thin space word wrap line brake issue
The thin space QT html hack results in cut-off chars/nums after a line break.

Avoid word wrap line breaks by using a smaller font and a line break before each alternative value)

Rebased-From: 24cb7c7bbba224dcb73fcf69296f5ef4734f745f
Github-Pull: #6694
2015-09-22 10:50:18 +02:00
Veres Lajos 45bfa137ef PARTIAL: typofixes (found by misspell_fixer)
Upstream: 9f68ed6b6d1a9c6436ce37913666165f2b180ee3 (PR #6539)
2015-09-22 00:43:15 +00:00
Pavel Vasin 21c406eda0 add support for miniupnpc api version 14
The value of new arg ttl is set to 2 as it's recommended default.
2015-09-22 00:43:15 +00:00
Cory Fields 13bd5a75b5 rpc-tests: re-enable rpc-tests for Windows 2015-09-22 00:43:14 +00:00
Cory Fields ccc4ad6c4d net: Set SO_REUSEADDR for Windows too
When running the rpc tests in Wine, nodes often fail to listen on localhost
due to a stale socket from a previous run. This aligns the behavior with other
platforms.
2015-09-22 00:43:14 +00:00
Alex Morcos 1f6772e9f0 add unit test for CNetAddr::GetGroup. 2015-09-22 00:43:14 +00:00
Alex Morcos 13642a50eb Fix masking of irrelevant bits in address groups. 2015-09-22 00:43:14 +00:00
Casey Rodarmor 6b51b9b195 Replace boost::reverse_lock with our own. 2015-09-22 00:43:13 +00:00
Casey Rodarmor 626c5e6936 Make sure we re-acquire lock if a task throws 2015-09-22 00:43:13 +00:00
fanquake 48770534a6 Add missing files to files.md
typo
2015-09-22 00:43:13 +00:00
Adam Weiss f171fee035 Handle leveldb::DestroyDB() errors on wipe failure
Add error checking to CLevelDBWrapper for errors from
leveldb::DestroyDB().  Without it, if unlink() or DeleteFileW() fail to
delete files, they will fail silent.  If they fail to delete any files,
CLevelDBWrapper will silently open and read the existing database.

Typically any permissions issues would be caught by leveldb as it churns
through many files as part of its compaction process, but it is
conceivable that this could cause problems on Windows with anti-virus
and indexing software.
2015-09-22 00:43:13 +00:00
Casey Rodarmor c5b89fe44e Fix race condition on test node shutdown 2015-09-22 00:43:12 +00:00
Ross Nicoll 4a3741028e Handle no chain tip available in InvalidChainFound()
Handle the case where no chain tip is available, in InvalidChainFound(). This fixes a null pointer deference when running unit tests, if the genesis block or block validation code is broken.
2015-09-22 00:43:12 +00:00
Casey Rodarmor f6d29a6ca8 Use unique name for AlertNotify tempfile 2015-09-22 00:43:12 +00:00
Adam Weiss e6adac7b3f Delay initial pruning until after wallet init
Don't prune until any wallet rescanning has taken place to avoid
potentially pruning blocks that the wallet rescan may need.
2015-09-22 00:43:12 +00:00
J Ross Nicoll e0020d4c44 Make sure LogPrint strings are line-terminated 2015-09-22 00:43:11 +00:00
Wladimir J. van der Laan 7ff9d122e4 Make sure LogPrintf strings are line-terminated
Fix the cases where LogPrint[f] was accidentally called without line
terminator, which resulted in concatenated log lines.

(see e.g. #6492)
2015-09-22 00:43:11 +00:00
Cory Fields 5a3913361d build: fix libressl detection
Checking libcrypto for a function after we've already found a (possibly
different) libcrypto is not what we want to do here.

pkg-config might've found a cross lib while AC_CHECK_LIB may find a different
or native one.

Run a link-test against the lib that's already been found instead.
2015-09-22 00:43:11 +00:00
Casey Rodarmor f6355e6918 Avoid leaking file descriptors in RegisterLoad
This is pretty trivial, but if there's an error here we'll leak a file
descriptor. Changed it to always close the file.
2015-09-22 00:43:11 +00:00
Cory Fields 60457d3c2f locking: fix a few small issues uncovered by -Wthread-safety
- rpcwallet: No need to lock twice here
- openssl: Clang doesn't understand selective lock/unlock here. Ignore it.
- CNode: Fix a legitimate (though very unlikely) locking bug.
2015-09-22 00:43:10 +00:00
fanquake a496e11d7c Remove bash test note from rpc-tests readme 2015-09-22 00:43:10 +00:00
Wladimir J. van der Laan 49c6a64202 tests: Remove old sh-based test framework
This removes the `conflictedbalance.sh` test as well, but that test has
been broken for a long time and isn't part of any scripts.
What it does is, IMO, sufficiently tested by other tests.
2015-09-22 00:43:10 +00:00
randy-waterhouse a37567dd44 Add autogen.sh to source tarball. 2015-09-22 00:43:10 +00:00
Cory Fields 1f4d7cf20b travis: for travis generating an extra build 2015-09-22 00:43:09 +00:00
Pavel Janík 649f5d9c11
Do not store more than 200 timedata samples.
Github-Pull: #6545
Rebased-From: 8be371db340b03dc03142c1bb3390fdfc84f56b4
2015-08-20 17:14:22 +02:00
Cory Fields 100ac4e185
consensus: cache the openssl EC_GROUP to avoid a race condition for each CECKey instantiation
Github-Pull: #6571
Rebased-From: 1d1073c2d3231a9de4adbc2bc46846fc20b34f9e
2015-08-20 16:37:50 +02:00
Suhas Daftuar 93b606aee4 Be even stricter in processing unrequested blocks
Github-Pull: #6224
Rebased-From: bfc30b34374d71928acee5ff41282f09cedfd5e4 6b1066fab41523d25d75b45a10e4b0f61d7c61d0 04b5d235f1560b8285591b963d3636f7ddf74563 59b49cd07482494d9a99068af502be9ceda41ed2
2015-07-29 20:11:52 +02:00
Pieter Wuille 5c27f1247a
Revert "Cache transaction validation successes"
This reverts commit bc484ef8db.
2015-07-28 20:15:51 +02:00
Pieter Wuille bc484ef8db
Cache transaction validation successes
Conflicts:
	src/main.cpp
	src/test/test_bitcoin.cpp

Github-Pull: #6077
Rebased-From: 17b11428c135203342aff38cabc8047e673f38ac 517e6dd25618522c716e64859554b0f29c6e65d0
2015-07-27 18:31:30 +02:00
Cory Fields 92401c2d90
Depends: bump to qt 5.5
Github-Pull: #6471
Rebased-From: fe997dfd121e3d82464908940753b77ebf61a10d 5189fe3d88b7d0154758379a877533fe364dec87 ab67dd7818ff2d0910f3fd9bfca9412d85de4424 ecd6a89381a34d4bcd07593a2e377656d070a7ed 060b3d377b0a0d318f630beb7fe4d8f41b99981c
2015-07-27 13:09:25 +02:00
Wladimir J. van der Laan 8e5a96908a
qt: Force TLS1.0+ for SSL connections
Github-Pull: #6384
Rebased-From: 15e26a6a9afe299b9ca6fced73b876644365879b
2015-07-24 07:54:58 +02:00