public T GetRPCTypedResult <T>(RPCConnection rpc, string commandName, object[] _params)
        {
            var result = rpc.RunCommand(commandName, _params);

            if (string.IsNullOrEmpty(result))
            {
                return(default(T));
            }
            if (string.IsNullOrEmpty(result))
            {
                throw new Exception("Result is null");
            }
            if (typeof(T) == typeof(string) ||
                typeof(T) == typeof(int) ||
                typeof(T) == typeof(long) ||
                typeof(T) == typeof(double) ||
                typeof(T) == typeof(bool))
            {
                return(JsonConvert.DeserializeObject <T>(JsonConvert.SerializeObject(result.Replace("\"", ""))));
            }
            else
            {
                return(JsonConvert.DeserializeObject <T>(result));
            }
        }
Beispiel #2
0
        public ZValidatePaymentDisclosureResult ZValidatePaymentDisclosure(RPCConnection rpc, string paymentDisclosure)
        {
            return(GetRPCTypedResult <ZValidatePaymentDisclosureResult>(rpc, ZendRPCCommand.ZValidatePaymentDisclosure,
                                                                        new object[] { $"{paymentDisclosure}" }));

            #endregion
        }
        public List <GetBlockResult> GetBlocks(RPCConnection rpc, List <int> heights, int verbosity)
        {
            var data = new List <RPCData>();

            heights.ForEach(a => data.Add(new RPCData(a.ToString(), ZendRPCCommand.GetBlock.GetDescription(), new object[] { $"{a}", true })));
            return(GetRPCTypedResult <List <GetBlockResult> >(rpc, data));
        }
 public GetBlockTemplateResult GetBlockTemplate(RPCConnection rpc, GetBlockTemplateInput jsonRequestObject = null)
 {
     return(GetRPCTypedResult <GetBlockTemplateResult>(rpc, ZendRPCCommand.GetBlockTemplate,
                                                       jsonRequestObject == null ? new object[0] : new object[] { jsonRequestObject }));
     //TODO: Check format (below), currently seems to return only 'proposal' as capability regardless of which way the message is sent
     //{
     //    new Dictionary<string,GetBlockTemplateInput>{{"jsonrequestobject",jsonRequestObject }}
     //});
 }
Beispiel #5
0
        public List <GetRawTransactionVerboseResult> GetRawTransactions(RPCConnection rpc, List <string> txids, bool verbose = true)
        {
            var data = new List <RPCData>();

            foreach (var txid in txids)
            {
                data.Add(new RPCData(txid, ZendRPCCommand.GetRawTransaction, new object[] { $"{txid}", 1 }));
            }
            return(GetRPCTypedResult <List <GetRawTransactionVerboseResult> >(rpc, data));
        }
Beispiel #6
0
        public T GetRPCTypedResult <T>(RPCConnection rpc, ZendRPCCommand commandName, object[] _params)
        {
            var result = rpc.RunCommand(commandName, _params);

            if (typeof(T) == typeof(string) ||
                typeof(T) == typeof(int) ||
                typeof(T) == typeof(long) ||
                typeof(T) == typeof(double) ||
                typeof(T) == typeof(bool))
            {
                return(JsonConvert.DeserializeObject <T>(JsonConvert.SerializeObject(result.Replace("\"", ""))));
            }

            return(JsonConvert.DeserializeObject <T>(result));
        }
Beispiel #7
0
 public bool DisconnectNode(RPCConnection rpc, string ipAddress, int port)
 {
     return(GetRPCTypedResult <bool>(rpc, ZendRPCCommand.DisconnectNode, new object[] { $"{ipAddress}", port }));
 }
Beispiel #8
0
 public bool AddNode(RPCConnection rpc, string ipAddress, int port, AddNodeCommand command)
 {
     return(GetRPCTypedResult <bool>(rpc, ZendRPCCommand.AddNode, new object[] { $"{ipAddress}", port, command }));
 }
Beispiel #9
0
 public bool ClearBanned(RPCConnection rpc)
 {
     return(GetRPCTypedResult <bool>(rpc, ZendRPCCommand.ClearBanned, new object[0]));
 }
Beispiel #10
0
 public bool Ping(RPCConnection rpc)
 {
     return(GetRPCTypedResult <bool>(rpc, ZendRPCCommand.Ping, new object[0]));
 }
Beispiel #11
0
 public void ZImportViewingKey(RPCConnection rpc, string vkey, ZImportKeyRescanType rescan, int startheight = 0)
 {
     GetRPCTypedResult <object>(rpc, ZendRPCCommand.ZImportViewingKey, new object[] { vkey, $"{rescan}", startheight });
 }
Beispiel #12
0
 public GetNetTotalsResult GetNetTotals(RPCConnection rpc)
 {
     return(GetRPCTypedResult <GetNetTotalsResult>(rpc, ZendRPCCommand.GetNetTotals, new object[0]));
 }
Beispiel #13
0
 public IList <PeerInfoResult> GetPeerInfo(RPCConnection rpc)
 {
     return(GetRPCTypedResult <List <PeerInfoResult> >(rpc, ZendRPCCommand.GetPeerInfo, new object[0]));
 }
