aceat64/EasyBitcoin-PHP

getblocktemplate no longer works

Closed this issue · 3 comments

Hi there,

Since Bitcoin 0.13.1 (segwit), the getblocktemplate() method no longer returns anything.

I think this is due to the fact that you now need to specify a rule when calling getblocktemplate. For example, if you call:

bitcoin-cli getblocktemplate

You get this error:

error code: -8
error message:
Support for 'segwit' rule requires explicit client support

To get it working, you have to pass a rule like this as an extra argument, like so:

bitcoin-cli getblocktemplate '{"rules":["segwit"]}'

Is there any way to pass this argument to the $bitcoin->getblocktemplate() method to get it working again?

You can pass the parameters to getblocktemplate this way:
$bitcoin->getblocktemplate(['rules' => ['segwit']]);

That's odd that it's requiring you to pass a request template. The documentation for the getblocktemplate call says the "TemplateRequest" parameter is optional. I'm running 0.13.1 on mainnet and it works without any parameters. Regardless, the code above should work for you.

Thank you, that works. I'm running on testnet, which is what I'm guessing is the cause.

Out of curiosity, why is it that the parameter is not enclosed in any kind of quotations, like $bitcoin->getblocktemplate("['rules' => ['segwit']]");?

Anything passed as a parameter will be automatically encoded to json by the library.