Commit graph

7736 commits

Author SHA1 Message Date
Matt Corallo
c19a65d56a Add sidechain tracking and double-spend proof generation 2015-06-08 17:57:19 -07:00
Matt Corallo
35c58420a4 Add withdraw-spent to CCoinsView/utxodb
Allows CCoinsCacheEntry/CCoinsMap entries to either be a CCoins
or, by setting a flag in the map key, a withdraw output from a
chain from which withdraw proofs are allowed to move to this
chain from.
2015-06-08 17:57:19 -07:00
Matt Corallo
ad584a25ba Check streams are empty after reading 2015-06-08 17:57:19 -07:00
Matt Corallo
67d4bc8cf4 Verify Withdraw proofs in script execution 2015-06-08 17:57:18 -07:00
Matt Corallo
8baa1b5ef5 Tweak SignatureChecker to expose a bit more about the transaction 2015-06-08 17:57:18 -07:00
Matt Corallo
e0bc30390e Add withdraw lock/out to script/standard.h (and, thus, RPC raw txn) 2015-06-08 17:57:18 -07:00
Matt Corallo
093f2e1e47 CScript::[IsWithdrawProof() + IsWithdrawLock()] (which are standard) 2015-06-08 17:57:18 -07:00
Matt Corallo
3c6faaa5da Add getint64 to CScriptNum 2015-06-08 17:57:18 -07:00
Matt Corallo
e7f9d03f81 EMPTY_COMMIT: Sidechain-specific commits follow 2015-06-08 17:57:18 -07:00
Pieter Wuille
f40342f0cc Get rid of CTxOut::GetHash 2015-06-08 17:57:18 -07:00
Matt Corallo
35ca77db2f Fail in DecodeHexTx if there is extra data at the end 2015-06-08 16:52:16 -07:00
Mark Friedenbach
d2aa2c8aff Allow specification of sequence numbers in bitcoin-tx 2015-06-08 16:52:16 -07:00
Matt Corallo
253f634396 Add -forceibdcomplete and use IBD to allow all-peer headers-sync.
This uses IsInitialBlockDownload to enable headers-fetching from
all peers (in addition to the existing recent-headers-tip check).
It also adds a hidden flag which allows you to force IBD to false,
enabling download from all peers.
2015-06-04 22:08:23 -07:00
Matt Corallo
f40b9feb2e Broaden when we request blocks/header from peers.
This starts a headers-sync with *all* peers instead of just "good"
ones after we finish initial headers sync.
It also downloads blocks from all peers after IBD finishes.
2015-06-04 22:08:23 -07:00
Matt Corallo
bb6eca865e Fix comment about cs_main (IsInitialBlockDownload locks cs_main) 2015-06-04 22:08:23 -07:00
Matt Corallo
4633dbe026 Add RPC call to generate and verify merkle blocks 2015-06-04 22:08:23 -07:00
Matt Corallo
386b0f2273 Add CMerkleBlock constructor for tx set + block and an empty one 2015-06-04 22:08:23 -07:00
Matt Corallo
1668f340a4 EMPTY_COMMIT: General interest commits follow 2015-06-04 22:08:23 -07:00
Bryan Bishop
aaf439bfd6 Implement watchonly support in fundrawtransaction
Support watchonly in fundrawtransaction, CreateTransaction, SelectCoins
and coin selection in general.

Coin selection is exposed over RPC through fundrawtransaction, and
watchonly can be enabled by passing includeWatching true (defaults to
false).

fundrawtransaction will first attempt to fund a transaction without
using watchonly, even when includeWatching is enabled. When this fails,
an includeWatching attempt is made.

When an includeWatching attempt at coin selection is performed (in
CreateTransaction), and all watchonlys are consumed leaving no funds
available for a fee, then CreateTransaction will not include a fee in
the transaction.

Also, includeWatching tests (for fundrawtransaction).

