Commit graph

5257 commits

Author SHA1 Message Date
Matt Corallo
48ebf73da8 Loosen the AllowFree threshold significantly 2015-06-08 17:57:20 -07:00
Matt Corallo
5846db6b79 Enable withdraw proof verification+CLTV+CSV 2015-06-08 17:57:20 -07:00
Matt Corallo
4db4d55064 No subsidy, 21 million genesis block 2015-06-08 17:57:20 -07:00
Matt Corallo
9121b5b415 Dynamically calculate the genesis/checkpoints 2015-06-08 17:57:20 -07:00
Matt Corallo
9565839787 Change coinbase maturity to 1 to make spending genesis easy. 2015-06-08 17:57:20 -07:00
Matt Corallo
f87a75e27f Make genesis coinbase spendable 2015-06-08 17:57:20 -07:00
Matt Corallo
046c251b40 Add withdrawsign command to bitcoin-tx (sidechain-only for now) 2015-06-08 17:57:20 -07:00
Matt Corallo
eca4077baa Use RPC calls to check bitcoin blocks are valid and confirmed 2015-06-08 17:57:19 -07:00
Matt Corallo
6dc16a139c MOVEONLY: Move CallRPC into its own file 2015-06-08 17:57:19 -07:00
Matt Corallo
b15d9390cd SIDECHAIN_ONLY: Fix link errors for sidechain-only libs 2015-06-08 17:57:19 -07:00
Matt Corallo
b6e861d748 Enable signing withdraw outputs 2015-06-08 17:57:19 -07:00
Matt Corallo
4d2d950ebc Make withdraw proof script errors significantly more verbose 2015-06-08 17:57:19 -07:00
Matt Corallo
f9adcd2e2c Auto-add fraud proof txn to mempool (with priority bump) 2015-06-08 17:57:19 -07:00
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
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
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
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