dcrjson

package module
v2.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2023 License: ISC Imports: 4 Imported by: 35

README

dcrjson

Build Status ISC License GoDoc

Package dcrjson implements concrete types for marshalling to and from the decred JSON-RPC API. A comprehensive suite of tests is provided to ensure proper functionality.

Although this package was primarily written for the decred, it has intentionally been designed so it can be used as a standalone package for any projects needing to marshal to and from decred 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 rpcclient 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.

Installation and Updating

$ go get -u github.com/decred/dcrd/dcrjson

Examples

  • Marshal Command Demonstrates how to create and marshal a command into a JSON-RPC request.

  • Unmarshal Command Demonstrates how to unmarshal a JSON-RPC request and then unmarshal the concrete request into a concrete command.

  • Marshal Response Demonstrates how to marshal a JSON-RPC response.

  • Unmarshal Response Demonstrates how to unmarshal a JSON-RPC response and then unmarshal the result field in the response to a concrete type.

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 the Decred developers. 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 dcrjson is licensed under the copyfree ISC License.

Documentation

Overview

Package dcrjson provides primitives for working with the Decred JSON-RPC API.

Overview

When communicating via the JSON-RPC protocol, all of the commands need to be marshalled to and from the the wire in the appropriate format. This package provides data structures and primitives to ease this process.

In addition, it also provides some additional features such as custom command registration, command categorization, and reflection-based help generation.

JSON-RPC Protocol Overview

This information is not necessary in order to use this package, but it does provide some intuition into what the marshalling and unmarshalling that is discussed below is doing under the hood.

As defined by the JSON-RPC spec, there are effectively two forms of messages on the wire:

  • Request Objects {"jsonrpc":"1.0","id":"SOMEID","method":"SOMEMETHOD","params":[SOMEPARAMS]} NOTE: Notifications are the same format except the id field is null.

  • Response Objects {"result":SOMETHING,"error":null,"id":"SOMEID"} {"result":null,"error":{"code":SOMEINT,"message":SOMESTRING},"id":"SOMEID"}

For requests, the params field can vary in what it contains depending on the method (a.k.a. command) being sent. Each parameter can be as simple as an int or a complex structure containing many nested fields. The id field is used to identify a request and will be included in the associated response.

When working with asynchronous transports, such as websockets, spontaneous notifications are also possible. As indicated, they are the same as a request object, except they have the id field set to null. Therefore, servers will ignore requests with the id field set to null, while clients can choose to consume or ignore them.

Unfortunately, the original Bitcoin JSON-RPC API (and hence anything compatible with it) doesn't always follow the spec and will sometimes return an error string in the result field with a null error for certain commands. However, for the most part, the error field will be set as described on failure.

Marshalling and Unmarshalling

Based upon the discussion above, it should be easy to see how the types of this package map into the required parts of the protocol

  • Request Objects (type Request)
  • Commands (type <Foo>Cmd)
  • Notifications (type <Foo>Ntfn)
  • Response Objects (type Response)
  • Result (type <Foo>Result)

To simplify the marshalling of the requests and responses, the MarshalCmd and MarshalResponse functions are provided. They return the raw bytes ready to be sent across the wire.

Unmarshalling a received Request object is a two step process:

  1. Unmarshal the raw bytes into a Request struct instance via json.Unmarshal
  2. Use UnmarshalCmd on the Result field of the unmarshalled Request to create a concrete command or notification instance with all struct fields set accordingly

This approach is used since it provides the caller with access to the additional fields in the request that are not part of the command such as the ID.

Unmarshalling a received Response object is also a two step process:

  1. Unmarhsal the raw bytes into a Response struct instance via json.Unmarshal
  2. Depending on the ID, unmarshal the Result field of the unmarshalled Response to create a concrete type instance

As above, this approach is used since it provides the caller with access to the fields in the response such as the ID and Error.

Command Creation

This package provides two approaches for creating a new command. This first, and preferred, method is to use one of the New<Foo>Cmd functions. This allows static compile-time checking to help ensure the parameters stay in sync with the struct definitions.

The second approach is the NewCmd function which takes a method (command) name and variable arguments. The function includes full checking to ensure the parameters are accurate according to provided method, however these checks are, obviously, run-time which means any mistakes won't be found until the code is actually executed. However, it is quite useful for user-supplied commands that are intentionally dynamic.

Custom Command Registration

The command handling of this package is built around the concept of registered commands. This is true for the wide variety of commands already provided by the package, but it also means caller can easily provide custom commands with all of the same functionality as the built-in commands. Use the RegisterCmd function for this purpose.

A list of all registered methods can be obtained with the RegisteredCmdMethods function.

Command Inspection

All registered commands are registered with flags that identify information such as whether the command applies to a chain server, wallet server, or is a notification along with the method name to use. These flags can be obtained with the MethodUsageFlags flags, and the method can be obtained with the CmdMethod function.

Help Generation

To facilitate providing consistent help to users of the RPC server, this package exposes the GenerateHelp and function which uses reflection on registered commands or notifications, as well as the provided expected result types, to generate the final help text.

In addition, the MethodUsageText function is provided to generate consistent one-line usage for registered commands and notifications using reflection.

Errors

There are 2 distinct type of errors supported by this package:

  • General errors related to marshalling or unmarshalling or improper use of the package (type Error)
  • RPC errors which are intended to be returned across the wire as a part of the JSON-RPC response (type RPCError)

The first category of errors (type Error) typically indicates a programmer error and can be avoided by properly using the API. Errors of this type will be returned from the various functions available in this package. They identify issues such as unsupported field types, attempts to register malformed commands, and attempting to create a new command with an improper number of parameters. The specific reason for the error can be detected by type asserting it to a *dcrjson.Error and accessing the ErrorCode field.

The second category of errors (type RPCError), on the other hand, are useful for returning errors to RPC clients. Consequently, they are used in the previously described Response type.

Example (UnmarshalResponse)

This example demonstrates how to unmarshal a JSON-RPC response and then unmarshal the result field in the response to a concrete type.

// Ordinarily this would be read from the wire, but for this example,
// it is hard coded here for clarity.  This is an example response to a
// getblockheight request.
data := []byte(`{"result":350001,"error":null,"id":1}`)

// Unmarshal the raw bytes from the wire into a JSON-RPC response.
var response Response
if err := json.Unmarshal(data, &response); err != nil {
	fmt.Println("Malformed JSON-RPC response:", err)
	return
}

// Check the response for an error from the server.  For example, the
// server might return an error if an invalid/unknown block hash is
// requested.
if response.Error != nil {
	fmt.Println(response.Error)
	return
}

// Unmarshal the result into the expected type for the response.
var blockHeight int32
if err := json.Unmarshal(response.Result, &blockHeight); err != nil {
	fmt.Printf("Unexpected result type: %T\n", response.Result)
	return
}
fmt.Println("Block height:", blockHeight)
Output:

Block height: 350001

Index

Examples

Constants

View Source
const (
	// ANAdd indicates the specified host should be added as a persistent
	// peer.
	ANAdd = types.ANAdd

	// ANRemove indicates the specified peer should be removed.
	ANRemove = types.ANRemove

	// ANOneTry indicates the specified host should try to connect once,
	// but it should not be made persistent.
	ANOneTry = types.ANOneTry
)
View Source
const (
	// NConnect indicates the specified host that should be connected to.
	NConnect = types.NConnect

	// NRemove indicates the specified peer that should be removed as a
	// persistent peer.
	NRemove = types.NRemove

	// NDisconnect indicates the specified peer should be disonnected.
	NDisconnect = types.NDisconnect
)
View Source
const (
	// EstimateSmartFeeEconomical returns an
	// economical result.
	EstimateSmartFeeEconomical = types.EstimateSmartFeeEconomical

	// EstimateSmartFeeConservative potentially returns
	// a conservative result.
	EstimateSmartFeeConservative = types.EstimateSmartFeeConservative
)
View Source
const (
	// GRMAll indicates any type of transaction should be returned.
	GRMAll = types.GRMAll

	// GRMRegular indicates only regular transactions should be returned.
	GRMRegular = types.GRMRegular

	// GRMTickets indicates that only tickets should be returned.
	GRMTickets = types.GRMTickets

	// GRMVotes indicates that only votes should be returned.
	GRMVotes = types.GRMVotes

	// GRMRevocations indicates that only revocations should be returned.
	GRMRevocations = types.GRMRevocations
)
View Source
const (
	// BlockConnectedNtfnMethod is the method used for notifications from
	// the chain server that a block has been connected.
	BlockConnectedNtfnMethod = "blockconnected"

	// BlockDisconnectedNtfnMethod is the method used for notifications from
	// the chain server that a block has been disconnected.
	BlockDisconnectedNtfnMethod = "blockdisconnected"

	// NewTicketsNtfnMethod is the method of the daemon newtickets notification.
	NewTicketsNtfnMethod = "newtickets"

	// ReorganizationNtfnMethod is the method used for notifications that the
	// block chain is in the process of a reorganization.
	ReorganizationNtfnMethod = "reorganization"

	// TxAcceptedNtfnMethod is the method used for notifications from the
	// chain server that a transaction has been accepted into the mempool.
	TxAcceptedNtfnMethod = "txaccepted"

	// TxAcceptedVerboseNtfnMethod is the method used for notifications from
	// the chain server that a transaction has been accepted into the
	// mempool.  This differs from TxAcceptedNtfnMethod in that it provides
	// more details in the notification.
	TxAcceptedVerboseNtfnMethod = "txacceptedverbose"

	// RelevantTxAcceptedNtfnMethod is the method used for notifications
	// from the chain server that inform a client that a relevant
	// transaction was accepted by the mempool.
	RelevantTxAcceptedNtfnMethod = "relevanttxaccepted"

	// SpentAndMissedTicketsNtfnMethod is the method of the daemon
	// spentandmissedtickets notification.
	SpentAndMissedTicketsNtfnMethod = "spentandmissedtickets"

	// StakeDifficultyNtfnMethod is the method of the daemon stakedifficulty
	// notification.
	StakeDifficultyNtfnMethod = "stakedifficulty"

	// WinningTicketsNtfnMethod is the method of the daemon winningtickets
	// notification.
	WinningTicketsNtfnMethod = "winningtickets"
)

Variables

View Source
var (
	ErrInvalidRequest = Error{
		Code:    -32600,
		Message: "Invalid request",
	}
	ErrMethodNotFound = Error{
		Code:    -32601,
		Message: "Method not found",
	}
	ErrInvalidParams = Error{
		Code:    -32602,
		Message: "Invalid parameters",
	}
	ErrInternal = Error{
		Code:    -32603,
		Message: "Internal error",
	}
	ErrParse = Error{
		Code:    -32700,
		Message: "Parse error",
	}
)

