bitcoin-0.8.6-r1: backported pull request https://github.com/bitcoin/bitcoin/pull/3656