public IAPIResult GetAddressTransactionCount([APIParameter("Address of account", "PDHcAHq1fZXuwDrtJGDhjemFnj2ZaFc7iu3qD4XjZG9eV")] string addressText, [APIParameter("Name or address of chain, optional", "apps")] string chainInput = "main") { if (!Address.IsValidAddress(addressText)) { return(new ErrorResult() { error = "invalid address" }); } var address = Address.FromText(addressText); var plugin = Nexus.GetPlugin <AddressTransactionsPlugin>(); if (plugin == null) { return(new ErrorResult() { error = "plugin not enabled" }); } int count = 0; if (!string.IsNullOrEmpty(chainInput)) { var chain = FindChainByInput(chainInput); if (chain == null) { return(new ErrorResult() { error = "invalid chain" }); } count = plugin.GetAddressTransactions(address).Count(tx => Nexus.FindBlockForHash(tx).ChainAddress.Equals(chain.Address)); } else { foreach (var chain in Nexus.Chains) { count += plugin.GetAddressTransactions(address).Count(tx => Nexus.FindBlockForHash(tx).ChainAddress.Equals(chain.Address)); } } return(new SingleResult() { value = count }); }