Adjust code to work with unpatched bitcoind

I had to tweak luke-jr's commit, but it wasn't significant so I squashed what I did back into his.