Merge remote-tracking branch 'upstream/namecoinq' into namecoinq
Allow specifying dbtx in TxnBegin.

Optionally allow specifying an existing DbTxn to use in TxnBegin of the
DBs, so that one can use an atomic transaction across multiple databases
to fix syncing issues in the future.
Construct UTXO database from a rescan.

Add initial code to construct the UTXO database on startup from a rescan
of the existing blockchain.
Update debug chatter for UTXO creation.

Only print the progress output every 1000 blocks, and print more
information in case ReadTxIndex fails.
Prepend "txo" to UTXO DB keys.

Prepend "txo" to the UTXO DB keys and write the version.  Also, ignore
the genesis block since its transaction is not in the txindex (for now).
Use one DB Txn per block in UTXO rescan.

Use one DB transaction per processed block in the UTXO rescan to avoid
running out of DB memory.
Print more statistics in UTXO creation.

Include also total number of tx and txo's in the debug output after
creating the UTXO set.
Build UTXO forward-in-time.

Build the UTXO forward in time, as it will be done when the UTXO DB is
updated in "real time".  For duplicate entries, check that they are
exactly the same.  (Should be the case, since the txid as hash is the
same.)
Implement UTXO verification routine.

Add another "rescan" of the blockchain that verifies an already built
UTXO set.
Update support for reusing DbTxn's across DBs.

Implement better support for reusing database transactions to
synchronise multiple DBs with TxnBegin(parent-txn).  Keep track of which
transactions are our own, and only abort/commit those.
Construct CUtxoDB object for ConnectBlock.

Construct a CUtxoDB object in main.cpp and pass it to ConnectBlock.
Add UTXO DB to ConnectInputs.
Add UTXO DB to DisconnectInputs.
Add variant of InsertUtxo for whole transaction.

Add a new variant of CUtxoDB::InsertUtxo that inserts all outputs of a
given (new) transaction.
Partially update UTXO DB in ConnectInputs.

Add a new transaction's outputs to the UTXO DB in ConnectInputs and
check that its inputs are indeed in the DB.  We do not yet remove spent
outputs, though.
Enable removing spent txos from the DB.

Enable the code that removes spent txo's from the UTXO DB in
ConnectInputs.  Without it, verifyutxo does indeed find spurious entries
over time.  With it, this is no longer the case.

Note that DisconnectInputs still needs updating to handle
reorganisations properly.