コード例 #1
0
        static async Task Main(string[] args)
        {
            Rlp.RegisterDecoders(typeof(DepositDecoder).Assembly);
            Rlp.RegisterDecoders(typeof(DepositDetailsDecoder).Assembly);

            string              dbPath      = args[0];
            ConsoleAsyncLogger  asyncLogger = new ConsoleAsyncLogger(LogLevel.Info);
            OneLoggerLogManager logManager  = new OneLoggerLogManager(asyncLogger);

            var deposits = await LoadDeposits(logManager, dbPath);

            IKeyStore         keyStore = BuildKeyStore(logManager);
            DevKeyStoreWallet wallet   = new DevKeyStoreWallet(keyStore, logManager, false);

            foreach (var depositGroup in deposits.Items.GroupBy(d => d.Consumer))
            {
                Console.WriteLine($"Deposits by {depositGroup.Key}");
                foreach (DepositDetails depositDetails in depositGroup)
                {
                    DateTimeOffset dto = DateTimeOffset.FromUnixTimeSeconds(depositDetails.Deposit.ExpiryTime);
                    Console.WriteLine($"  [REFUNDABLE] Deposit by {depositDetails.Consumer} for {depositDetails.DataAsset.Name} {depositDetails.Deposit.Units} expired on {dto.Date:f}");
                }

                Transaction[] refundTxs = GenerateTxsForRefunds(depositGroup, wallet);
                foreach (Transaction transaction in refundTxs)
                {
                    Console.WriteLine();
                    Console.WriteLine("***************************************");
                    TransactionDecoder decoder = new TransactionDecoder();
                    Rlp txRlp = decoder.Encode(transaction);
                    Console.WriteLine(txRlp.Bytes.ToHexString());
                    Console.WriteLine("***************************************");
                }
            }

            Console.ReadLine();
        }