Unmarshal received message failed: json: cannot unmarshal object into Go struct field response.error of type string
The reason for that is that ElectrumX, Fulcrum, and Electrs/Esplora are inconsistent when it comes to the error response format.
Please see the examples (for Bitcoin Testnet servers):
Responses unmarshaling don't work for errors returned by ElectrumX and Fulcrum servers.
I called the
GetBlockHeader
function with a block height that doesn't exist. https://github.com/checksum0/go-electrum/blob/b862ac442cf9f05c55a46eb060c7b547450808d3/electrum/block.go#L27 I observed the following error being returned:The reason for that is that ElectrumX, Fulcrum, and Electrs/Esplora are inconsistent when it comes to the error response format. Please see the examples (for Bitcoin Testnet servers):
ElectrumX
Fulcrum
Electrs/Esplora
The client handles correctly only the response returned by the Electrs/Esplora server, as only this response format can be unmarshaled to the
response
struct that assumes astring
as anerror
: https://github.com/checksum0/go-electrum/blob/b862ac442cf9f05c55a46eb060c7b547450808d3/electrum/network.go#L124-L128