Revert "Revert "Revert "Revert "Revert "Revert "Fixes to get bitcoind compiling""""""

This reverts commit c8ed20cb68eea2003b3b6d924cdd22876df00dd5.