Description

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

NewCmd is referenced in 2 repositories

github.com/btcsuite/btcd

...