Пример #1
0
        public void LoadAccountFromPrivateKey()
        {
            Ensure.ArgumentNotNull(this.PrivateKey, "Private Key");
            var account = new Account(PrivateKey);

            accountsService.AddAccount(account);
        }
        public void LoadPrivateKey()
        {
            if (String.IsNullOrEmpty(Password))
            {
                throw new NullReferenceException("Password cannot be null or empty");
            }
            if (String.IsNullOrEmpty(FileName))
            {
                throw new NullReferenceException("File name cannot be null or empty");
            }
            if (!File.Exists(FileName))
            {
                throw new Exception("File cannot be found");
            }
            using (var file = System.IO.File.OpenText(FileName))
            {
                var json = file.ReadToEnd();
                //create a new Nethereum key store service
                var service = new KeyStoreService();
                //decrypt the json using the password and get the private key
                var privateKey = service.DecryptKeyStoreFromJson(Password, json).ToHex();

                var account = new Account(privateKey);
                accountsService.AddAccount(account);
            }
        }
        public AccountsServiceTests()
        {
            _web3 = new Mock <IWeb3>();
            _webProviderService = new Mock <IWeb3ProviderService>();
            _webProviderService
            .Setup(s => s.GetWeb3(It.IsAny <Account>()))
            .Returns <IWeb3>(s => _web3.Object);
            _webProviderService
            .Setup(s => s.GetWeb3())
            .Returns(_web3.Object);
            _accountsService = new AccountsService(_webProviderService.Object);

            _accountsService.AddAccount(_testPrivateKey);
        }