Standard JSON-RPC 2.0 errors

View Source
var (
	ErrMisc = Error{
		Code:    -1,
		Message: "Miscellaneous error",
	}
	ErrForbiddenBySafeMode = Error{
		Code:    -2,
		Message: "Server is in safe mode, and command is not allowed in safe mode",
	}
	ErrType = Error{
		Code:    -3,
		Message: "Unexpected type was passed as parameter",
	}
	ErrInvalidAddressOrKey = Error{
		Code:    -5,
		Message: "Invalid address or key",
	}
	ErrOutOfMemory = Error{
		Code:    -7,
		Message: "Ran out of memory during operation",
	}
	ErrInvalidParameter = Error{
		Code:    -8,
		Message: "Invalid, missing or duplicate parameter",
	}
	ErrDatabase = Error{
		Code:    -20,
		Message: "Database error",
	}
	ErrDeserialization = Error{
		Code:    -22,
		Message: "Error parsing or validating structure in raw format",
	}
)

General application defined JSON errors

View Source
var (
	ErrClientNotConnected = Error{
		Code:    -9,
		Message: "dcrd is not connected",
	}
	ErrClientInInitialDownload = Error{
		Code:    -10,
		Message: "dcrd is downloading blocks...",
	}
)

Peer-to-peer client errors

View Source
var (
	ErrWallet = Error{
		Code:    -4,
		Message: "Unspecified problem with wallet",
	}
	ErrWalletInsufficientFunds = Error{
		Code:    -6,
		Message: "Not enough funds in wallet or account",
	}
	ErrWalletInvalidAccountName = Error{
		Code:    -11,
		Message: "Invalid account name",
	}
	ErrWalletKeypoolRanOut = Error{
		Code:    -12,
		Message: "Keypool ran out, call keypoolrefill first",
	}
	ErrWalletUnlockNeeded = Error{
		Code:    -13,
		Message: "Enter the wallet passphrase with walletpassphrase first",
	}
	ErrWalletPassphraseIncorrect = Error{
		Code:    -14,
		Message: "The wallet passphrase entered was incorrect",
	}
	ErrWalletWrongEncState = Error{
		Code:    -15,
		Message: "Command given in wrong wallet encryption state",
	}
	ErrWalletEncryptionFailed = Error{
		Code:    -16,
		Message: "Failed to encrypt the wallet",
	}
	ErrWalletAlreadyUnlocked = Error{
		Code:    -17,
		Message: "Wallet is already unlocked",
	}
)

Wallet JSON errors

View Source
var (
	ErrBlockNotFound = Error{
		Code:    -5,
		Message: "Block not found",
	}
	ErrBlockCount = Error{
		Code:    -5,
		Message: "Error getting block count",
	}
	ErrBestBlockHash = Error{
		Code:    -5,
		Message: "Error getting best block hash",
	}
	ErrDifficulty = Error{
		Code:    -5,
		Message: "Error getting difficulty",
	}
	ErrOutOfRange = Error{
		Code:    -1,
		Message: "Block number out of range",
	}
	ErrNoTxInfo = Error{
		Code:    -5,
		Message: "No information available about transaction",
	}
	ErrNoNewestBlockInfo = Error{
		Code:    -5,
		Message: "No information about newest block",
	}
	ErrInvalidTxVout = Error{
		Code:    -5,
		Message: "Output index number (vout) does not exist for transaction.",
	}
	ErrRawTxString = Error{
		Code:    -32602,
		Message: "Raw tx is not a string",
	}
	ErrDecodeHexString = Error{
		Code:    -22,
		Message: "Unable to decode hex string",
	}
)

Specific Errors related to commands. These are the ones a user of the rpc server are most likely to see. Generally, the codes should match one of the more general errors above.

View Source
var (
	ErrNoWallet = Error{
		Code:    -1,
		Message: "This implementation does not implement wallet commands",
	}
	ErrUnimplemented = Error{
		Code:    -1,
		Message: "Command unimplemented",
	}
)

Errors that are specific to dcrd.

View Source
var (
	ErrRPCInvalidRequest = &RPCError{
		Code:    -32600,
		Message: "Invalid request",
	}
	ErrRPCMethodNotFound = &RPCError{
		Code:    -32601,
		Message: "Method not found",
	}
	ErrRPCInvalidParams = &RPCError{
		Code:    -32602,
		Message: "Invalid parameters",
	}
	ErrRPCInternal = &RPCError{
		Code:    -32603,
		Message: "Internal error",
	}
	ErrRPCParse = &RPCError{
		Code:    -32700,
		Message: "Parse error",
	}
)

Standard JSON-RPC 2.0 errors.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func CmdMethod

func CmdMethod(cmd interface{}) (string, error)

CmdMethod returns the method for the passed command. The provided command type must be a registered type. All commands provided by this package are registered by default.

func DecodeConcatenatedHashes

func DecodeConcatenatedHashes(hashes string) ([]chainhash.Hash, error)

DecodeConcatenatedHashes return a slice of contiguous chainhash.Hash objects created by decoding a single string of concatenated hex-encoded hashes.

These hashes must NOT be the byte reversed string encoding that is typically used for block and transaction hashes, or each resulting hash will also be reversed.

The length of the string must be evenly divisible by twice the hash size in order for the parameter to be valid. This function assumes the input is from a JSON-RPC request and any errors will be of type *RPCError with an ErrRPCInvalidParameter or ErrRPCDecodedHexString error code.

func EncodeConcatenatedHashes

func EncodeConcatenatedHashes(hashSlice []chainhash.Hash) string

EncodeConcatenatedHashes serializes a slice of chainhash.Hash values into a string of hex-encoded bytes.

func Float64

func Float64(v float64) *float64

Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func GenerateHelp

func GenerateHelp(method string, descs map[string]string, resultTypes ...interface{}) (string, error)

GenerateHelp generates and returns help output for the provided method and result types given a map to provide the appropriate keys for the method synopsis, field descriptions, conditions, and result descriptions. The method must be associated with a registered type. All commands provided by this package are registered by default.

The resultTypes must be pointer-to-types which represent the specific types of values the command returns. For example, if the command only returns a boolean value, there should only be a single entry of (*bool)(nil). Note that each type must be a single pointer to the type. Therefore, it is recommended to simply pass a nil pointer cast to the appropriate type as previously shown.

The provided descriptions map must contain all of the keys or an error will be returned which includes the missing key, or the final missing key when there is more than one key missing. The generated help in the case of such an error will use the key in place of the description.

The following outlines the required keys:

"<method>--synopsis"             Synopsis for the command
"<method>-<lowerfieldname>"      Description for each command argument
"<typename>-<lowerfieldname>"    Description for each object field
"<method>--condition<#>"         Description for each result condition
"<method>--result<#>"            Description for each primitive result num

Notice that the "special" keys synopsis, condition<#>, and result<#> are preceded by a double dash to ensure they don't conflict with field names.

The condition keys are only required when there is more than on result type, and the result key for a given result type is only required if it's not an object.

For example, consider the 'help' command itself. There are two possible returns depending on the provided parameters. So, the help would be generated by calling the function as follows:

GenerateHelp("help", descs, (*string)(nil), (*string)(nil)).

The following keys would then be required in the provided descriptions map:

"help--synopsis":   "Returns a list of all commands or help for ...."
"help-command":     "The command to retrieve help for",
"help--condition0": "no command provided"
"help--condition1": "command specified"
"help--result0":    "List of commands"
"help--result1":    "Help for specified command"

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func Int32

func Int32(v int32) *int32

Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func Int64

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func IsValidIDType

func IsValidIDType(id interface{}) bool

IsValidIDType checks that the ID field (which can go in any of the JSON-RPC requests, responses, or notifications) is valid. JSON-RPC 1.0 allows any valid JSON type. JSON-RPC 2.0 (which bitcoind follows for some parts) only allows string, number, or null, so this function restricts the allowed types to that list. This function is only provided in case the caller is manually marshalling for some reason. The functions which accept an ID in this package already call this function to ensure the provided id is valid.

func MarshalCmd

func MarshalCmd(rpcVersion string, id interface{}, cmd interface{}) ([]byte, error)

MarshalCmd marshals the passed command to a JSON-RPC request byte slice that is suitable for transmission to an RPC server. The provided command type must be a registered type. All commands provided by this package are registered by default.

Example

This example demonstrates how to create and marshal a command into a JSON-RPC request.

// Create a new getblock command.  Notice the nil parameter indicates
// to use the default parameter for that fields.  This is a common
// pattern used in all of the New<Foo>Cmd functions in this package for
// optional fields.  Also, notice the call to Bool which is a
// convenience function for creating a pointer out of a primitive for
// optional parameters.
blockHash := "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
gbCmd := NewGetBlockCmd(blockHash, Bool(false), nil)

// Marshal the command to the format suitable for sending to the RPC
// server.  Typically the client would increment the id here which is
// request so the response can be identified.
id := 1
marshalledBytes, err := MarshalCmd("1.0", id, gbCmd)
if err != nil {
	fmt.Println(err)
	return
}

// Display the marshalled command.  Ordinarily this would be sent across
// the wire to the RPC server, but for this example, just display it.
fmt.Printf("%s\n", marshalledBytes)
Output:

{"jsonrpc":"1.0","method":"getblock","params":["000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",false],"id":1}

func MarshalResponse

func MarshalResponse(rpcVersion string, id interface{}, result interface{}, rpcErr *RPCError) ([]byte, error)

MarshalResponse marshals the passed rpc version, id, result, and RPCError to a JSON-RPC response byte slice that is suitable for transmission to a JSON-RPC client.

Example

This example demonstrates how to marshal a JSON-RPC response.

// Marshal a new JSON-RPC response.  For example, this is a response
// to a getblockheight request.
marshalledBytes, err := MarshalResponse("1.0", 1, 350001, nil)
if err != nil {
	fmt.Println(err)
	return
}

// Display the marshalled response.  Ordinarily this would be sent
// across the wire to the RPC client, but for this example, just display
// it.
fmt.Printf("%s\n", marshalledBytes)
Output:

{"jsonrpc":"1.0","result":350001,"error":null,"id":1}

func MethodUsageText

func MethodUsageText(method string) (string, error)

MethodUsageText returns a one-line usage string for the provided method. The provided method must be associated with a registered type. All commands provided by this package are registered by default.

func MustRegisterCmd

func MustRegisterCmd(method string, cmd interface{}, flags UsageFlag)

MustRegisterCmd performs the same function as RegisterCmd except it panics if there is an error. This should only be called from package init functions.

func NewCmd

func NewCmd(method string, args ...interface{}) (interface{}, error)

