fullnode: wait for session to stop.
bugfix: zero out beginning bytes (before most significant digit) for deterministic wallet secret generation.
sha256 minor tidying.
Merge pull request #22 from PabloCastellano/master

Documentation and minor improvements
increase credits/debits checksum to 8 bytes up from 4 to protect against collisions.
just some debug logging to poller and indexer. might be useful in the future.
pool/indexer detailed debug logging isn't needed in main code though.

This reverts commit 11fd8968752b0f60b0893ee6f273ab946f5ab4f7.
Merge branch 'master' of https://github.com/spesmilo/libbitcoin
fixed problem with inconsistent debits db caused by 1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T (for example). use a simpler strategy for loading debits instead of trying to be smart.
swap order of outputs and spends for indexer to be consistent.
fixed assert problem with tx getting indexed twice. see output below for debug logs.

Problem: when a reorganization happens, the tx gets resubmitted to validation in
the pool. if during the interim the same tx was in the queue and gets processed
by store() first, then it will successfully be included in the pool and the
indexer will index is again (without the tx being deindexed when removed from
the pool).

there are multiple strategies to take, but i've opted here for the simplest
implementation in line with http://www.jwz.org/doc/worse-is-better.html
from now on, when a tx is removed from a pool during a reorganization, the
confirm handler is called with the error_code set to error::blockchain_reorganized

--------------------------

DEBUG [session]: Transaction inventory: 4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017
DEBUG: transaction_pool::exists(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: DEBUG: transaction_pool::do_exists(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::store(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::validate(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::do_validate(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)

DEBUG [session]: Transaction inventory: 4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017
DEBUG: transaction_pool::exists(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::do_exists(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::do_exists(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::store(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::validate(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::do_validate(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::validation_complete(Success, unconfirmed(0), 4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG:   tx OK passed
DEBUG: wrap_handle_validate ec = Success
DEBUG [transaction_pool]: txpool::store() [421 / 2000]
DEBUG: transaction_indexer::index(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
INFO: Accepted transaction: 4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017
DEBUG: transaction_indexer::do_index(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG:   0  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   1  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   2  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   3  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG [network]: r: inv (109 bytes)
DEBUG:   4  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   5  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   6  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   7  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   8  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   9  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   10  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG [network]: r: inv (37 bytes)
DEBUG:   11  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   12  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   13  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   14  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   15  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   16  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   17  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG [worker]: Sending heartbeat
DEBUG [worker]: Received heartbeat
DEBUG:   18  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   19  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   20  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   21  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   22  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   23  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   24  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   25  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   26  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   27  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   28  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   29  1JwSSub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99  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   100  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   101  1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T
DEBUG:   0  199dyH3r7kYHMjiqHhZdRnVy4rZRBSVQn9

---------------

DEBUG: transaction_pool::resubmit_all()
...
DEBUG:   re-storing 5c20bf9ac478df401302b02325ea535d18b863b8125c6e0805c758631d07c839
DEBUG: transaction_pool::store(5c20bf9ac478df401302b02325ea535d18b863b8125c6e0805c758631d07c839)
DEBUG: transaction_pool::validate(5c20bf9ac478df401302b02325ea535d18b863b8125c6e0805c758631d07c839)
DEBUG:   re-storing 4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017
DEBUG: transaction_pool::store(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG: transaction_pool::validate(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG:   re-storing ...
...

DEBUG: transaction_pool::do_validate(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)

...

DEBUG: transaction_pool::validation_complete(Success, unconfirmed(0), 4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
DEBUG:   tx OK passed
DEBUG: wrap_handle_validate ec = Success
DEBUG [transaction_pool]: txpool::store() [23 / 2000]
DEBUG: transaction_indexer::index(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)
INFO: Accepted transaction: 4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017
DEBUG: transaction_indexer::do_index(4a9dfa9d8cef865e166cd6e55e3558cd600bd863c449251ec0c5bcaa24603017)

***** Internal Program Error - assertion (index_does_not_exist(payaddr, point,
spends_map_)) failed in void libbitcoin::transaction_indexer::do_index(const
libbitcoin::transaction_type&,
libbitcoin::transaction_indexer::completion_handler):
transaction_indexer.cpp(98): Transaction is indexed duplicate times!
Abortado (`core' generado)
in fetch_history(chain, indexer, ...), height=0 => unconfirmed tx, height=max => non-existent.
i like the debug logging. lets do more of this.
safer transaction_pool - re-subscribe to blockchain reorgs right away so as not to miss any blocks.
contextual logging using LOG_TXIDX and LOG_TXPOOL
accept inconsistency and conflicts as a fact of life. try our best to resolve these.
bugfix: output is found but spend already exists, so skip insertion instead of continuing to loop. also set found = true so assert doesn't trigger.
update version macro in version.hpp
time a section of code to find bottlenecks. not included in default dist.
put decorator header in namespace.