Merge pull request #536 from langerhans/btc-0.9.2-batch-3

BTC 0.9.2 batch 3
Update doc/gitian-building.md for new gitian

The patch to make it possible to configure the LXC IPs has been merged
upstream. This means that it is no longer needed to patch gitian.
Remove that workaround.
Point to BDB 5.1
translation update
Add AssertLockHeld for cs_main to ChainActive-using functions

All functions that use ChainActive but do not aquire the cs_main
lock themselves, need to be called with the cs_main lock held.

This commit adds assertions to all externally callable functions
that use chainActive or chainMostWork.

This will flag usages when built with -DDEBUG_LOCKORDER.
chainActive locking issues resolved
AddToWallet implies BindWallet

Now that AddToWallet is called when loading transactions from the
wallet database, BindWallet can be integrated into that and does not
need to be an extra step.

Leaves behaviour unchanged, but makes the
fFromLoadWallet/!fFromLoadWallet paths in AddToWallet a bit more
symmetric.
script: add CScriptNum class

This class holds an int64_t and replaces the use of CBigInt for script
integrals.
script: switch to CScriptNum usage for scripts
script: switch outside users to CScriptNum
script: remove bignum dependency
script: add additional script tests
script: Add test for CScriptNum

Because this class replaces some usages of CBigNum, tests have been added to
verify that they function the same way. The only difference in their usage is
the handling of out-of-range numbers.

While operands are constrained to [-0x7FFFFFFF,0x7FFFFFFF], the results may
overflow. The overflowing result is technically unbounded, but in practice
it can be no bigger than the result of an operation on two operands. This
implementation limits them to the size of an int64.

CBigNum was unaware of this constraint, so it allowed for unbounded results,
which were then checked before use. CScriptNum asserts if an arithmetic
operation will overflow an int64_t, since scripts are not able to reach those
numbers anyway. Additionally, CScriptNum will throw an exception when
constructed from a vector containing more than 4 bytes This mimics the previous
CastToBigNum behavior.
Replace DecodeBase58/EncodeBase58 with direct implementation.

This removes the bignum/OpenSSL dependency.

The base58 transformation code is also moved to a separate .cpp file.
[Qt] importwallet progress
Add required locks in tests

Unit tests with DEBUG_LOCKORDER were running into assertions.
qt: get required locks upfront in polling functions

This avoids the GUI from getting stuck on
periodical polls if the core is holding the locks for a longer time -
for example, during a wallet rescan.
Add missing AssertLockHeld in ConnectBlock
Add MESSAGE_START_SIZE from chainparams when loading blocks from external files.
Revision in OS X plist