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)); } }
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 }} //}); }
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)); }
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)); }
public bool DisconnectNode(RPCConnection rpc, string ipAddress, int port) { return(GetRPCTypedResult <bool>(rpc, ZendRPCCommand.DisconnectNode, new object[] { $"{ipAddress}", port })); }
public bool AddNode(RPCConnection rpc, string ipAddress, int port, AddNodeCommand command) { return(GetRPCTypedResult <bool>(rpc, ZendRPCCommand.AddNode, new object[] { $"{ipAddress}", port, command })); }
public bool ClearBanned(RPCConnection rpc) { return(GetRPCTypedResult <bool>(rpc, ZendRPCCommand.ClearBanned, new object[0])); }
public bool Ping(RPCConnection rpc) { return(GetRPCTypedResult <bool>(rpc, ZendRPCCommand.Ping, new object[0])); }
public void ZImportViewingKey(RPCConnection rpc, string vkey, ZImportKeyRescanType rescan, int startheight = 0) { GetRPCTypedResult <object>(rpc, ZendRPCCommand.ZImportViewingKey, new object[] { vkey, $"{rescan}", startheight }); }
public GetNetTotalsResult GetNetTotals(RPCConnection rpc) { return(GetRPCTypedResult <GetNetTotalsResult>(rpc, ZendRPCCommand.GetNetTotals, new object[0])); }
public IList <PeerInfoResult> GetPeerInfo(RPCConnection rpc) { return(GetRPCTypedResult <List <PeerInfoResult> >(rpc, ZendRPCCommand.GetPeerInfo, new object[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 })); }
public IList <ZCBenchmarkResult> ZCBenchMark(RPCConnection rpc, ZCBenchmarkType benchmarktype, int samplecount = 1) { return(GetRPCTypedResult <List <ZCBenchmarkResult> >(rpc, ZendRPCCommand.ZCBenchmark, new object[] { $"{benchmarktype}", samplecount })); }
public IList <ZListReceivedByAddressResult> ZListReceivedByAddress(RPCConnection rpc, string address, int minconf = 1) { return(GetRPCTypedResult <List <ZListReceivedByAddressResult> >(rpc, ZendRPCCommand.ZListReceivedByAddress, new object[] { $"{address}", minconf })); }
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 })); }
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 })); }
public IList <string> ZListAddresses(RPCConnection rpc, bool includewatchonly) { return(GetRPCTypedResult <List <string> >(rpc, ZendRPCCommand.ZListAddresses, new object[] { includewatchonly })); }
public void ZImportWallet(RPCConnection rpc, string filename) { GetRPCTypedResult <object>(rpc, ZendRPCCommand.ZImportWallet, new object[] { $"{filename}" }); }
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 })); }
public IList <ZOperationStatusOrResult> ZGetOperationStatus(RPCConnection rpc, IEnumerable <string> opids) { return(GetRPCTypedResult <List <ZOperationStatusOrResult> >(rpc, ZendRPCCommand.ZGetOperationStatus, new object[] { opids })); }
public int GetConnectionCount(RPCConnection rpc) { return(GetRPCTypedResult <int>(rpc, ZendRPCCommand.GetConnectionCount, new object[0])); }
public string ZGetNewAddress(RPCConnection rpc) { return(GetRPCTypedResult <string>(rpc, ZendRPCCommand.ZGetNewAddress, new object[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}" })); }
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]); }
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 })); }
public ZGetTotalBalanceResult ZGetTotalBalance(RPCConnection rpc, int minconf = 1, bool includeWatchOnly = false) { return(GetRPCTypedResult <ZGetTotalBalanceResult>(rpc, ZendRPCCommand.ZGetBalance, new object[] { minconf, includeWatchOnly })); }