BitcoinLib.Services.CoinService.GetAddressBalance C# (CSharp) Method

GetAddressBalance() public method

public GetAddressBalance ( string inWalletAddress, int minConf, bool validateAddressBeforeProcessing ) : decimal
inWalletAddress string
minConf int
validateAddressBeforeProcessing bool
return decimal
        public decimal GetAddressBalance(string inWalletAddress, int minConf, bool validateAddressBeforeProcessing)
        {
            if (validateAddressBeforeProcessing)
            {
                var validateAddressResponse = ValidateAddress(inWalletAddress);

                if (!validateAddressResponse.IsValid)
                {
                    throw new GetAddressBalanceException($"Address {inWalletAddress} is invalid!");
                }

                if (!validateAddressResponse.IsMine)
                {
                    throw new GetAddressBalanceException($"Address {inWalletAddress} is not an in-wallet address!");
                }
            }

            var listUnspentResponses = ListUnspent(minConf, 9999999, new List<string>
            {
                inWalletAddress
            });

            return listUnspentResponses.Any() ? listUnspentResponses.Sum(x => x.Amount) : 0;
        }