lbcd/README.md
Dave Collins f4fc117b66 Update TravisCI to goclean script.
- Also update to use the new container-based builds
- Add coveralls.io support
- Update build badge to use SVG
- Add badges for coverage, license, and godoc
- For now, set it to change to he v2 directory
  - This will need to be changed once the v1 code is replaced
2015-02-19 00:41:10 -06:00

3.7 KiB

btcjson

[Build Status] (https://travis-ci.org/btcsuite/btcjson) [![Coverage Status] (https://img.shields.io/coveralls/btcsuite/btcjson.svg)] (https://coveralls.io/r/btcsuite/btcjson?branch=master) ![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.

This package is one of the core packages from btcd, an alternative full-node implementation of bitcoin which is under active development by Conformal. Although it was primarily written for btcd, this package 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 bitcoind or bitcoin-qt through JSON-RPC. These can be used to get information from the client or to cause the client 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

[GoDoc] (http://godoc.org/github.com/btcsuite/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/btcjson

Installation

$ go get github.com/btcsuite/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.