func NewQuery(req *jsonrpc.RPCRequest, walletID string) (*Query, error) {
	if strings.TrimSpace(req.Method) == "" {
		return nil, errors.Err("no method in request")
	}

	q := &Query{Request: req, WalletID: walletID}

	if !methodInList(q.Method(), relaxedMethods) && !methodInList(q.Method(), walletSpecificMethods) {
		return nil, rpcerrors.NewMethodNotAllowedError(errors.Err("forbidden method"))
	}

	if q.ParamsAsMap() != nil {
		if _, ok := q.ParamsAsMap()[forbiddenParam]; ok {
			return nil, rpcerrors.NewInvalidParamsError(fmt.Errorf("forbidden parameter supplied: %v", forbiddenParam))
		}
	}

	if MethodAcceptsWallet(q.Method()) {
		if q.IsAuthenticated() {
			if p := q.ParamsAsMap(); p != nil {
				p[paramWalletID] = q.WalletID
				q.Request.Params = p
			} else {
				q.Request.Params = map[string]interface{}{paramWalletID: q.WalletID}
			}
		} else if MethodRequiresWallet(q.Method()) {
			return nil, rpcerrors.NewAuthRequiredError()
		}
	}

	return q, nil
}
// NewQuery initializes Query object with JSON-RPC request supplied as bytes.
// The object is immediately usable and returns an error in case request parsing fails.
// If wallet_id is not empty, it will be added as a param to the query when the Caller calls it.
NewQuery initializes Query object with JSON-RPC request supplied as bytes.
The object is immediately usable and returns an error in case request parsing fails.
If wallet_id is not empty, it will be added as a param to the query when the Caller calls it.
// NewQuery initializes Query object with JSON - RPC request supplied as bytes . // The object is immediately usable and returns an error in case request parsing fails . // If wallet_id is not empty it will be added as a param to the query when the Caller calls it .
func NewQuery(req *jsonrpc.RPCRequest, walletID string) (*Query, error) {
	if strings.TrimSpace(req.Method) == "" {
		return nil, errors.Err("no method in request")
	}
	q := &Query{Request: req, WalletID: walletID}
	if !methodInList(q.Method(), relaxedMethods) && !methodInList(q.Method(), walletSpecificMethods) {
		return nil, rpcerrors.NewMethodNotAllowedError(errors.Err("forbidden method"))
	}
	if q.ParamsAsMap() != nil {
		if _, ok := q.ParamsAsMap()[forbiddenParam]; ok {
			return nil, rpcerrors.NewInvalidParamsError(fmt.Errorf("forbidden parameter supplied: %v", forbiddenParam))
		}
	}
	if MethodAcceptsWallet(q.Method()) {
		if q.IsAuthenticated() {
			if p := q.ParamsAsMap(); p != nil {
				p[paramWalletID] = q.WalletID
				q.Request.Params = p
			} else {
				q.Request.Params = map[string]interface{}{paramWalletID: q.WalletID}
			}
		} else if MethodRequiresWallet(q.Method()) {
			return nil, rpcerrors.NewAuthRequiredError()
		}
	}
	return q, nil
}
func NewQuery ( req * jsonrpc . RPCRequest , walletID string ) ( * Query , error ) { if strings . TrimSpace ( req . Method ) == " " { return nil , errors . Err ( " " ) } q := & Query { Request : req , WalletID : walletID } if ! methodInList ( q . Method ( ) , relaxedMethods ) && ! methodInList ( q . Method ( ) , walletSpecificMethods ) { return nil , rpcerrors . NewMethodNotAllowedError ( errors . Err ( " " ) ) } if q . ParamsAsMap ( ) != nil { if _ , ok := q . ParamsAsMap ( ) [ forbiddenParam ] ; ok { return nil , rpcerrors . NewInvalidParamsError ( fmt . Errorf ( " " , forbiddenParam ) ) } } if MethodAcceptsWallet ( q . Method ( ) ) { if q . IsAuthenticated ( ) { if p := q . ParamsAsMap ( ) ; p != nil { p [ paramWalletID ] = q . WalletID q . Request . Params = p } else { q . Request . Params = map [ string ] interface { } { paramWalletID : q . WalletID } } } else if MethodRequiresWallet ( q . Method ( ) ) { return nil , rpcerrors . NewAuthRequiredError ( ) } } return q , nil }
NewQuery initializes Query object with JSON-RPC request supplied as bytes.
NewQuery initializes Query object with JSON - RPC request supplied as bytes .