See also: https://github.com/bitcoin/bitcoin/pull/5503
2015-06-04 22:08:23 -07:00
Jonas Schnelli
c5b204dae3 fundrawtransaction overhaul
- fix typo
2015-06-04 22:08:23 -07:00
Jonas Schnelli
fceb64c0ac add simple unittest for fundrawtransaction (increase test coverage) 2015-06-04 22:08:23 -07:00
Jonas Schnelli
cd42202ac3 add support for existing vins for fundrawtransaction 2015-06-04 22:08:23 -07:00
Jonas Schnelli
018828d666 fundrawtransaction basics 2015-06-04 22:08:23 -07:00
Matt Corallo
625eff80e9 EMPTY_COMMIT: fundrawtransaction commits follow 2015-06-04 22:08:23 -07:00
Mark Friedenbach
ffbd813f0a Enable sequence numbers as a relative lock-time, and the new opcodes CHECKLOCKTIMEVERIFY and CHECKSEQUENCEVERIFY as enforced consensus rules. 2015-06-04 22:08:23 -07:00
Mark Friedenbach
d409ee9490 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.
2015-06-04 22:08:23 -07:00
Peter Todd
656893241d 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.
2015-06-04 22:08:23 -07:00
Mark Friedenbach
bbdccaa987 Enable policy enforcing GetMedianTimePast as the end point of lock-time constraints
Transactions are not allowed in the memory pool or selected for inclusion in a block until their lock times exceed chainActive.Tip()->GetMedianTimePast(). However blocks including transactions which are only mature under the old rules are still accepted; this is *not* the soft-fork required to actually rely on the new constraint in production.
2015-06-04 22:08:23 -07:00
Mark Friedenbach
8bdb2d4d1d Enable policy enforcing sequence numbers as a relative lock time in the mempool and transaction selection code, for the purpose of later supporting consensus-enforced transaction replacement
Transactions that fail relative lock time checks will be rejected from the mempool and not included in generated blocks, making it easy to test the feature. However blocks including transactions containing "invalid" relative lock times will still be accepted; this is *not* the soft-fork required to actually enable relative lock times for production use.
2015-06-04 22:08:23 -07:00
Mark Friedenbach
23f42e61dd Replace NOP3 with CHECKSEQUENCEVERIFY (BIPXX)
<nInvSequence> CHECKSEQUENCEVERIFY -> <nInvSequence>

Fails if ~txin.nSequence < nInvSequence (the nSequence field of the txin is bit-inverted before the comparison), allowing funds of a txout to be locked for a number of blocks or a duration of time after its inclusion in a block.

Only the logic and unit tests are implemented; this commit does not have changes to policy or consensus behavior.
2015-06-04 22:08:22 -07:00
Mark Friedenbach
2affed549a Move SEQUENCE_THRESHOLD to script/script.h
Will now be needed by CHECKSEQUENCEVERIFY code.
2015-06-04 22:08:22 -07:00
Peter Todd
dfe3d9a4cd 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-04 22:08:22 -07:00
Peter Todd
f6f2cf6fba Move LOCKTIME_THRESHOLD to src/script/script.h
Will now be needed by CHECKLOCKTIMEVERIFY code.
2015-06-04 22:08:22 -07:00
Peter Todd
a1757fdea3 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-06-04 22:08:22 -07:00
Mark Friedenbach
51680bc859 Add rules--presently disabled--for using GetMedianTimePast as endpoint for lock-time calculations
The lock-time code currently uses CBlock::nTime as the cutoff point for time based locked transactions. This has the unfortunate outcome of creating a perverse incentive for miners to lie about the time of a block in order to collect more fees by including transactions that by wall clock determination have not yet matured. By using CBlockIndex::GetMedianTimePast from the prior block instead, the self-interested miner no longer gains from generating blocks with fraudulent timestamps. Users can compensate for this change by simply adding an hour (3600 seconds) to their time-based lock times.

If enforced, this would be a soft-fork change. This commit only adds the functionality on an unexecuted code path, without changing the behaviour of Bitcoin Core.
2015-06-04 22:08:22 -07:00
Mark Friedenbach
f441365501 Add rules--presently disabled--for using sequence numbers as a relative lock time
In summary, the sequence number of each input in a transaction is used to store an inverted relative locktime: a delta value which is added to the height or time of the block which included the output being spent to generate a per-input lock time from the sequence number. If enforced, this would make transaction replacement possible as replacing an input with a higher sequence number (lower relative lock time) would allow the new transaction to make it on the chain sooner.