NewCmd provides a generic mechanism to create a new command that can marshal to a JSON-RPC request while respecting the requirements of the provided method. The method must have been registered with the package already along with its type definition. All methods associated with the commands exported by this package are already registered by default.

The arguments are most efficient when they are the exact same type as the underlying field in the command struct associated with the the method, however this function also will perform a variety of conversions to make it more flexible. This allows, for example, command line args which are strings to be passed unaltered. In particular, the following conversions are supported:

  • Conversion between any size signed or unsigned integer so long as the value does not overflow the destination type
  • Conversion between float32 and float64 so long as the value does not overflow the destination type
  • Conversion from string to boolean for everything strconv.ParseBool recognizes
  • Conversion from string to any size integer for everything strconv.ParseInt and strconv.ParseUint recognizes
  • Conversion from string to any size float for everything strconv.ParseFloat recognizes
  • Conversion from string to arrays, slices, structs, and maps by treating the string as marshalled JSON and calling json.Unmarshal into the destination field

func RegisterCmd

func RegisterCmd(method string, cmd interface{}, flags UsageFlag) error

RegisterCmd registers a new command that will automatically marshal to and from JSON-RPC with full type checking and positional parameter support. It also accepts usage flags which identify the circumstances under which the command can be used.

This package automatically registers all of the exported commands by default using this function, however it is also exported so callers can easily register custom types.

The type format is very strict since it needs to be able to automatically marshal to and from JSON-RPC 1.0. The following enumerates the requirements:

  • The provided command must be a single pointer to a struct
  • All fields must be exported
  • The order of the positional parameters in the marshalled JSON will be in the same order as declared in the struct definition
  • Struct embedding is not supported
  • Struct fields may NOT be channels, functions, complex, or interface
  • A field in the provided struct with a pointer is treated as optional
  • Multiple indirections (i.e **int) are not supported
  • Once the first optional field (pointer) is encountered, the remaining fields must also be optional fields (pointers) as required by positional params
  • A field that has a 'jsonrpcdefault' struct tag must be an optional field (pointer)

NOTE: This function only needs to be able to examine the structure of the passed struct, so it does not need to be an actual instance. Therefore, it is recommended to simply pass a nil pointer cast to the appropriate type. For example, (*FooCmd)(nil).

func RegisteredCmdMethods

func RegisteredCmdMethods() []string

RegisteredCmdMethods returns a sorted list of methods for all registered commands.

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func Uint

func Uint(v uint) *uint

Uint is a helper routine that allocates a new uint value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func Uint16 added in v2.1.0

func Uint16(v uint16) *uint16

Uint16 is a helper routine that allocates a new uint16 value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func Uint32

func Uint32(v uint32) *uint32

Uint32 is a helper routine that allocates a new uint32 value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func Uint64

func Uint64(v uint64) *uint64

Uint64 is a helper routine that allocates a new uint64 value to store v and returns a pointer to it. This is useful when assigning optional parameters.

func UnmarshalCmd

func UnmarshalCmd(r *Request) (interface{}, error)

UnmarshalCmd unmarshals a JSON-RPC request into a suitable concrete command so long as the method type contained within the marshalled request is registered.

Example

This example demonstrates how to unmarshal a JSON-RPC request and then unmarshal the concrete request into a concrete command.

// Ordinarily this would be read from the wire, but for this example,
// it is hard coded here for clarity.
data := []byte(`{"jsonrpc":"1.0","method":"getblock","params":["000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",false],"id":1}`)

// Unmarshal the raw bytes from the wire into a JSON-RPC request.
var request Request
if err := json.Unmarshal(data, &request); err != nil {
	fmt.Println(err)
	return
}

// Typically there isn't any need to examine the request fields directly
// like this as the caller already knows what response to expect based
// on the command it sent.  However, this is done here to demonstrate
// why the unmarshal process is two steps.
if request.ID == nil {
	fmt.Println("Unexpected notification")
	return
}
if request.Method != "getblock" {
	fmt.Println("Unexpected method")
	return
}

// Unmarshal the request into a concrete command.
cmd, err := UnmarshalCmd(&request)
if err != nil {
	fmt.Println(err)
	return
}

// Type assert the command to the appropriate type.
gbCmd, ok := cmd.(*GetBlockCmd)
if !ok {
	fmt.Printf("Incorrect command type: %T\n", cmd)
	return
}

// Display the fields in the concrete command.
fmt.Println("Hash:", gbCmd.Hash)
fmt.Println("Verbose:", *gbCmd.Verbose)
fmt.Println("VerboseTx:", *gbCmd.VerboseTx)
Output:

Hash: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
Verbose: false
VerboseTx: false

Types

type AddNodeCmd

type AddNodeCmd = types.AddNodeCmd

AddNodeCmd defines the addnode JSON-RPC command.

func NewAddNodeCmd

func NewAddNodeCmd(addr string, subCmd AddNodeSubCmd) *AddNodeCmd

NewAddNodeCmd returns a new instance which can be used to issue an addnode JSON-RPC command.

type AddNodeSubCmd

type AddNodeSubCmd = types.AddNodeSubCmd

AddNodeSubCmd defines the type used in the addnode JSON-RPC command for the sub command field.

type Agenda

type Agenda = types.Agenda

Agenda models an individual agenda including its choices.

type AgendaInfo

type AgendaInfo = types.AgendaInfo

AgendaInfo provides an overview of an agenda in a consensus deployment.

type AuthenticateCmd

type AuthenticateCmd = types.AuthenticateCmd

AuthenticateCmd defines the authenticate JSON-RPC command.

func NewAuthenticateCmd

func NewAuthenticateCmd(username, passphrase string) *AuthenticateCmd

NewAuthenticateCmd returns a new instance which can be used to issue an authenticate JSON-RPC command.

type BlockConnectedNtfn

type BlockConnectedNtfn = types.BlockConnectedNtfn

BlockConnectedNtfn defines the blockconnected JSON-RPC notification.

func NewBlockConnectedNtfn

func NewBlockConnectedNtfn(header string, subscribedTxs []string) *BlockConnectedNtfn

NewBlockConnectedNtfn returns a new instance which can be used to issue a blockconnected JSON-RPC notification.

type BlockDisconnectedNtfn

type BlockDisconnectedNtfn = types.BlockDisconnectedNtfn

BlockDisconnectedNtfn defines the blockdisconnected JSON-RPC notification.

func NewBlockDisconnectedNtfn

func NewBlockDisconnectedNtfn(header string) *BlockDisconnectedNtfn

NewBlockDisconnectedNtfn returns a new instance which can be used to issue a blockdisconnected JSON-RPC notification.

type Choice

type Choice = types.Choice

Choice models an individual choice inside an Agenda.

type CreateRawSSRtxCmd

type CreateRawSSRtxCmd = types.CreateRawSSRtxCmd

CreateRawSSRtxCmd is a type handling custom marshaling and unmarshaling of createrawssrtx JSON RPC commands.

func NewCreateRawSSRtxCmd

func NewCreateRawSSRtxCmd(inputs []TransactionInput, fee *float64) *CreateRawSSRtxCmd

NewCreateRawSSRtxCmd creates a new CreateRawSSRtxCmd.

type CreateRawSStxCmd

type CreateRawSStxCmd = types.CreateRawSStxCmd

CreateRawSStxCmd is a type handling custom marshaling and unmarshaling of createrawsstx JSON RPC commands.

func NewCreateRawSStxCmd

func NewCreateRawSStxCmd(inputs []SStxInput, amount map[string]int64,
	couts []SStxCommitOut) *CreateRawSStxCmd

NewCreateRawSStxCmd creates a new CreateRawSStxCmd.

type CreateRawTransactionCmd

type CreateRawTransactionCmd = types.CreateRawTransactionCmd

CreateRawTransactionCmd defines the createrawtransaction JSON-RPC command.

func NewCreateRawTransactionCmd

func NewCreateRawTransactionCmd(inputs []TransactionInput, amounts map[string]float64,
	lockTime *int64, expiry *int64) *CreateRawTransactionCmd

NewCreateRawTransactionCmd returns a new instance which can be used to issue a createrawtransaction JSON-RPC command.

Amounts are in DCR.

type DebugLevelCmd

type DebugLevelCmd = types.DebugLevelCmd

DebugLevelCmd defines the debuglevel JSON-RPC command. This command is not a standard Bitcoin command. It is an extension for btcd.

func NewDebugLevelCmd

func NewDebugLevelCmd(levelSpec string) *DebugLevelCmd

NewDebugLevelCmd returns a new DebugLevelCmd which can be used to issue a debuglevel JSON-RPC command. This command is not a standard Bitcoin command. It is an extension for btcd.

type DecodeRawTransactionCmd

type DecodeRawTransactionCmd = types.DecodeRawTransactionCmd

DecodeRawTransactionCmd defines the decoderawtransaction JSON-RPC command.

func NewDecodeRawTransactionCmd

func NewDecodeRawTransactionCmd(hexTx string) *DecodeRawTransactionCmd

NewDecodeRawTransactionCmd returns a new instance which can be used to issue a decoderawtransaction JSON-RPC command.

type DecodeScriptCmd

type DecodeScriptCmd = types.DecodeScriptCmd

DecodeScriptCmd defines the decodescript JSON-RPC command.

func NewDecodeScriptCmd

func NewDecodeScriptCmd(hexScript string) *DecodeScriptCmd

NewDecodeScriptCmd returns a new instance which can be used to issue a decodescript JSON-RPC command.

type DecodeScriptResult

type DecodeScriptResult = types.DecodeScriptResult

DecodeScriptResult models the data returned from the decodescript command.

type Error

type Error = v3.Error

Error identifies a general error. This differs from an RPCError in that this error typically is used more by the consumers of the package as opposed to RPCErrors which are intended to be returned to the client across the wire via a JSON-RPC Response. The caller can use type assertions to determine the specific error and access the ErrorCode field.

type ErrorCode

type ErrorCode = v3.ErrorCode

ErrorCode identifies a kind of error. These error codes are NOT used for JSON-RPC response errors.

