Revert "Revert "Fixes to get bitcoind compiling""

This reverts commit d667f294636e0c3c811e80539435b1102f91bc63.
Revert "Revert "Revert "Fixes to get bitcoind compiling"""

This reverts commit f7beec5021720d5469b232b3bad5b5e118c4db72.