Commit graph

12 commits

Author SHA1 Message Date
Dave Collins
1c052a01d8 Reject blocks with high precision timestamps.
This commit adds an additional sanity check to ensure the block that is
being processed does not contain a timestamp with a precision higher than
one second.  This is necessary because the consensus rules only deal with
whole seconds in the time comparisons whereas the internal data structures
make use of Go time.Time values which support up to nanosecond precision.

Also, add a test to ensure the new functionality works as expected.

ok @owainga
2014-02-24 10:42:50 -06:00
David Hill
e1f66f6103 gofmt 2014-02-04 16:16:53 -05:00
Dave Collins
be277b7230 Update for recent btcwire API changes. 2014-01-19 12:32:30 -06:00
Dave Collins
18ac5c848a Add 2014 to copyright dates. 2014-01-08 23:52:54 -06:00
Dave Collins
5295be070d Make the CheckBlockSanity function context free.
Rather than defining CheckBlockSanity as a member of a BlockChain
instance, define it at the root level so it is truly context free as
intended.  In order to make it context free, the proof of work limit is
now a required parameter.
2013-11-07 16:06:01 -06:00
Dave Collins
09b53a8fca Export the CheckBlockSanity function. 2013-11-07 15:39:48 -06:00
Dave Collins
6165e9b95b Convert API to use new btcutil.Tx.
This is part of the ongoing transaction hash optimization effort noted in
conformal/btcd#25.
2013-10-28 15:17:53 -05:00
Dave Collins
6d078d8115 Implement chain setup infrastructure in the tests.
This commit implents a basic infrastructure to be used throughout the
tests for creating a new chain instance that is ready to have tests run
against it.  It also returns a teardown function the caller can use to
clean up after it is done testing.  This paves the way for adding more
tests.
2013-10-09 18:29:53 -05:00
Dave Collins
0b334bc841 Correct reading of serialized height in coinbase.
This commit corrects the reading of the serialized height in coinbase
transactions for block height of version 2 or greater.  On mainnet, the
serialized height is always 3 bytes and will continue to be so for
something like  another ~159 years, so there was no issue with mainnet.
However on testnet, there are some version 2 blocks which are low enough
in the chain to only take 2 bytes to serialize.

In addition, this commit adds a full tests for the relavant function
including negative tests and variable length serialized lengths for block
heights.

Closes #1.
2013-10-06 14:27:53 -05:00
Dave Collins
10a62a37a3 Update for latest btcutil, btcscript, and btcwire.
This commit updates the calls into btcutil, btcscript, and btcwire for the
latest API changes which remove the need for the protocol version for
serialization and deserialization of blocks and transactions.
2013-08-05 18:53:50 -05:00
Dave Collins
f219ed5baf Add support for params based on active network.
This commit modifies the code to use params based on the active network
which paves the way for supporting the special rules and different genesis
blocks used by the test networks.
2013-07-24 12:26:17 -05:00
Dave Collins
aa5847f3cc Initial implementation. 2013-07-19 08:50:13 -05:00