const (
	// ErrDuplicateMethod indicates a command with the specified method
	// already exists.
	ErrDuplicateMethod ErrorCode = iota

	// ErrInvalidUsageFlags indicates one or more unrecognized flag bits
	// were specified.
	ErrInvalidUsageFlags

	// ErrInvalidType indicates a type was passed that is not the required
	// type.
	ErrInvalidType

	// ErrEmbeddedType indicates the provided command struct contains an
	// embedded type which is not not supported.
	ErrEmbeddedType

	// ErrUnexportedField indiciates the provided command struct contains an
	// unexported field which is not supported.
	ErrUnexportedField

	// ErrUnsupportedFieldType indicates the type of a field in the provided
	// command struct is not one of the supported types.
	ErrUnsupportedFieldType

	// ErrNonOptionalField indicates a non-optional field was specified
	// after an optional field.
	ErrNonOptionalField

	// ErrNonOptionalDefault indicates a 'jsonrpcdefault' struct tag was
	// specified for a non-optional field.
	ErrNonOptionalDefault

	// ErrMismatchedDefault indicates a 'jsonrpcdefault' struct tag contains
	// a value that doesn't match the type of the field.
	ErrMismatchedDefault

	// ErrUnregisteredMethod indicates a method was specified that has not
	// been registered.
	ErrUnregisteredMethod

	// ErrMissingDescription indicates a description required to generate
	// help is missing.
	ErrMissingDescription

	// ErrNumParams inidcates the number of params supplied do not
	// match the requirements of the associated command.
	ErrNumParams
)

These constants are used to identify a specific RuleError.

type EstimateFeeCmd

type EstimateFeeCmd = types.EstimateFeeCmd

EstimateFeeCmd defines the estimatefee JSON-RPC command.

func NewEstimateFeeCmd

func NewEstimateFeeCmd(numBlocks int64) *EstimateFeeCmd

NewEstimateFeeCmd returns a new instance which can be used to issue an estimatefee JSON-RPC command.

type EstimateSmartFeeCmd

type EstimateSmartFeeCmd = types.EstimateSmartFeeCmd

EstimateSmartFeeCmd defines the estimatesmartfee JSON-RPC command.

func NewEstimateSmartFeeCmd

func NewEstimateSmartFeeCmd(confirmations int64, mode *EstimateSmartFeeMode) *EstimateSmartFeeCmd

NewEstimateSmartFeeCmd returns a new instance which can be used to issue an estimatesmartfee JSON-RPC command.

type EstimateSmartFeeMode

type EstimateSmartFeeMode = types.EstimateSmartFeeMode

EstimateSmartFeeMode defines estimation mode to be used with the estimatesmartfee command.

func EstimateSmartFeeModeAddr

func EstimateSmartFeeModeAddr(v EstimateSmartFeeMode) *EstimateSmartFeeMode

EstimateSmartFeeModeAddr is a helper routine that allocates a new EstimateSmartFeeMode value to store v and returns a pointer to it. This is useful when assigning optional parameters.

type EstimateSmartFeeResult

type EstimateSmartFeeResult = types.EstimateSmartFeeResult

EstimateSmartFeeResult models the data returned from the estimatesmartfee command.

type EstimateStakeDiffCmd

type EstimateStakeDiffCmd = types.EstimateStakeDiffCmd

EstimateStakeDiffCmd defines the eststakedifficulty JSON-RPC command.

func NewEstimateStakeDiffCmd

func NewEstimateStakeDiffCmd(tickets *uint32) *EstimateStakeDiffCmd

NewEstimateStakeDiffCmd defines the eststakedifficulty JSON-RPC command.

type EstimateStakeDiffResult

type EstimateStakeDiffResult = types.EstimateStakeDiffResult

EstimateStakeDiffResult models the data returned from the estimatestakediff command.

type ExistsAddressCmd

type ExistsAddressCmd = types.ExistsAddressCmd

ExistsAddressCmd defines the existsaddress JSON-RPC command.

func NewExistsAddressCmd

func NewExistsAddressCmd(address string) *ExistsAddressCmd

NewExistsAddressCmd returns a new instance which can be used to issue a existsaddress JSON-RPC command.

type ExistsAddressesCmd

type ExistsAddressesCmd = types.ExistsAddressesCmd

ExistsAddressesCmd defines the existsaddresses JSON-RPC command.

func NewExistsAddressesCmd

func NewExistsAddressesCmd(addresses []string) *ExistsAddressesCmd

NewExistsAddressesCmd returns a new instance which can be used to issue an existsaddresses JSON-RPC command.

type ExistsExpiredTicketsCmd

type ExistsExpiredTicketsCmd struct {
	TxHashBlob string
}

ExistsExpiredTicketsCmd defines the existsexpiredtickets JSON-RPC command.

func NewExistsExpiredTicketsCmd

func NewExistsExpiredTicketsCmd(txHashBlob string) *ExistsExpiredTicketsCmd

NewExistsExpiredTicketsCmd returns a new instance which can be used to issue an existsexpiredtickets JSON-RPC command.

type ExistsLiveTicketCmd

type ExistsLiveTicketCmd = types.ExistsLiveTicketCmd

ExistsLiveTicketCmd defines the existsliveticket JSON-RPC command.

func NewExistsLiveTicketCmd

func NewExistsLiveTicketCmd(txHash string) *ExistsLiveTicketCmd

NewExistsLiveTicketCmd returns a new instance which can be used to issue an existsliveticket JSON-RPC command.

type ExistsLiveTicketsCmd

type ExistsLiveTicketsCmd struct {
	TxHashBlob string
}

ExistsLiveTicketsCmd defines the existslivetickets JSON-RPC command.

func NewExistsLiveTicketsCmd

func NewExistsLiveTicketsCmd(txHashBlob string) *ExistsLiveTicketsCmd

NewExistsLiveTicketsCmd returns a new instance which can be used to issue an existslivetickets JSON-RPC command.

type ExistsMempoolTxsCmd

type ExistsMempoolTxsCmd struct {
	TxHashBlob string
}

ExistsMempoolTxsCmd defines the existsmempooltxs JSON-RPC command.

func NewExistsMempoolTxsCmd

func NewExistsMempoolTxsCmd(txHashBlob string) *ExistsMempoolTxsCmd

NewExistsMempoolTxsCmd returns a new instance which can be used to issue an existslivetickets JSON-RPC command.

type ExistsMissedTicketsCmd

type ExistsMissedTicketsCmd struct {
	TxHashBlob string
}

ExistsMissedTicketsCmd defines the existsmissedtickets JSON-RPC command.

func NewExistsMissedTicketsCmd

func NewExistsMissedTicketsCmd(txHashBlob string) *ExistsMissedTicketsCmd

NewExistsMissedTicketsCmd returns a new instance which can be used to issue an existsmissedtickets JSON-RPC command.

type FeeInfoBlock

type FeeInfoBlock = types.FeeInfoBlock

FeeInfoBlock is ticket fee information about a block.

type FeeInfoMempool

type FeeInfoMempool = types.FeeInfoMempool

FeeInfoMempool is ticket fee information about the mempool.

type FeeInfoRange

type FeeInfoRange = types.FeeInfoRange

FeeInfoRange is ticket fee information about a range.

type FeeInfoWindow

type FeeInfoWindow = types.FeeInfoWindow

FeeInfoWindow is ticket fee information about an adjustment window.

type GenerateCmd

type GenerateCmd = types.GenerateCmd

GenerateCmd defines the generate JSON-RPC command.

func NewGenerateCmd

func NewGenerateCmd(numBlocks uint32) *GenerateCmd

NewGenerateCmd returns a new instance which can be used to issue a generate JSON-RPC command.

type GetAddedNodeInfoCmd

type GetAddedNodeInfoCmd = types.GetAddedNodeInfoCmd

GetAddedNodeInfoCmd defines the getaddednodeinfo JSON-RPC command.

func NewGetAddedNodeInfoCmd

func NewGetAddedNodeInfoCmd(dns bool, node *string) *GetAddedNodeInfoCmd

NewGetAddedNodeInfoCmd returns a new instance which can be used to issue a getaddednodeinfo JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type GetAddedNodeInfoResult

type GetAddedNodeInfoResult = types.GetAddedNodeInfoResult

GetAddedNodeInfoResult models the data from the getaddednodeinfo command.

type GetAddedNodeInfoResultAddr

type GetAddedNodeInfoResultAddr = types.GetAddedNodeInfoResultAddr

GetAddedNodeInfoResultAddr models the data of the addresses portion of the getaddednodeinfo command.

type GetBestBlockCmd

type GetBestBlockCmd = types.GetBestBlockCmd

GetBestBlockCmd defines the getbestblock JSON-RPC command.

func NewGetBestBlockCmd

func NewGetBestBlockCmd() *GetBestBlockCmd

NewGetBestBlockCmd returns a new instance which can be used to issue a getbestblock JSON-RPC command.

type GetBestBlockHashCmd

type GetBestBlockHashCmd = types.GetBestBlockHashCmd

GetBestBlockHashCmd defines the getbestblockhash JSON-RPC command.

func NewGetBestBlockHashCmd

func NewGetBestBlockHashCmd() *GetBestBlockHashCmd

NewGetBestBlockHashCmd returns a new instance which can be used to issue a getbestblockhash JSON-RPC command.

type GetBestBlockResult

type GetBestBlockResult = types.GetBestBlockResult

GetBestBlockResult models the data from the getbestblock command.

type GetBlockChainInfoCmd

type GetBlockChainInfoCmd = types.GetBlockChainInfoCmd

GetBlockChainInfoCmd defines the getblockchaininfo JSON-RPC command.

func NewGetBlockChainInfoCmd

func NewGetBlockChainInfoCmd() *GetBlockChainInfoCmd

NewGetBlockChainInfoCmd returns a new instance which can be used to issue a getblockchaininfo JSON-RPC command.

type GetBlockChainInfoResult

type GetBlockChainInfoResult = types.GetBlockChainInfoResult

GetBlockChainInfoResult models the data returned from the getblockchaininfo command.

type GetBlockCmd

type GetBlockCmd = types.GetBlockCmd

GetBlockCmd defines the getblock JSON-RPC command.

func NewGetBlockCmd

func NewGetBlockCmd(hash string, verbose, verboseTx *bool) *GetBlockCmd

NewGetBlockCmd returns a new instance which can be used to issue a getblock JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type GetBlockCountCmd

type GetBlockCountCmd = types.GetBlockCountCmd

GetBlockCountCmd defines the getblockcount JSON-RPC command.

func NewGetBlockCountCmd

func NewGetBlockCountCmd() *GetBlockCountCmd

NewGetBlockCountCmd returns a new instance which can be used to issue a getblockcount JSON-RPC command.

type GetBlockHashCmd

type GetBlockHashCmd = types.GetBlockHashCmd

GetBlockHashCmd defines the getblockhash JSON-RPC command.

func NewGetBlockHashCmd

func NewGetBlockHashCmd(index int64) *GetBlockHashCmd

NewGetBlockHashCmd returns a new instance which can be used to issue a getblockhash JSON-RPC command.

type GetBlockHeaderCmd

type GetBlockHeaderCmd = types.GetBlockHeaderCmd

GetBlockHeaderCmd defines the getblockheader JSON-RPC command.

func NewGetBlockHeaderCmd

func NewGetBlockHeaderCmd(hash string, verbose *bool) *GetBlockHeaderCmd

