6b3c3c7498
This commit contains the entire btcjson repository along with several changes needed to move all of the files into the btcjson directory in order to prepare it for merging. This does NOT update btcd or any of the other packages to use the new location as that will be done separately. - All import paths in the old btcjson test files have been changed to the new location - The coveralls badge has been removed since it unfortunately doesn't support coverage of sub-packages This is ongoing work toward #214. |
||
---|---|---|
.. | ||
v2/btcjson | ||
cmdhelp.go | ||
CONTRIBUTORS | ||
doc.go | ||
internal_test.go | ||
jsonapi.go | ||
jsonapi_test.go | ||
jsoncmd.go | ||
jsoncmd_test.go | ||
jsonerr.go | ||
jsonfxns.go | ||
jsonfxns_test.go | ||
jsonresults.go | ||
jsonresults_test.go | ||
README.md |
btcjson
[] (https://travis-ci.org/btcsuite/btcd) ![ISC License] (http://img.shields.io/badge/license-ISC-blue.svg)
Package btcjson implements concrete types for marshalling to and from the bitcoin JSON-RPC API. A comprehensive suite of tests is provided to ensure proper functionality. Package btcjson is licensed under the copyfree ISC license.
Although this package was primarily written for btcd, it has intentionally been designed so it can be used as a standalone package for any projects needing to marshal to and from bitcoin JSON-RPC requests and responses.
Note that although it's possible to use this package directly to implement an RPC client, it is not recommended since it is only intended as an infrastructure package. Instead, RPC clients should use the btcrpcclient package which provides a full blown RPC client with many features such as automatic connection management, websocket support, automatic notification re-registration on reconnect, and conversion from the raw underlying RPC types (strings, floats, ints, etc) to higher-level types with many nice and useful properties.
JSON RPC
Bitcoin provides an extensive API call list to control the chain and wallet servers through JSON-RPC. These can be used to get information from the server or to cause the server to perform some action.
The general form of the commands are:
{"jsonrpc": "1.0", "id":"test", "method": "getinfo", "params": []}
btcjson provides code to easily create these commands from go (as some of the commands can be fairly complex), to send the commands to a running bitcoin RPC server, and to handle the replies (putting them in useful Go data structures).
Sample Use
// Create a new command.
cmd, err := btcjson.NewGetBlockCountCmd()
if err != nil {
// Handle error
}
// Marshal the command to a JSON-RPC formatted byte slice.
marshalled, err := btcjson.MarshalCmd(id, cmd)
if err != nil {
// Handle error
}
// At this point marshalled contains the raw bytes that are ready to send
// to the RPC server to issue the command.
fmt.Printf("%s\n", marshalled)
Documentation
[] (http://godoc.org/github.com/btcsuite/btcd/btcjson)
Full go doc
style documentation for the project can be viewed online without
installing this package by using the GoDoc site
here.
You can also view the documentation locally once the package is installed with
the godoc
tool by running godoc -http=":6060"
and pointing your browser to
http://localhost:6060/pkg/github.com/btcsuite/btcd/btcjson
Installation
$ go get github.com/btcsuite/btcd/btcjson
GPG Verification Key
All official release tags are signed by Conformal so users can ensure the code has not been tampered with and is coming from Conformal. To verify the signature perform the following:
-
Download the public key from the Conformal website at https://opensource.conformal.com/GIT-GPG-KEY-conformal.txt
-
Import the public key into your GPG keyring:
gpg --import GIT-GPG-KEY-conformal.txt
-
Verify the release tag with the following command where
TAG_NAME
is a placeholder for the specific tag:git tag -v TAG_NAME
License
Package btcjson is licensed under the copyfree ISC License.