Beispiel #14
0
 public ZShieldCoinbase ZShieldCoinbase(RPCConnection rpc, string fromaddress, string toaddress, double fee = 0.0001, int limit = 50)
 {
     return(GetRPCTypedResult <ZShieldCoinbase>(rpc, ZendRPCCommand.ZShieldCoinbase, new object[] { $"{fromaddress}", $"{toaddress}", fee, limit }));
 }
Beispiel #15
0
 public IList <ZCBenchmarkResult> ZCBenchMark(RPCConnection rpc, ZCBenchmarkType benchmarktype, int samplecount = 1)
 {
     return(GetRPCTypedResult <List <ZCBenchmarkResult> >(rpc, ZendRPCCommand.ZCBenchmark, new object[] { $"{benchmarktype}", samplecount }));
 }
Beispiel #16
0
 public IList <ZListReceivedByAddressResult> ZListReceivedByAddress(RPCConnection rpc, string address, int minconf = 1)
 {
     return(GetRPCTypedResult <List <ZListReceivedByAddressResult> >(rpc, ZendRPCCommand.ZListReceivedByAddress, new object[] { $"{address}", minconf }));
 }
Beispiel #17
0
 public string ZSendMany(RPCConnection rpc, string fromaddress, IList <ZSendManyAmountsInput> amounts, int minconf = 1, double fee = 0.0001)
 {
     return(GetRPCTypedResult <string>(rpc, ZendRPCCommand.ZSendMany, new object[] { $"{fromaddress}", amounts, minconf, fee }));
 }
Beispiel #18
0
        public IList <string> ZListOperationIds(RPCConnection rpc, ZListOperationIdsStatusType status)
        {
            var description = status == ZListOperationIdsStatusType.All ? "" : status.GetDescription();

            return(GetRPCTypedResult <List <string> >(rpc, ZendRPCCommand.ZListOperationIds, new object[] { description }));
        }
Beispiel #19
0
 public IList <string> ZListAddresses(RPCConnection rpc, bool includewatchonly)
 {
     return(GetRPCTypedResult <List <string> >(rpc, ZendRPCCommand.ZListAddresses, new object[] { includewatchonly }));
 }
Beispiel #20
0
 public void ZImportWallet(RPCConnection rpc, string filename)
 {
     GetRPCTypedResult <object>(rpc, ZendRPCCommand.ZImportWallet, new object[] { $"{filename}" });
 }
Beispiel #21
0
 public IList <AddedNodeResult> GetAddedNodeInfo(RPCConnection rpc, bool dns, string ipAddress = null, int?port = null)
 {
     return(GetRPCTypedResult <List <AddedNodeResult> >(rpc, ZendRPCCommand.GetAddedNodeInfo, new object[] { dns, $"{ipAddress}", port }));
 }
Beispiel #22
0
 public IList <ZOperationStatusOrResult> ZGetOperationStatus(RPCConnection rpc, IEnumerable <string> opids)
 {
     return(GetRPCTypedResult <List <ZOperationStatusOrResult> >(rpc, ZendRPCCommand.ZGetOperationStatus, new object[] { opids }));
 }
Beispiel #23
0
 public int GetConnectionCount(RPCConnection rpc)
 {
     return(GetRPCTypedResult <int>(rpc, ZendRPCCommand.GetConnectionCount, new object[0]));
 }
Beispiel #24
0
 public string ZGetNewAddress(RPCConnection rpc)
 {
     return(GetRPCTypedResult <string>(rpc, ZendRPCCommand.ZGetNewAddress, new object[0]));
 }
Beispiel #25
0
 public GetNetworkInfoResult GetNetworkInfo(RPCConnection rpc)
 {
     return(GetRPCTypedResult <GetNetworkInfoResult>(rpc, ZendRPCCommand.GetNetworkInfo, new object[0]));
 }
 public string Help(RPCConnection rpc, string command)
 {
     return(GetRPCTypedResult <string>(rpc, ZendRPCCommand.Help, new object[] { $"{command}" }));
 }
Beispiel #27
0
 public IList <BannedPeersResult> ListBanned(RPCConnection rpc)
 {
     return(GetRPCTypedResult <List <BannedPeersResult> >(rpc, ZendRPCCommand.ListBanned, new object[0]));
 }
 public void Stop(RPCConnection rpc)
 {
     GetRPCTypedResult <string>(rpc, ZendRPCCommand.Stop, new object[0]);
 }
Beispiel #29
0
 public bool SetBan(RPCConnection rpc, string ipaddress, int?netmask, SetBanCommand AddRemove, int?bantimeSeconds, bool absolute)
 {
     return(GetRPCTypedResult <bool>(rpc, ZendRPCCommand.SetBan, new object[] { ipaddress, netmask, AddRemove, bantimeSeconds, absolute }));
 }
Beispiel #30
0
 public ZGetTotalBalanceResult ZGetTotalBalance(RPCConnection rpc, int minconf = 1, bool includeWatchOnly = false)
 {
     return(GetRPCTypedResult <ZGetTotalBalanceResult>(rpc, ZendRPCCommand.ZGetBalance, new object[] { minconf, includeWatchOnly }));
 }