NewGetBlockHeaderCmd returns a new instance which can be used to issue a getblockheader JSON-RPC command.

type GetBlockHeaderVerboseResult

type GetBlockHeaderVerboseResult = types.GetBlockHeaderVerboseResult

GetBlockHeaderVerboseResult models the data from the getblockheader command when the verbose flag is set. When the verbose flag is not set, getblockheader returns a hex-encoded string.

type GetBlockSubsidyCmd

type GetBlockSubsidyCmd = types.GetBlockSubsidyCmd

GetBlockSubsidyCmd defines the getblocksubsidy JSON-RPC command.

func NewGetBlockSubsidyCmd

func NewGetBlockSubsidyCmd(height int64, voters uint16) *GetBlockSubsidyCmd

NewGetBlockSubsidyCmd returns a new instance which can be used to issue a getblocksubsidy JSON-RPC command.

type GetBlockSubsidyResult

type GetBlockSubsidyResult = types.GetBlockSubsidyResult

GetBlockSubsidyResult models the data returned from the getblocksubsidy command.

type GetBlockTemplateCmd

type GetBlockTemplateCmd = types.GetBlockTemplateCmd

GetBlockTemplateCmd defines the getblocktemplate JSON-RPC command.

func NewGetBlockTemplateCmd

func NewGetBlockTemplateCmd(request *TemplateRequest) *GetBlockTemplateCmd

NewGetBlockTemplateCmd returns a new instance which can be used to issue a getblocktemplate JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type GetBlockTemplateResult

type GetBlockTemplateResult = types.GetBlockTemplateResult

GetBlockTemplateResult models the data returned from the getblocktemplate command.

type GetBlockTemplateResultAux

type GetBlockTemplateResultAux = types.GetBlockTemplateResultAux

GetBlockTemplateResultAux models the coinbaseaux field of the getblocktemplate command.

type GetBlockTemplateResultTx

type GetBlockTemplateResultTx = types.GetBlockTemplateResultTx

GetBlockTemplateResultTx models the transactions field of the getblocktemplate command.

type GetBlockVerboseResult

type GetBlockVerboseResult = types.GetBlockVerboseResult

GetBlockVerboseResult models the data from the getblock command when the verbose flag is set. When the verbose flag is not set, getblock returns a hex-encoded string. Contains Decred additions.

type GetCFilterCmd

type GetCFilterCmd = types.GetCFilterCmd

GetCFilterCmd defines the getcfilter JSON-RPC command.

func NewGetCFilterCmd

func NewGetCFilterCmd(hash string, filterType string) *GetCFilterCmd

NewGetCFilterCmd returns a new instance which can be used to issue a getcfilter JSON-RPC command.

type GetCFilterHeaderCmd

type GetCFilterHeaderCmd = types.GetCFilterHeaderCmd

GetCFilterHeaderCmd defines the getcfilterheader JSON-RPC command.

func NewGetCFilterHeaderCmd

func NewGetCFilterHeaderCmd(hash string, filterType string) *GetCFilterHeaderCmd

NewGetCFilterHeaderCmd returns a new instance which can be used to issue a getcfilterheader JSON-RPC command.

type GetChainTipsCmd

type GetChainTipsCmd = types.GetChainTipsCmd

GetChainTipsCmd defines the getchaintips JSON-RPC command.

func NewGetChainTipsCmd

func NewGetChainTipsCmd() *GetChainTipsCmd

NewGetChainTipsCmd returns a new instance which can be used to issue a getchaintips JSON-RPC command.

type GetChainTipsResult

type GetChainTipsResult = types.GetChainTipsResult

GetChainTipsResult models the data returns from the getchaintips command.

type GetCoinSupplyCmd

type GetCoinSupplyCmd = types.GetCoinSupplyCmd

GetCoinSupplyCmd defines the getcoinsupply JSON-RPC command.

func NewGetCoinSupplyCmd

func NewGetCoinSupplyCmd() *GetCoinSupplyCmd

NewGetCoinSupplyCmd returns a new instance which can be used to issue a getcoinsupply JSON-RPC command.

type GetConnectionCountCmd

type GetConnectionCountCmd = types.GetConnectionCountCmd

GetConnectionCountCmd defines the getconnectioncount JSON-RPC command.

func NewGetConnectionCountCmd

func NewGetConnectionCountCmd() *GetConnectionCountCmd

NewGetConnectionCountCmd returns a new instance which can be used to issue a getconnectioncount JSON-RPC command.

type GetCurrentNetCmd

type GetCurrentNetCmd = types.GetCurrentNetCmd

GetCurrentNetCmd defines the getcurrentnet JSON-RPC command.

func NewGetCurrentNetCmd

func NewGetCurrentNetCmd() *GetCurrentNetCmd

NewGetCurrentNetCmd returns a new instance which can be used to issue a getcurrentnet JSON-RPC command.

type GetDifficultyCmd

type GetDifficultyCmd = types.GetDifficultyCmd

GetDifficultyCmd defines the getdifficulty JSON-RPC command.

func NewGetDifficultyCmd

func NewGetDifficultyCmd() *GetDifficultyCmd

NewGetDifficultyCmd returns a new instance which can be used to issue a getdifficulty JSON-RPC command.

type GetGenerateCmd

type GetGenerateCmd = types.GetGenerateCmd

GetGenerateCmd defines the getgenerate JSON-RPC command.

func NewGetGenerateCmd

func NewGetGenerateCmd() *GetGenerateCmd

NewGetGenerateCmd returns a new instance which can be used to issue a getgenerate JSON-RPC command.

type GetHashesPerSecCmd

type GetHashesPerSecCmd = types.GetHashesPerSecCmd

GetHashesPerSecCmd defines the gethashespersec JSON-RPC command.

func NewGetHashesPerSecCmd

func NewGetHashesPerSecCmd() *GetHashesPerSecCmd

NewGetHashesPerSecCmd returns a new instance which can be used to issue a gethashespersec JSON-RPC command.

type GetHeadersCmd

type GetHeadersCmd struct {
	BlockLocators string `json:"blocklocators"`
	HashStop      string `json:"hashstop"`
}

GetHeadersCmd defines the getheaders JSON-RPC command.

func NewGetHeadersCmd

func NewGetHeadersCmd(blockLocators string, hashStop string) *GetHeadersCmd

NewGetHeadersCmd returns a new instance which can be used to issue a getheaders JSON-RPC command.

type GetHeadersResult

type GetHeadersResult = types.GetHeadersResult

GetHeadersResult models the data returned by the chain server getheaders command.

type GetInfoCmd

type GetInfoCmd = types.GetInfoCmd

GetInfoCmd defines the getinfo JSON-RPC command.

func NewGetInfoCmd

func NewGetInfoCmd() *GetInfoCmd

NewGetInfoCmd returns a new instance which can be used to issue a getinfo JSON-RPC command.

type GetMempoolInfoCmd

type GetMempoolInfoCmd = types.GetMempoolInfoCmd

GetMempoolInfoCmd defines the getmempoolinfo JSON-RPC command.

func NewGetMempoolInfoCmd

func NewGetMempoolInfoCmd() *GetMempoolInfoCmd

NewGetMempoolInfoCmd returns a new instance which can be used to issue a getmempool JSON-RPC command.

type GetMempoolInfoResult

type GetMempoolInfoResult = types.GetMempoolInfoResult

GetMempoolInfoResult models the data returned from the getmempoolinfo command.

type GetMiningInfoCmd

type GetMiningInfoCmd = types.GetMiningInfoCmd

GetMiningInfoCmd defines the getmininginfo JSON-RPC command.

func NewGetMiningInfoCmd

func NewGetMiningInfoCmd() *GetMiningInfoCmd

NewGetMiningInfoCmd returns a new instance which can be used to issue a getmininginfo JSON-RPC command.

type GetMiningInfoResult

type GetMiningInfoResult = types.GetMiningInfoResult

GetMiningInfoResult models the data from the getmininginfo command. Contains Decred additions.

type GetNetTotalsCmd

type GetNetTotalsCmd = types.GetNetTotalsCmd

GetNetTotalsCmd defines the getnettotals JSON-RPC command.

func NewGetNetTotalsCmd

func NewGetNetTotalsCmd() *GetNetTotalsCmd

NewGetNetTotalsCmd returns a new instance which can be used to issue a getnettotals JSON-RPC command.

type GetNetTotalsResult

type GetNetTotalsResult = types.GetNetTotalsResult

GetNetTotalsResult models the data returned from the getnettotals command.

type GetNetworkHashPSCmd

type GetNetworkHashPSCmd = types.GetNetworkHashPSCmd

GetNetworkHashPSCmd defines the getnetworkhashps JSON-RPC command.

func NewGetNetworkHashPSCmd

func NewGetNetworkHashPSCmd(numBlocks, height *int) *GetNetworkHashPSCmd

NewGetNetworkHashPSCmd returns a new instance which can be used to issue a getnetworkhashps JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type GetNetworkInfoCmd

type GetNetworkInfoCmd = types.GetNetworkInfoCmd

GetNetworkInfoCmd defines the getnetworkinfo JSON-RPC command.

func NewGetNetworkInfoCmd

func NewGetNetworkInfoCmd() *GetNetworkInfoCmd

NewGetNetworkInfoCmd returns a new instance which can be used to issue a getnetworkinfo JSON-RPC command.

type GetNetworkInfoResult

type GetNetworkInfoResult = types.GetNetworkInfoResult

GetNetworkInfoResult models the data returned from the getnetworkinfo command.

type GetPeerInfoCmd

type GetPeerInfoCmd = types.GetPeerInfoCmd

GetPeerInfoCmd defines the getpeerinfo JSON-RPC command.

func NewGetPeerInfoCmd

func NewGetPeerInfoCmd() *GetPeerInfoCmd

NewGetPeerInfoCmd returns a new instance which can be used to issue a getpeer JSON-RPC command.

type GetPeerInfoResult

type GetPeerInfoResult = types.GetPeerInfoResult

GetPeerInfoResult models the data returned from the getpeerinfo command.

type GetRawMempoolCmd

type GetRawMempoolCmd = types.GetRawMempoolCmd

GetRawMempoolCmd defines the getmempool JSON-RPC command.

func NewGetRawMempoolCmd

func NewGetRawMempoolCmd(verbose *bool, txType *string) *GetRawMempoolCmd

NewGetRawMempoolCmd returns a new instance which can be used to issue a getrawmempool JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type GetRawMempoolTxTypeCmd

type GetRawMempoolTxTypeCmd = types.GetRawMempoolTxTypeCmd

GetRawMempoolTxTypeCmd defines the type used in the getrawmempool JSON-RPC command for the TxType command field.

