Пример #1
0
        static void Main(string[] args)
        {
            // args[0] = path to folder containing db2 directory & wallet jsons
            // args[1] = origin wallet filename
            // args[2] = destination wallet filename

            //string repoPath = Path.Combine(args[0], "db2");
            string repoPath = Path.Combine(@"C:\Users\Kevin\Downloads\Projects\TBdata\regtest17", "db2_server");
            var    network  = Network.RegTest;
            var    api      = (network != Network.RegTest ? new SmartBitApi(network) : null);
            var    repo     = new DBreezeUtils(repoPath, network);
            //var walletUtils = new WalletUtils(args[0], args[1], args[2]);
            var walletUtils = new WalletUtils(@"C:\Users\Kevin\Downloads\Projects\TBdata\regtest17", "alice.wallet.json", "bob.wallet.json");
            var textOutput  = new TextOutput(repo, api, walletUtils);

            textOutput.DumpServers();
            textOutput.DumpCycleTransactions(false);

            Console.WriteLine("=====");
            Console.WriteLine("TxToRecord transactions");
            foreach (var tx in repo.FindAllTxToRecordEntries())
            {
                Console.WriteLine("TxToRecord entry: " + tx);
                Console.WriteLine(tx.TxData.ToHex());
                Console.WriteLine("===");
            }

            Console.WriteLine("=====");
            Console.WriteLine("Broadcast transactions");
            foreach (var tx in repo.FindAllBroadcastTransactions())
            {
                Console.WriteLine(tx.TxData.ToHex());
                Console.WriteLine(tx.TxData);

                if (tx.TxId.ToString().Equals("1f8c1db597c59c367bb72e95ec88f815ffb7e923d64f6f336d806554b9e1dfe8"))
                {
                    Console.WriteLine("Break");
                }

                /*try
                 * {
                 *  var result = api.GetTransaction(tx.TxId).Result;
                 *
                 *  if (result.State == SmartBitResultState.Success)
                 *      Console.WriteLine("Broadcast found: " + tx);
                 *  else if (result.State == SmartBitResultState.Failure)
                 *  {
                 *      Console.WriteLine("Broadcast NOT found: " + tx);
                 *
                 *      Console.WriteLine(tx.TxData.ToHex());
                 *
                 *      var pushResult = api.PushTx(tx.TxData).Result;
                 *  }
                 *  else
                 *      Console.WriteLine("* Broadcast UNKNOWN status: " + tx);
                 * }
                 * catch (Exception e)
                 * {
                 *  Console.WriteLine("* Broadcast UNKNOWN status: " + tx);
                 * }*/
            }

            Console.WriteLine("=====");
            Console.WriteLine("Trusted broadcast transactions");
            foreach (var tx in repo.FindAllTrustedBroadcastTransactions())
            {
                if (tx.TxId.ToString().Equals("1f8c1db597c59c367bb72e95ec88f815ffb7e923d64f6f336d806554b9e1dfe8"))
                {
                    Console.WriteLine("Break");
                }

                /*try
                 * {
                 *  var result = api.GetTransaction(tx.TxId).Result;
                 *
                 *  if (result.State == SmartBitResultState.Success)
                 *      Console.WriteLine("Trusted Broadcast found: " + tx);
                 *  else if (result.State == SmartBitResultState.Failure)
                 *  {
                 *      Console.WriteLine("Trusted Broadcast NOT found: " + tx);
                 *
                 *      var pushResult = api.PushTx(tx.TxData).Result;
                 *  }
                 *  else
                 *      Console.WriteLine("* Trusted Broadcast UNKNOWN status: " + tx);
                 * }
                 * catch (Exception e)
                 * {
                 *  Console.WriteLine("* Trusted Broadcast UNKNOWN status: " + tx);
                 * }*/
            }

            Console.WriteLine("=====");

            foreach (var txType in Enum.GetValues(typeof(TransactionType)).Cast <TransactionType>())
            {
                var txTypeName = ((TransactionType)txType).ToString();

                foreach (var txData in repo.FindAllTransactions(txType))
                {
                    try
                    {
                        var result = api.GetTransaction(txData).Result;

                        if (result.State == SmartBitResultState.Success)
                        {
                            Console.WriteLine(txTypeName + " found: " + txData);
                        }
                        else if (result.State == SmartBitResultState.Failure)
                        {
                            Console.WriteLine(txTypeName + " NOT found: " + txData);
                        }
                        else
                        {
                            Console.WriteLine("* " + txTypeName + " UNKNOWN status: " + txData);
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("* " + txTypeName + " UNKNOWN status: " + txData);
                    }
                }
            }

            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            // args[0] = path to folder containing db2 directory & wallet jsons
            // args[1] = origin wallet filename
            // args[2] = destination wallet filename

            string repoPath    = Path.Combine(args[0], "db2");
            var    network     = Network.Main;
            var    api         = new SmartBitApi(network);
            var    repo        = new DBreezeUtils(repoPath, network);
            var    walletUtils = new WalletUtils(args[0], args[1], args[2]);
            var    textOutput  = new TextOutput(repo, api, walletUtils);

            textOutput.DumpServers();
            textOutput.DumpCycleTransactions(true);

            Console.WriteLine("=====");
            Console.WriteLine("TxToRecord transactions");
            foreach (var tx in repo.FindAllTxToRecordEntries())
            {
                Console.WriteLine("TxToRecord entry: " + tx);
            }

            Console.WriteLine("=====");
            Console.WriteLine("Broadcast transactions");
            foreach (var tx in repo.FindAllBroadcastTransactions())
            {
                try
                {
                    var result = api.GetTransaction(tx.TxId).Result;

                    if (result.State == SmartBitResultState.Success)
                    {
                        Console.WriteLine("Broadcast found: " + tx);
                    }
                    else if (result.State == SmartBitResultState.Failure)
                    {
                        Console.WriteLine("Broadcast NOT found: " + tx);

                        Console.WriteLine(tx.TxData.ToHex());

                        var pushResult = api.PushTx(tx.TxData).Result;
                    }
                    else
                    {
                        Console.WriteLine("* Broadcast UNKNOWN status: " + tx);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("* Broadcast UNKNOWN status: " + tx);
                }
            }

            Console.WriteLine("=====");
            Console.WriteLine("Trusted broadcast transactions");
            foreach (var tx in repo.FindAllTrustedBroadcastTransactions())
            {
                try
                {
                    var result = api.GetTransaction(tx.TxId).Result;

                    if (result.State == SmartBitResultState.Success)
                    {
                        Console.WriteLine("Trusted Broadcast found: " + tx);
                    }
                    else if (result.State == SmartBitResultState.Failure)
                    {
                        Console.WriteLine("Trusted Broadcast NOT found: " + tx);

                        var pushResult = api.PushTx(tx.TxData).Result;
                    }
                    else
                    {
                        Console.WriteLine("* Trusted Broadcast UNKNOWN status: " + tx);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("* Trusted Broadcast UNKNOWN status: " + tx);
                }
            }

            Console.WriteLine("=====");

            foreach (var txType in Enum.GetValues(typeof(TransactionType)).Cast <TransactionType>())
            {
                var txTypeName = ((TransactionType)txType).ToString();

                foreach (var txData in repo.FindAllTransactions(txType))
                {
                    try
                    {
                        var result = api.GetTransaction(txData).Result;

                        if (result.State == SmartBitResultState.Success)
                        {
                            Console.WriteLine(txTypeName + " found: " + txData);
                        }
                        else if (result.State == SmartBitResultState.Failure)
                        {
                            Console.WriteLine(txTypeName + " NOT found: " + txData);
                        }
                        else
                        {
                            Console.WriteLine("* " + txTypeName + " UNKNOWN status: " + txData);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("* " + txTypeName + " UNKNOWN status: " + txData);
                    }
                }
            }

            Console.ReadLine();
        }
Пример #3
0
 public TextOutput(DBreezeUtils repo, SmartBitApi api, WalletUtils walletUtils)
 {
     this.repo        = repo;
     this.api         = api;
     this.walletUtils = walletUtils;
 }