This commit does not implement the transaction replacement logic. Nor does this commit make the relative lock time rules as consensus or policy rules. It merely adds new, but disabled functionality and unit tests for that functionality.
2015-06-04 22:08:22 -07:00
Mark Friedenbach
2be1de38aa Get rid of CTxIn::IsFinal(), which is only used in one location and whose semantics will not survive revival of sequence numbers 2015-06-04 22:08:22 -07:00
Mark Friedenbach
553ff39655 Reverse structure of IsFinalTx()
Instead of checking if the transaction is in a category of cases to return true and failing otherwise, we return false if the tx is a failure case and otherwise return true. This removes an early-exit opportunity which will no longer be possible once sequence numbers are re-enabled, but has no change in behaviour.
2015-06-04 22:08:22 -07:00
Mark Friedenbach
ad6f810c37 Prevent block.nTime from decreasing
Under some circumstances it is possible for there to be a significant, discontinuous jump in a node's clock value. On mining nodes, this can result in block templates which are no longer valid due to time-based nLockTime constraints. UpdateTime() is modified so that it will never decrease a block's nLockTime, thereby preventing such invalidations.
2015-06-04 22:08:22 -07:00
Mark Friedenbach
4d5f4e2d4d 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-04 22:08:22 -07:00
Matt Corallo
2b6745d37f EMPTY_COMMIT: CLTV Commits follow 2015-06-03 20:46:44 -07:00
Wladimir J. van der Laan
181771b712
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.

Github-Pull: #6226
Rebased-From: 4e157fc60d
2015-06-03 15:16:18 +02:00
Luke Dashjr
ecc96f5ba9
Remove P2SH coinbase flag, no longer interesting
Github-Pull: #6203
Rebased-From: d449772cf6
2015-06-02 09:14:13 +02:00
Wladimir J. van der Laan
ebd7d8d78c
Parameter interaction: disable upnp if -proxy set
To protect privacy, do not use UPNP when a proxy is set. The user may
still specify -listen=1 to listen locally (for a hidden service), so
don't rely on this happening through -listen.

Fixes #2927.

Conflicts:
	src/init.cpp

Rebased-From: 8c35b6f3be
Github-Pull: #6153
2015-05-27 09:35:40 +02:00
Wladimir J. van der Laan
ae3d8f371a
Fix two problems in CSubNet parsing
Fix two CSubNet constructor problems:

- The use of `/x` where 8 does not divide x was broken, due to a
  bit-order issue

- The use of e.g. `1.2.3.4/24` where the netmasked bits in the network
  are not 0 was broken. Fix this by explicitly normalizing the netwok
  according to the bitmask.

Also add tests for these cases.

Fixes #6179. Thanks to @jonasschnelli for reporting and initial fix.

Rebased-From: b45c50ce51
Github-Pull: #6186
2015-05-27 09:11:27 +02:00
Wladimir J. van der Laan
e4a7d51537
Simplify code for CSubnet
Simplify the code by using CAddress.ip directly, instead of the reversed
GetByte() semantics.

Rebased-From: 19e8d7be42
Github-Pull: #6186
2015-05-27 09:10:56 +02:00
Wladimir J. van der Laan
16f45600c8
doc: small amandment to release notes 2015-05-16 10:37:27 +02:00
Wladimir J. van der Laan
ff32503267
Release notes 0.10.2 2015-05-12 17:08:58 +02:00
Gregory Maxwell
da656068ec
Avoid crash on start in TestBlockValidity with gen=1.
When the internal miner is enabled at the start of a new node, there
 is an near instant assert in TestBlockValidity because its attempting
 to mine a block before the top checkpoint.

Also avoids a data race around vNodes.

Github-Pull: #6123
Rebased-From: bba7c24929
2015-05-12 16:38:04 +02:00
Wladimir J. van der Laan
49e4d14f75
Translations update 2015-05-12 16:33:04 +02:00