type GetRawMempoolVerboseResult

type GetRawMempoolVerboseResult = types.GetRawMempoolVerboseResult

GetRawMempoolVerboseResult models the data returned from the getrawmempool command when the verbose flag is set. When the verbose flag is not set, getrawmempool returns an array of transaction hashes.

type GetRawTransactionCmd

type GetRawTransactionCmd = types.GetRawTransactionCmd

GetRawTransactionCmd defines the getrawtransaction JSON-RPC command.

NOTE: This field is an int versus a bool to remain compatible with Bitcoin Core even though it really should be a bool.

func NewGetRawTransactionCmd

func NewGetRawTransactionCmd(txHash string, verbose *int) *GetRawTransactionCmd

NewGetRawTransactionCmd returns a new instance which can be used to issue a getrawtransaction JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type GetStakeDifficultyCmd

type GetStakeDifficultyCmd = types.GetStakeDifficultyCmd

GetStakeDifficultyCmd is a type handling custom marshaling and unmarshaling of getstakedifficulty JSON RPC commands.

func NewGetStakeDifficultyCmd

func NewGetStakeDifficultyCmd() *GetStakeDifficultyCmd

NewGetStakeDifficultyCmd returns a new instance which can be used to issue a JSON-RPC getstakedifficulty command.

type GetStakeDifficultyResult

type GetStakeDifficultyResult = types.GetStakeDifficultyResult

GetStakeDifficultyResult models the data returned from the getstakedifficulty command.

type GetStakeVersionInfoCmd

type GetStakeVersionInfoCmd = types.GetStakeVersionInfoCmd

GetStakeVersionInfoCmd returns stake version info for the current interval. Optionally, Count indicates how many additional intervals to return.

func NewGetStakeVersionInfoCmd

func NewGetStakeVersionInfoCmd(count int32) *GetStakeVersionInfoCmd

NewGetStakeVersionInfoCmd returns a new instance which can be used to issue a JSON-RPC getstakeversioninfo command.

type GetStakeVersionInfoResult

type GetStakeVersionInfoResult = types.GetStakeVersionInfoResult

GetStakeVersionInfoResult models the resulting data for getstakeversioninfo command.

type GetStakeVersionsCmd

type GetStakeVersionsCmd = types.GetStakeVersionsCmd

GetStakeVersionsCmd returns stake version for a range of blocks. Count indicates how many blocks are walked backwards.

func NewGetStakeVersionsCmd

func NewGetStakeVersionsCmd(hash string, count int32) *GetStakeVersionsCmd

NewGetStakeVersionsCmd returns a new instance which can be used to issue a JSON-RPC getstakeversions command.

type GetStakeVersionsResult

type GetStakeVersionsResult = types.GetStakeVersionsResult

GetStakeVersionsResult models the data returned from the getstakeversions command.

type GetTicketPoolValueCmd

type GetTicketPoolValueCmd = types.GetTicketPoolValueCmd

GetTicketPoolValueCmd defines the getticketpoolvalue JSON-RPC command.

func NewGetTicketPoolValueCmd

func NewGetTicketPoolValueCmd() *GetTicketPoolValueCmd

NewGetTicketPoolValueCmd returns a new instance which can be used to issue a getticketpoolvalue JSON-RPC command.

type GetTxOutCmd

type GetTxOutCmd = types.GetTxOutCmd

GetTxOutCmd defines the gettxout JSON-RPC command.

func NewGetTxOutCmd

func NewGetTxOutCmd(txHash string, vout uint32, includeMempool *bool) *GetTxOutCmd

NewGetTxOutCmd returns a new instance which can be used to issue a gettxout JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type GetTxOutResult

type GetTxOutResult = types.GetTxOutResult

GetTxOutResult models the data from the gettxout command.

type GetTxOutSetInfoCmd

type GetTxOutSetInfoCmd = types.GetTxOutSetInfoCmd

GetTxOutSetInfoCmd defines the gettxoutsetinfo JSON-RPC command.

func NewGetTxOutSetInfoCmd

func NewGetTxOutSetInfoCmd() *GetTxOutSetInfoCmd

NewGetTxOutSetInfoCmd returns a new instance which can be used to issue a gettxoutsetinfo JSON-RPC command.

type GetVoteInfoCmd

type GetVoteInfoCmd = types.GetVoteInfoCmd

GetVoteInfoCmd returns voting results over a range of blocks. Count indicates how many blocks are walked backwards.

func NewGetVoteInfoCmd

func NewGetVoteInfoCmd(version uint32) *GetVoteInfoCmd

NewGetVoteInfoCmd returns a new instance which can be used to issue a JSON-RPC getvoteinfo command.

type GetVoteInfoResult

type GetVoteInfoResult = types.GetVoteInfoResult

GetVoteInfoResult models the data returned from the getvoteinfo command.

type GetWorkCmd

type GetWorkCmd = types.GetWorkCmd

GetWorkCmd defines the getwork JSON-RPC command.

func NewGetWorkCmd

func NewGetWorkCmd(data *string) *GetWorkCmd

NewGetWorkCmd returns a new instance which can be used to issue a getwork JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type GetWorkResult

type GetWorkResult = types.GetWorkResult

GetWorkResult models the data from the getwork command.

type HelpCmd

type HelpCmd = types.HelpCmd

HelpCmd defines the help JSON-RPC command.

func NewHelpCmd

func NewHelpCmd(command *string) *HelpCmd

NewHelpCmd returns a new instance which can be used to issue a help JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type InfoChainResult

type InfoChainResult = types.InfoChainResult

InfoChainResult models the data returned by the chain server getinfo command.

type LiveTicketsCmd

type LiveTicketsCmd = types.LiveTicketsCmd

LiveTicketsCmd is a type handling custom marshaling and unmarshaling of livetickets JSON RPC commands.

func NewLiveTicketsCmd

func NewLiveTicketsCmd() *LiveTicketsCmd

NewLiveTicketsCmd returns a new instance which can be used to issue a JSON-RPC livetickets command.

type LiveTicketsResult

type LiveTicketsResult = types.LiveTicketsResult

LiveTicketsResult models the data returned from the livetickets command.

type LoadTxFilterCmd

type LoadTxFilterCmd = types.LoadTxFilterCmd

LoadTxFilterCmd defines the loadtxfilter request parameters to load or reload a transaction filter.

func NewLoadTxFilterCmd

func NewLoadTxFilterCmd(reload bool, addresses []string, outPoints []OutPoint) *LoadTxFilterCmd

NewLoadTxFilterCmd returns a new instance which can be used to issue a loadtxfilter JSON-RPC command.

type LocalAddressesResult

type LocalAddressesResult = types.LocalAddressesResult

LocalAddressesResult models the localaddresses data from the getnetworkinfo command.

type MissedTicketsCmd

type MissedTicketsCmd = types.MissedTicketsCmd

MissedTicketsCmd is a type handling custom marshaling and unmarshaling of missedtickets JSON RPC commands.

func NewMissedTicketsCmd

func NewMissedTicketsCmd() *MissedTicketsCmd

NewMissedTicketsCmd returns a new instance which can be used to issue a JSON-RPC missedtickets command.

type MissedTicketsResult

type MissedTicketsResult = types.MissedTicketsResult

MissedTicketsResult models the data returned from the missedtickets command.

type NetworksResult

type NetworksResult = types.NetworksResult

NetworksResult models the networks data from the getnetworkinfo command.

type NewTicketsNtfn

type NewTicketsNtfn = types.NewTicketsNtfn

NewTicketsNtfn is a type handling custom marshaling and unmarshaling of newtickets JSON websocket notifications.

func NewNewTicketsNtfn

func NewNewTicketsNtfn(hash string, height int32, stakeDiff int64, tickets []string) *NewTicketsNtfn

NewNewTicketsNtfn creates a new NewTicketsNtfn.

type NodeCmd

type NodeCmd = types.NodeCmd

NodeCmd defines the dropnode JSON-RPC command.

func NewNodeCmd

func NewNodeCmd(subCmd NodeSubCmd, target string, connectSubCmd *string) *NodeCmd

NewNodeCmd returns a new instance which can be used to issue a `node` JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type NodeSubCmd

type NodeSubCmd = types.NodeSubCmd

NodeSubCmd defines the type used in the addnode JSON-RPC command for the sub command field.

type NotifyBlocksCmd

type NotifyBlocksCmd = types.NotifyBlocksCmd

NotifyBlocksCmd defines the notifyblocks JSON-RPC command.

func NewNotifyBlocksCmd

func NewNotifyBlocksCmd() *NotifyBlocksCmd

NewNotifyBlocksCmd returns a new instance which can be used to issue a notifyblocks JSON-RPC command.

type NotifyNewTicketsCmd

type NotifyNewTicketsCmd = types.NotifyNewTicketsCmd

NotifyNewTicketsCmd is a type handling custom marshaling and unmarshaling of notifynewtickets JSON websocket extension commands.

func NewNotifyNewTicketsCmd

func NewNotifyNewTicketsCmd() *NotifyNewTicketsCmd

NewNotifyNewTicketsCmd creates a new NotifyNewTicketsCmd.

type NotifyNewTransactionsCmd

type NotifyNewTransactionsCmd = types.NotifyNewTransactionsCmd

NotifyNewTransactionsCmd defines the notifynewtransactions JSON-RPC command.

func NewNotifyNewTransactionsCmd

func NewNotifyNewTransactionsCmd(verbose *bool) *NotifyNewTransactionsCmd

NewNotifyNewTransactionsCmd returns a new instance which can be used to issue a notifynewtransactions JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type NotifySpentAndMissedTicketsCmd

type NotifySpentAndMissedTicketsCmd = types.NotifySpentAndMissedTicketsCmd

NotifySpentAndMissedTicketsCmd is a type handling custom marshaling and unmarshaling of notifyspentandmissedtickets JSON websocket extension commands.

func NewNotifySpentAndMissedTicketsCmd

func NewNotifySpentAndMissedTicketsCmd() *NotifySpentAndMissedTicketsCmd

NewNotifySpentAndMissedTicketsCmd creates a new NotifySpentAndMissedTicketsCmd.

type NotifyStakeDifficultyCmd

type NotifyStakeDifficultyCmd = types.NotifyStakeDifficultyCmd

NotifyStakeDifficultyCmd is a type handling custom marshaling and unmarshaling of notifystakedifficulty JSON websocket extension commands.

func NewNotifyStakeDifficultyCmd

func NewNotifyStakeDifficultyCmd() *NotifyStakeDifficultyCmd

NewNotifyStakeDifficultyCmd creates a new NotifyStakeDifficultyCmd.

type NotifyWinningTicketsCmd

type NotifyWinningTicketsCmd = types.NotifyWinningTicketsCmd

