コード例 #1
0
ファイル: Program.cs プロジェクト: salvation-al/marvin
        static void DisplayBalance()
        {
            var keyStorePath = string.Empty;

            while (string.IsNullOrWhiteSpace(keyStorePath))
            {
                Console.WriteLine("Enter location to save Keystore file");
                Console.WriteLine("--eg: F:/temp/keystore.icx");
                keyStorePath = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(keyStorePath))
                {
                    Console.WriteLine("File path cannot be blank please try again");
                }
            }

            if (File.Exists(keyStorePath))
            {
                // This path is a file
                Console.WriteLine("Enter password for your Keystore...");
                var keyStorePassword = Console.ReadLine();
                try
                {
                    Console.WriteLine("Checking balance please wait...");
                    var wallet  = IconSDK.Account.Wallet.Load(keyStorePassword, keyStorePath);
                    var balance = wallet.GetBalance().Result;
                    Console.WriteLine($"Your current ICX balance is : {NumericHelper.Loop2ICX(balance.ToString())} ICX");
                }
                catch (Exception e)
                {
                    Console.WriteLine("Unable to open Keystore, did you type the correct password?");
                    DisplayBalance();
                }
            }
            else
            {
                Console.WriteLine("Marvin couldn't find a keystore file at that location, please try again.");
                DisplayBalance();
            }
        }