public EmailTransactionsIncrementPublisher(IEmailSender emailSender,
                                            ILogFactory logFactory,
                                            TransactionsReportWriter writer,
                                            EmailSettings settings)
 {
     _emailSender = emailSender;
     _writer      = writer;
     _settings    = settings;
     _log         = logFactory.CreateLog(this);
 }
Ejemplo n.º 2
0
 public SlackTransactionsIncrementPublisher(
     ILogFactory logFactory,
     TransactionsReportWriter writer,
     SlackSettings settings)
 {
     _log      = logFactory.CreateLog(this);
     _writer   = writer;
     _settings = settings;
     _client   = new SlackTaskClient(settings.AuthToken);
 }
Ejemplo n.º 3
0
        public BlobTransactionsIncrementPublisher(
            ILogFactory logFactory,
            AzureStorageSettings settings,
            TransactionsReportWriter writer)
        {
            _log = logFactory.CreateLog(this);

            _writer = writer;

            var azureAccount = CloudStorageAccount.Parse(settings.ReportStorageConnString);

            var blobClient = azureAccount.CreateCloudBlobClient();

            _blobContainer = blobClient.GetContainerReference("chainalysis-history-exporter");

            _blobContainer.CreateIfNotExistsAsync().GetAwaiter().GetResult();
        }
Ejemplo n.º 4
0
        private static async Task RemoveInvalidAddresses(ILogFactory logFactory)
        {
            var assetsClient       = new AssetsClient(logFactory, new AssetsClientSettings());
            var blockchainProvider = new BlockchainsProvider(assetsClient);
            var addressNormalizer  = new AddressNormalizer
                                     (
                logFactory,
                new IAddressNormalizer[]
            {
                new GeneralAddressNormalizer(),
                new BtcAddressNormalizer(blockchainProvider, new BtcSettings {
                    Network = "mainnet"
                }),
                new BchAddressNormalizer(blockchainProvider, new BchSettings {
                    Network = "mainnet"
                }),
                new LtcAddressNormalizer(blockchainProvider, new LtcSettings {
                    Network = "ltc-main"
                }),
                new EthAddressNormalizer(blockchainProvider),
                new XrpAddressNormalizer(blockchainProvider)
            }
                                     );
            var reportReader = new TransactionsReportReader(addressNormalizer);
            var reportWriter = new TransactionsReportWriter();

            Console.WriteLine("Loading...");

            var readStream           = File.Open("transactions.csv", FileMode.Open, FileAccess.Read, FileShare.Read);
            var originalTransactions = await reportReader.ReadAsync
                                       (
                readStream,
                new Progress <int>
                (
                    transactionCount =>
            {
                if (transactionCount % 1000 == 0)
                {
                    Console.WriteLine(transactionCount);
                }
            }
                ),
                leaveOpen : false
                                       );

            Console.WriteLine("Filtering...");

            var filteredTransactions = originalTransactions
                                       .Where
                                       (
                tx => !string.IsNullOrWhiteSpace(tx.Hash) &&
                !string.IsNullOrWhiteSpace(tx.CryptoCurrency) &&
                tx.UserId != Guid.Empty
                                       )
                                       .ToHashSet();

            Console.WriteLine("Saving...");

            var writeStream = File.Open
                              (
                "filtered-transactions.csv",
                FileMode.Create,
                FileAccess.Write,
                FileShare.Read
                              );
            await reportWriter.WriteAsync
            (
                filteredTransactions,
                writeStream,
                new Progress <int>
                (
                    transactionsCount =>
            {
                if (transactionsCount % 1000 == 0)
                {
                    var percent = transactionsCount * 100 / filteredTransactions.Count;

                    Console.WriteLine($"{percent}%");
                }
            }
                ),
                leaveOpen : false
            );
        }