NotifyWinningTicketsCmd is a type handling custom marshaling and unmarshaling of notifywinningtickets JSON websocket extension commands.

func NewNotifyWinningTicketsCmd

func NewNotifyWinningTicketsCmd() *NotifyWinningTicketsCmd

NewNotifyWinningTicketsCmd creates a new NotifyWinningTicketsCmd.

type OutPoint

type OutPoint = types.OutPoint

OutPoint describes a transaction outpoint that will be marshalled to and from JSON. Contains Decred addition.

type PingCmd

type PingCmd = types.PingCmd

PingCmd defines the ping JSON-RPC command.

func NewPingCmd

func NewPingCmd() *PingCmd

NewPingCmd returns a new instance which can be used to issue a ping JSON-RPC command.

type PrevOut

type PrevOut = types.PrevOut

PrevOut represents previous output for an input Vin.

type RPCError

type RPCError = v3.RPCError

RPCError represents an error that is used as a part of a JSON-RPC Response object.

func NewRPCError

func NewRPCError(code RPCErrorCode, message string) *RPCError

NewRPCError constructs and returns a new JSON-RPC error that is suitable for use in a JSON-RPC Response object.

type RPCErrorCode

type RPCErrorCode = v3.RPCErrorCode

RPCErrorCode represents an error code to be used as a part of an RPCError which is in turn used in a JSON-RPC Response object.

A specific type is used to help ensure the wrong errors aren't used.

const (
	ErrRPCMisc                RPCErrorCode = -1
	ErrRPCForbiddenBySafeMode RPCErrorCode = -2
	ErrRPCType                RPCErrorCode = -3
	ErrRPCInvalidAddressOrKey RPCErrorCode = -5
	ErrRPCOutOfMemory         RPCErrorCode = -7
	ErrRPCInvalidParameter    RPCErrorCode = -8
	ErrRPCDatabase            RPCErrorCode = -20
	ErrRPCDeserialization     RPCErrorCode = -22
	ErrRPCVerify              RPCErrorCode = -25
)

General application defined JSON errors.

const (
	ErrRPCClientNotConnected      RPCErrorCode = -9
	ErrRPCClientInInitialDownload RPCErrorCode = -10
)

Peer-to-peer client errors.

const (
	ErrRPCWallet                    RPCErrorCode = -4
	ErrRPCWalletInsufficientFunds   RPCErrorCode = -6
	ErrRPCWalletInvalidAccountName  RPCErrorCode = -11
	ErrRPCWalletKeypoolRanOut       RPCErrorCode = -12
	ErrRPCWalletUnlockNeeded        RPCErrorCode = -13
	ErrRPCWalletPassphraseIncorrect RPCErrorCode = -14
	ErrRPCWalletWrongEncState       RPCErrorCode = -15
	ErrRPCWalletEncryptionFailed    RPCErrorCode = -16
	ErrRPCWalletAlreadyUnlocked     RPCErrorCode = -17
)

Wallet JSON errors

const (
	ErrRPCBlockNotFound     RPCErrorCode = -5
	ErrRPCBlockCount        RPCErrorCode = -5
	ErrRPCBestBlockHash     RPCErrorCode = -5
	ErrRPCDifficulty        RPCErrorCode = -5
	ErrRPCOutOfRange        RPCErrorCode = -1
	ErrRPCNoTxInfo          RPCErrorCode = -5
	ErrRPCNoCFIndex         RPCErrorCode = -5
	ErrRPCNoNewestBlockInfo RPCErrorCode = -5
	ErrRPCInvalidTxVout     RPCErrorCode = -5
	ErrRPCRawTxString       RPCErrorCode = -32602
	ErrRPCDecodeHexString   RPCErrorCode = -22
	ErrRPCDuplicateTx       RPCErrorCode = -40
)

Specific Errors related to commands. These are the ones a user of the RPC server are most likely to see. Generally, the codes should match one of the more general errors above.

const (
	ErrRPCNoWallet      RPCErrorCode = -1
	ErrRPCUnimplemented RPCErrorCode = -1
)

Errors that are specific to btcd.

type RebroadcastMissedCmd

type RebroadcastMissedCmd = types.RebroadcastMissedCmd

RebroadcastMissedCmd is a type handling custom marshaling and unmarshaling of rebroadcastwinners JSON RPC commands.

func NewRebroadcastMissedCmd

func NewRebroadcastMissedCmd() *RebroadcastMissedCmd

NewRebroadcastMissedCmd returns a new instance which can be used to issue a JSON-RPC rebroadcastmissed command.

type RebroadcastWinnersCmd

type RebroadcastWinnersCmd = types.RebroadcastWinnersCmd

RebroadcastWinnersCmd is a type handling custom marshaling and unmarshaling of rebroadcastwinners JSON RPC commands.

func NewRebroadcastWinnersCmd

func NewRebroadcastWinnersCmd() *RebroadcastWinnersCmd

NewRebroadcastWinnersCmd returns a new instance which can be used to issue a JSON-RPC rebroadcastwinners command.

type RelevantTxAcceptedNtfn

type RelevantTxAcceptedNtfn = types.RelevantTxAcceptedNtfn

RelevantTxAcceptedNtfn defines the parameters to the relevanttxaccepted JSON-RPC notification.

func NewRelevantTxAcceptedNtfn

func NewRelevantTxAcceptedNtfn(txHex string) *RelevantTxAcceptedNtfn

NewRelevantTxAcceptedNtfn returns a new instance which can be used to issue a relevantxaccepted JSON-RPC notification.

type ReorganizationNtfn

type ReorganizationNtfn = types.ReorganizationNtfn

ReorganizationNtfn defines the reorganization JSON-RPC notification.

func NewReorganizationNtfn

func NewReorganizationNtfn(oldHash string, oldHeight int32, newHash string,
	newHeight int32) *ReorganizationNtfn

NewReorganizationNtfn returns a new instance which can be used to issue a blockdisconnected JSON-RPC notification.

type Request

type Request = v3.Request

Request represents raw JSON-RPC requests. The Method field identifies the specific command type which in turn leads to different parameters. Callers typically will not use this directly since this package provides a statically typed command infrastructure which handles creation of these requests, however this struct is being exported in case the caller wants to construct raw requests for some reason.

func NewRequest

func NewRequest(rpcVersion string, id interface{}, method string, params []interface{}) (*Request, error)

NewRequest returns a new JSON-RPC request object given the provided rpc version, id, method, and parameters. The parameters are marshalled into a json.RawMessage for the Params field of the returned request object. This function is only provided in case the caller wants to construct raw requests for some reason. Typically callers will instead want to create a registered concrete command type with the NewCmd or New<Foo>Cmd functions and call the MarshalCmd function with that command to generate the marshalled JSON-RPC request.

type RescanCmd

type RescanCmd struct {
	// Concatenated block hashes in non-byte-reversed hex encoding.  Must
	// have length evenly divisible by 2*chainhash.HashSize.
	BlockHashes string
}

RescanCmd defines the rescan JSON-RPC command.

func NewRescanCmd

func NewRescanCmd(blockHashes string) *RescanCmd

NewRescanCmd returns a new instance which can be used to issue a rescan JSON-RPC command.

type RescanResult

type RescanResult = types.RescanResult

RescanResult models the result object returned by the rescan RPC.

type RescannedBlock

type RescannedBlock = types.RescannedBlock

RescannedBlock contains the hash and all discovered transactions of a single rescanned block.

type Response

type Response = v3.Response

Response is the general form of a JSON-RPC response. The type of the Result field varies from one command to the next, so it is implemented as an interface. The ID field has to be a pointer to allow for a nil value when empty.

func NewResponse

func NewResponse(rpcVersion string, id interface{}, marshalledResult []byte, rpcErr *RPCError) (*Response, error)

NewResponse returns a new JSON-RPC response object given the provided rpc version, id, marshalled result, and RPC error. This function is only provided in case the caller wants to construct raw responses for some reason. Typically callers will instead want to create the fully marshalled JSON-RPC response to send over the wire with the MarshalResponse function.

type SStxCommitOut

type SStxCommitOut = types.SStxCommitOut

SStxCommitOut represents the output to an SStx transaction. Specifically a a commitment address and amount, and a change address and amount.

type SStxInput

type SStxInput = types.SStxInput

SStxInput represents the inputs to an SStx transaction. Specifically a transactionsha and output number pair, along with the output amounts.

type ScriptPubKeyResult

type ScriptPubKeyResult = types.ScriptPubKeyResult

ScriptPubKeyResult models the scriptPubKey data of a tx script. It is defined separately since it is used by multiple commands.

type ScriptSig

type ScriptSig = types.ScriptSig

ScriptSig models a signature script. It is defined separately since it only applies to non-coinbase. Therefore the field in the Vin structure needs to be a pointer.

type SearchRawTransactionsCmd

type SearchRawTransactionsCmd = types.SearchRawTransactionsCmd

SearchRawTransactionsCmd defines the searchrawtransactions JSON-RPC command.

func NewSearchRawTransactionsCmd

func NewSearchRawTransactionsCmd(address string, verbose, skip, count *int, vinExtra *int, reverse *bool, filterAddrs *[]string) *SearchRawTransactionsCmd

NewSearchRawTransactionsCmd returns a new instance which can be used to issue a sendrawtransaction JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type SearchRawTransactionsResult

type SearchRawTransactionsResult = types.SearchRawTransactionsResult

SearchRawTransactionsResult models the data from the searchrawtransaction command.

type SendRawTransactionCmd

type SendRawTransactionCmd = types.SendRawTransactionCmd

SendRawTransactionCmd defines the sendrawtransaction JSON-RPC command.

func NewSendRawTransactionCmd

func NewSendRawTransactionCmd(hexTx string, allowHighFees *bool) *SendRawTransactionCmd

NewSendRawTransactionCmd returns a new instance which can be used to issue a sendrawtransaction JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type SessionCmd

type SessionCmd = types.SessionCmd

SessionCmd defines the session JSON-RPC command.

func NewSessionCmd

func NewSessionCmd() *SessionCmd

NewSessionCmd returns a new instance which can be used to issue a session JSON-RPC command.

type SessionResult

type SessionResult = types.SessionResult

SessionResult models the data from the session command.

type SetGenerateCmd

type SetGenerateCmd = types.SetGenerateCmd

SetGenerateCmd defines the setgenerate JSON-RPC command.

func NewSetGenerateCmd

func NewSetGenerateCmd(generate bool, genProcLimit *int) *SetGenerateCmd

NewSetGenerateCmd returns a new instance which can be used to issue a setgenerate JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type SpentAndMissedTicketsNtfn

type SpentAndMissedTicketsNtfn = types.SpentAndMissedTicketsNtfn

