Exemplo n.º 1
0
        private static NxtAccount ParseAccount(SqliteDataReader reader)
        {
            var account = new NxtAccount
            {
                Id           = (long)reader["id"],
                BalanceNqt   = (long)reader["balance_nqt"],
                SecretPhrase = reader["secret_phrase"].ToString(),
                Address      = reader["address"].ToString()
            };

            return(account);
        }
Exemplo n.º 2
0
        public async Task AddAccount(NxtAccount account)
        {
            using (var dbConnection = OpenNewDbConnection())
            {
                var sql = $"INSERT INTO account (secret_phrase, address, balance_nqt) VALUES ('{account.SecretPhrase}', '{account.Address}', {account.BalanceNqt})";
                using (var command = new SqliteCommand(sql, dbConnection))
                {
                    await command.ExecuteNonQueryAsync();
                }

                using (var command = new SqliteCommand("SELECT last_insert_rowid()", dbConnection))
                {
                    account.Id = (long)await command.ExecuteScalarAsync();
                }
            }
        }
Exemplo n.º 3
0
        public async Task <NxtAccount> AddAccount()
        {
            var localPasswordGenerator = new LocalPasswordGenerator();
            var localAccountService    = new LocalAccountService();

            var secretPhrase         = localPasswordGenerator.GeneratePassword();
            var accountWithPublicKey = localAccountService.GetAccount(AccountIdLocator.BySecretPhrase(secretPhrase));

            var account = new NxtAccount
            {
                Address      = accountWithPublicKey.AccountRs,
                SecretPhrase = secretPhrase,
                BalanceNqt   = 0
            };

            await wallet.AddAccount(account);

            return(account);
        }