bitcoind: bdb fixes

Merges in fixes by @theuni to make wallets opened with this build
portable again.