lbcd/btcjson
Dave Collins 637fbcadec rpcserver: Convert to make use of new btcjson.
This commit converts the RPC server over to use the new features available
in the latest version of btcjson and improve a few things along the way.
This following summarizes the changes:

- All btcjson imports have been updated to the latest package version
- The help has been significantly improved
  - Invoking help with no command specified now provides an alphabetized
    list of all supported commands along with one-line usage
  - The help for each command is automatically generated and provides much
    more explicit information such as the type of each parameter, whether
    or not it's optional or required, etc
  - The websocket-specific commands are now provided when accessing the
    help when connected via websockets
  - Help has been added for all websocket-specific commands and is only
    accessible when connected via websockets
- The error returns and handling of both the standard and websocket
  handlers has been made consistent
- All RPC errors have been converted to the new RPCError type
- Various variables have been renamed for consistency
- Several RPC errors have been improved
- The commands that are marked as unimplemented have been moved into the
  separate map where they belong
- Several comments have been improved
- An unnecessary check has been removed from the createrawtransaction
  handler
- The command parsing has been restructured a bit to pave the way for
  JSON-RPC 2.0 batching support
2015-02-24 23:46:51 -06:00
..
btcws Import btcws repo into btcjson/btcws directory. 2015-02-19 12:53:08 -06:00
v2/btcjson rpcserver: Convert to make use of new btcjson. 2015-02-24 23:46:51 -06:00
cmdhelp.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
CONTRIBUTORS Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
doc.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
internal_test.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
jsonapi.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
jsonapi_test.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
jsoncmd.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
jsoncmd_test.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
jsonerr.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
jsonfxns.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
jsonfxns_test.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
jsonresults.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
jsonresults_test.go Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00
README.md Import btcjson repo into btcjson directory. 2015-02-19 11:10:46 -06:00

btcjson

[Build Status] (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

[GoDoc] (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.