func MarshalCmd(id interface{}, cmd interface{}) ([]byte, error) {
	rt := reflect.TypeOf(cmd)
	registerLock.RLock()
	method, ok := concreteTypeToMethod[rt]
	registerLock.RUnlock()
	if !ok {
		str := fmt.Sprintf("%q is not registered", method)
		return nil, makeError(ErrUnregisteredMethod, str)
	}
	rv := reflect.ValueOf(cmd)
	if rv.IsNil() {
		str := fmt.Sprint("the specified command is nil")
		return nil, makeError(ErrInvalidType, str)
	}
	params := makeParams(rt.Elem(), rv.Elem())
	rawCmd, err := NewRequest(id, method, params)
	if err != nil {
		return nil, err
	}
	return json.Marshal(rawCmd)
}
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.
package btcjson
import (
	"encoding/json"
	"fmt"
	"reflect"
	"strconv"
	"strings"
)
func makeParams(rt reflect.Type, rv reflect.Value) []interface{} {
	numFields := rt.NumField()
	params := make([]interface{}, 0, numFields)
	for i := 0; i < numFields; i++ {
		rtf := rt.Field(i)
		rvf := rv.Field(i)
		if rtf.Type.Kind() == reflect.Ptr {
			if rvf.IsNil() {
				break
			}
			rvf.Elem()
		}
		params = append(params, rvf.Interface())
	}
	return params
}