Ejemplo n.º 1
0
        public async Task GeneratorTransaction()
        {
            var cancelTokenSource = new CancellationTokenSource();
            var ct = cancelTokenSource.Token;

            var rnd = new Random();

            using (var context = new BitcoindDbContext(DbContextOptions))
            {
                for (var i = 1; i < 1000; i++)
                {
                    var bitcoin        = new Key();
                    var bitcoinaddress = bitcoin.PubKey.GetAddress(Network.TestNet);
                    var amount         = rnd.Next(1, i);
                    var confirmation   = (byte)rnd.Next(0, 4);

                    var transaction = new TransactionEntity
                    {
                        Address        = bitcoinaddress.ToString(),
                        Amount         = amount,
                        IdempotencyKey = Guid.NewGuid(),
                        Data           = DateTime.UtcNow,
                        Confirmation   = confirmation
                    };

                    await context
                    .Transactions
                    .AddAsync(transaction, ct);
                }

                await context
                .SaveChangesAsync(ct);
            }
        }
Ejemplo n.º 2
0
 public WalletHelper(
     BitcoindDbContext context
     )
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }