getblocktemplate: longpolling support

Built on top of #936, this adds support for getblocktemplate longpolling to bitcoind.