コード例 #1
0
        /// <summary>
        /// This function require already splitted command and parameters
        /// This is for the case that some of the parameters must contain ',' which is used as separator
        /// </summary>
        /// <param name="command">RPC command name</param>
        /// <param name="parameters">string array of parameters</param>
        /// <returns></returns>
        public async Task <string> RPCLocalCommandSplitedAsync(string command, string[] parameters)
        {
            if (parameters != null)
            {
                foreach (var par in parameters)
                {
                    par.TrimStart().TrimEnd();
                }
            }
            else
            {
                return("ERROR - RPC Params cannot be empty");
            }

            if (!ClientInitialized)
            {
                InitClients();
            }

            if (!ClientInitialized)
            {
                throw new Exception("Cannot init RPC communication clients.");
            }

            var res = await QTWalletRPC.ProcessRequest(Guid.NewGuid().ToString(), command, parameters, jsonClient);

            //Console.WriteLine($"result of request: {res}");

            return(res);
        }
コード例 #2
0
        /// <summary>
        /// Function for call of RPC command. Parameters is string splitted with ','
        /// First is command, then goes the parameters. If parameters must cointain ',' please use function RPCLocalCommandSplitedAsync
        /// </summary>
        /// <param name="param">First is command, then goes the parameters.</param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public async Task <string> RPCLocalCommandAsync(string param, object obj)
        {
            var split = param.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (split.Length < 1)
            {
                throw new Exception("Not enought parameters: please input as minimum RPC command name!");
            }

            //var addr = "NPWBL3i8ZQ8tmhDtrixXwYd93nofmunvhA";
            var command = split[0].TrimStart().TrimEnd();

            string[] parameters = new string[split.Length - 1];

            for (int i = 0; i < split.Length - 1; i++)
            {
                parameters[i] = split[i + 1].TrimStart().TrimEnd();
            }

            if (!ClientInitialized)
            {
                InitClients();
            }

            if (!ClientInitialized)
            {
                throw new Exception("Cannot init RPC communication clients.");
            }

            var res = await QTWalletRPC.ProcessRequest(Guid.NewGuid().ToString(), command, parameters, jsonClient);

            //Console.WriteLine($"result of request: {res}");

            return(res);
        }