SpentAndMissedTicketsNtfn is a type handling custom marshaling and unmarshaling of spentandmissedtickets JSON websocket notifications.

func NewSpentAndMissedTicketsNtfn

func NewSpentAndMissedTicketsNtfn(hash string, height int32, stakeDiff int64, tickets map[string]string) *SpentAndMissedTicketsNtfn

NewSpentAndMissedTicketsNtfn creates a new SpentAndMissedTicketsNtfn.

type StakeDifficultyNtfn

type StakeDifficultyNtfn = types.StakeDifficultyNtfn

StakeDifficultyNtfn is a type handling custom marshaling and unmarshaling of stakedifficulty JSON websocket notifications.

func NewStakeDifficultyNtfn

func NewStakeDifficultyNtfn(hash string, height int32, stakeDiff int64) *StakeDifficultyNtfn

NewStakeDifficultyNtfn creates a new StakeDifficultyNtfn.

type StakeVersions

type StakeVersions = types.StakeVersions

StakeVersions models the data for GetStakeVersionsResult.

type StopCmd

type StopCmd = types.StopCmd

StopCmd defines the stop JSON-RPC command.

func NewStopCmd

func NewStopCmd() *StopCmd

NewStopCmd returns a new instance which can be used to issue a stop JSON-RPC command.

type StopNotifyBlocksCmd

type StopNotifyBlocksCmd = types.StopNotifyBlocksCmd

StopNotifyBlocksCmd defines the stopnotifyblocks JSON-RPC command.

func NewStopNotifyBlocksCmd

func NewStopNotifyBlocksCmd() *StopNotifyBlocksCmd

NewStopNotifyBlocksCmd returns a new instance which can be used to issue a stopnotifyblocks JSON-RPC command.

type StopNotifyNewTransactionsCmd

type StopNotifyNewTransactionsCmd = types.StopNotifyNewTransactionsCmd

StopNotifyNewTransactionsCmd defines the stopnotifynewtransactions JSON-RPC command.

func NewStopNotifyNewTransactionsCmd

func NewStopNotifyNewTransactionsCmd() *StopNotifyNewTransactionsCmd

NewStopNotifyNewTransactionsCmd returns a new instance which can be used to issue a stopnotifynewtransactions JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type SubmitBlockCmd

type SubmitBlockCmd = types.SubmitBlockCmd

SubmitBlockCmd defines the submitblock JSON-RPC command.

func NewSubmitBlockCmd

func NewSubmitBlockCmd(hexBlock string, options *SubmitBlockOptions) *SubmitBlockCmd

NewSubmitBlockCmd returns a new instance which can be used to issue a submitblock JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type SubmitBlockOptions

type SubmitBlockOptions = types.SubmitBlockOptions

SubmitBlockOptions represents the optional options struct provided with a SubmitBlockCmd command.

type TemplateRequest

type TemplateRequest = types.TemplateRequest

TemplateRequest is a request object as defined in BIP22 (https://en.bitcoin.it/wiki/BIP_0022), it is optionally provided as an pointer argument to GetBlockTemplateCmd.

type Ticket

type Ticket = types.Ticket

Ticket is the structure representing a ticket.

type TicketFeeInfoCmd

type TicketFeeInfoCmd = types.TicketFeeInfoCmd

TicketFeeInfoCmd defines the ticketsfeeinfo JSON-RPC command.

func NewTicketFeeInfoCmd

func NewTicketFeeInfoCmd(blocks *uint32, windows *uint32) *TicketFeeInfoCmd

NewTicketFeeInfoCmd returns a new instance which can be used to issue a JSON-RPC ticket fee info command.

type TicketFeeInfoResult

type TicketFeeInfoResult = types.TicketFeeInfoResult

TicketFeeInfoResult models the data returned from the ticketfeeinfo command. command.

type TicketVWAPCmd

type TicketVWAPCmd = types.TicketVWAPCmd

TicketVWAPCmd defines the ticketvwap JSON-RPC command.

func NewTicketVWAPCmd

func NewTicketVWAPCmd(start *uint32, end *uint32) *TicketVWAPCmd

NewTicketVWAPCmd returns a new instance which can be used to issue a JSON-RPC ticket volume weight average price command.

type TicketsForAddressCmd

type TicketsForAddressCmd = types.TicketsForAddressCmd

TicketsForAddressCmd defines the ticketsforbucket JSON-RPC command.

func NewTicketsForAddressCmd

func NewTicketsForAddressCmd(addr string) *TicketsForAddressCmd

NewTicketsForAddressCmd returns a new instance which can be used to issue a JSON-RPC tickets for bucket command.

type TicketsForAddressResult

type TicketsForAddressResult = types.TicketsForAddressResult

TicketsForAddressResult models the data returned from the ticketforaddress command.

type TransactionInput

type TransactionInput = types.TransactionInput

TransactionInput represents the inputs to a transaction. Specifically a transaction hash and output number pair. Contains Decred additions.

type TxAcceptedNtfn

type TxAcceptedNtfn = types.TxAcceptedNtfn

TxAcceptedNtfn defines the txaccepted JSON-RPC notification.

func NewTxAcceptedNtfn

func NewTxAcceptedNtfn(txHash string, amount float64) *TxAcceptedNtfn

NewTxAcceptedNtfn returns a new instance which can be used to issue a txaccepted JSON-RPC notification.

type TxAcceptedVerboseNtfn

type TxAcceptedVerboseNtfn = types.TxAcceptedVerboseNtfn

TxAcceptedVerboseNtfn defines the txacceptedverbose JSON-RPC notification.

func NewTxAcceptedVerboseNtfn

func NewTxAcceptedVerboseNtfn(rawTx TxRawResult) *TxAcceptedVerboseNtfn

NewTxAcceptedVerboseNtfn returns a new instance which can be used to issue a txacceptedverbose JSON-RPC notification.

type TxFeeInfoCmd

type TxFeeInfoCmd = types.TxFeeInfoCmd

TxFeeInfoCmd defines the ticketsfeeinfo JSON-RPC command.

func NewTxFeeInfoCmd

func NewTxFeeInfoCmd(blocks *uint32, start *uint32, end *uint32) *TxFeeInfoCmd

NewTxFeeInfoCmd returns a new instance which can be used to issue a JSON-RPC ticket fee info command.

type TxFeeInfoResult

type TxFeeInfoResult = types.TxFeeInfoResult

TxFeeInfoResult models the data returned from the ticketfeeinfo command. command.

type TxRawDecodeResult

type TxRawDecodeResult = types.TxRawDecodeResult

TxRawDecodeResult models the data from the decoderawtransaction command.

type TxRawResult

type TxRawResult = types.TxRawResult

TxRawResult models the data from the getrawtransaction command.

type UsageFlag

type UsageFlag = v3.UsageFlag

UsageFlag define flags that specify additional properties about the circumstances under which a command can be used.

const (
	// UFWalletOnly indicates that the command can only be used with an RPC
	// server that supports wallet commands.
	//
	// Deprecated: This flag is not used in the v3 API and is masked away
	// when presenting formatted UsageFlag strings.
	UFWalletOnly UsageFlag = 1 << iota

	// UFWebsocketOnly indicates that the command can only be used when
	// communicating with an RPC server over websockets.  This typically
	// applies to notifications and notification registration functions
	// since neiher makes since when using a single-shot HTTP-POST request.
	UFWebsocketOnly

	// UFNotification indicates that the command is actually a notification.
	// This means when it is marshalled, the ID must be nil.
	UFNotification
)

func MethodUsageFlags

func MethodUsageFlags(method string) (UsageFlag, error)

MethodUsageFlags returns the usage flags for the passed command method. The provided method must be associated with a registered type. All commands provided by this package are registered by default.

type ValidateAddressChainResult

type ValidateAddressChainResult = types.ValidateAddressChainResult

ValidateAddressChainResult models the data returned by the chain server validateaddress command.

type ValidateAddressCmd

type ValidateAddressCmd = types.ValidateAddressCmd

ValidateAddressCmd defines the validateaddress JSON-RPC command.

func NewValidateAddressCmd

func NewValidateAddressCmd(address string) *ValidateAddressCmd

NewValidateAddressCmd returns a new instance which can be used to issue a validateaddress JSON-RPC command.

type VerifyChainCmd

type VerifyChainCmd = types.VerifyChainCmd

VerifyChainCmd defines the verifychain JSON-RPC command.

func NewVerifyChainCmd

func NewVerifyChainCmd(checkLevel, checkDepth *int64) *VerifyChainCmd

NewVerifyChainCmd returns a new instance which can be used to issue a verifychain JSON-RPC command.

The parameters which are pointers indicate they are optional. Passing nil for optional parameters will use the default value.

type VerifyMessageCmd

type VerifyMessageCmd = types.VerifyMessageCmd

VerifyMessageCmd defines the verifymessage JSON-RPC command.

func NewVerifyMessageCmd

func NewVerifyMessageCmd(address, signature, message string) *VerifyMessageCmd

NewVerifyMessageCmd returns a new instance which can be used to issue a verifymessage JSON-RPC command.

type VersionBits

type VersionBits = types.VersionBits

VersionBits models a generic version:bits tuple.

type VersionCmd

type VersionCmd = types.VersionCmd

VersionCmd defines the version JSON-RPC command.

func NewVersionCmd

func NewVersionCmd() *VersionCmd

NewVersionCmd returns a new instance which can be used to issue a JSON-RPC version command.

type VersionCount

type VersionCount = types.VersionCount

VersionCount models a generic version:count tuple.

type VersionInterval

type VersionInterval = types.VersionInterval

VersionInterval models a cooked version count for an interval.

type VersionResult

type VersionResult = types.VersionResult

VersionResult models objects included in the version response. In the actual result, these objects are keyed by the program or API name.

type Vin

type Vin = types.Vin

Vin models parts of the tx data. It is defined separately since getrawtransaction, decoderawtransaction, and searchrawtransaction use the same structure.

type VinPrevOut

type VinPrevOut = types.VinPrevOut

VinPrevOut is like Vin except it includes PrevOut. It is used by searchrawtransaction

type Vout

type Vout = types.Vout

Vout models parts of the tx data. It is defined separately since both getrawtransaction and decoderawtransaction use the same structure.

type WinningTicketsNtfn

type WinningTicketsNtfn = types.WinningTicketsNtfn

WinningTicketsNtfn is a type handling custom marshaling and unmarshaling of blockconnected JSON websocket notifications.

func NewWinningTicketsNtfn

func NewWinningTicketsNtfn(hash string, height int32, tickets map[string]string) *WinningTicketsNtfn

NewWinningTicketsNtfn creates a new WinningTicketsNtfn.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL