Port of addrindex

Port of addrindex commit https://github.com/jmcorgan/bitcoin/commit/4790f3c823a33fae44b82ef7962372e38b1b0131

ref https://github.com/viacoin/viacoin/issues/17

Note the original PR https://github.com/jmcorgan/bitcoin/commit/079503c6ac69c29fcc960511edfd4e3fd0b9daec has two commits squashed. This PR only ports https://github.com/jmcorgan/bitcoin/commit/4790f3c823a33fae44b82ef7962372e38b1b0131, to maintain mergeability.