An alternative full node implementation of LBRY's blockchain written in Go (golang)
2b780d16b0
This modifies the code which handles failed server responses to attempt to unmarshal the response bytes as a regular JSON-RPC response regardless of the HTTP status code and, if that fails, return an error that includes the status code as well as the raw response bytes. This is being done because some JSON-RPC servers, such as Bitcoin Core, don't follow the intended HTTP status code meanings. For example, if you request a block that doesn't exist, it returns a status code of 500 which is supposed to mean internal server error instead of a standard 200 status code (since the HTTP request itself was successful) along with the JSON-RPC error response. The result is that errors from Core will now show up as an actual RPCError instead of an error with the raw JSON bytes. This also has the benefit of returning the HTTP status code in the error for real HTTP failure cases such as 401 authentication failures, which previously would just be an empty error when used against Core since it doesn't return the actual response along with the status code as it should. |
||
---|---|---|
examples | ||
.gitignore | ||
.travis.yml | ||
chain.go | ||
CONTRIBUTORS | ||
doc.go | ||
extensions.go | ||
goclean.sh | ||
infrastructure.go | ||
LICENSE | ||
log.go | ||
mining.go | ||
net.go | ||
notify.go | ||
rawrequest.go | ||
rawtransactions.go | ||
README.md | ||
wallet.go |
btcrpcclient
[] (https://travis-ci.org/btcsuite/btcrpcclient) [] (http://godoc.org/github.com/btcsuite/btcrpcclient)
btcrpcclient implements a Websocket-enabled Bitcoin JSON-RPC client package written in Go. It provides a robust and easy to use client for interfacing with a Bitcoin RPC server that uses a btcd/bitcoin core compatible Bitcoin JSON-RPC API.
Status
This package is currently under active development. It is already stable and the infrastructure is complete. However, there are still several RPCs left to implement and the API is not stable yet.
Documentation
- API Reference
- btcd Websockets Example
Connects to a btcd RPC server using TLS-secured websockets, registers for block connected and block disconnected notifications, and gets the current block count - btcwallet Websockets Example
Connects to a btcwallet RPC server using TLS-secured websockets, registers for notifications about changes to account balances, and gets a list of unspent transaction outputs (utxos) the wallet can sign - Bitcoin Core HTTP POST Example
Connects to a bitcoin core RPC server using HTTP POST mode with TLS disabled and gets the current block count
Major Features
- Supports Websockets (btcd/btcwallet) and HTTP POST mode (bitcoin core)
- Provides callback and registration functions for btcd/btcwallet notifications
- Supports btcd extensions
- Translates to and from higher-level and easier to use Go types
- Offers a synchronous (blocking) and asynchronous API
- When running in Websockets mode (the default):
- Automatic reconnect handling (can be disabled)
- Outstanding commands are automatically reissued
- Registered notifications are automatically reregistered
- Back-off support on reconnect attempts
Installation
$ go get -u github.com/btcsuite/btcrpcclient
License
Package btcrpcclient is licensed under the copyfree ISC License.