public async Task <Wallet> AddAsync(Wallet wallet)
        {
            if (wallet.KeyPairs.Count == 0)
            {
                _addressProvider.GenerateAddress(wallet);
            }

            using (var db = new SqliteConnection($"Data Source={DataFile}"))
            {
                await db.OpenAsync();

                using (var t = db.BeginTransaction())
                {
                    await db.ExecuteAsync("INSERT INTO Wallet (Id,PasswordHash,Secret) VALUES (@Id,@PasswordHash,@Secret)", wallet, t);

                    await SaveAddressesInTransactionAsync(wallet, db, t);

                    t.Commit();
                }
            }

            return(wallet);
        }
Example #2
0
 public string GenerateAddress(Wallet wallet)
 {
     return(_addresses.GenerateAddress(wallet));
 }