Make regtest subsidy halving interval 150.

This commit moves the subsidy halving interval to the chain params so it
can be configured per network.  With that change it sets the regression
test halving interval to 150 to match the regression test params of the
reference implementation.

This was pointed out by @flammit.
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
Export CalcBlockSubsidy function.
Export CountSigOps function.
Export MaxSigOpsPerBlock.
Change BuildMerkleTreeStore to accept transactions.

This commit modifies the BuildMerkleTreeStore function to accept a slice
of btcutil.Tx transactions as opposed to a full block.  This allows more
flexibility when calculating merkle roots since a full block may not be
created yet (particularly when generating blocks that need to be solved in
mining).

Previously, the BuildMerkleTreeStore function accepted a btcutil.Block
because originally the block itself cached the transaction hashes and it
was necessary to have access to the block to make use of the cached
transactions.  However, the code has since been improved such that it
caches transaction hashes directly in each btcutil.Tx.  This means the
code can remain as efficient as before while allowing the individual
transacitons to be passed.
Export CountP2SHSigOps.
Export CalcNextRequiredDifficutly function.

This commit exports a new variant of the existing internal
calcNextRequiredDifficulty function which calculates and returns the next
required difficulty for a block after the end of the current best chain
based on the difficulty retarget rules.

In order to support the exported function the internal one was slightly
modified to accept the block timestamp instead of an entire block since
the timestamp is all that is needed and the caller of the exported
function might next have a full block yet.
Defer unlock of orphan mutex in addOrphanBlock.

This was pointed out by saracen on the btcd IRC channel.
Export CheckConnectBlock function.

This commit makes a slight variant of the existing checkConnectBlock
function available to external callers.  The new exported version checks
if the passed block will connect to the end of the current main chain.

In order to support this, a few other small modifications have been made
to the initial index generation and the existing checkConnectBlock since
it previously made some assumptions about the state of genesis block which
can no longer be assumed due accepting blocks from callers directly.

Also, add a quick test to ensure the new function fails when checking if
the genesis block will connect again when it's already inserted.
add unit testing for BigToCompact, CompactToBig, and CalcWork
Export coinbase script length limits.

This commit exports the MinCoinbaseScriptLen and MaxCoinbaseScriptLen
constants.
Export CalcPastMedianTime function.

This commit makes a slight variant of the existing calcPastMedianTime
function available to external callers.  The new exported version
calculates the past median time from the end of the current main chain
versus an arbitrary block node.