コード例 #1
0
ファイル: Program.cs プロジェクト: eoliveros/xchwallet
        static int RunShow(ShowOptions opts)
        {
            var wallet = OpenWallet(opts);

            if (wallet == null)
            {
                return(1);
            }

            /*
             * if (opts.RegisterAddrs)
             * {
             *  if (wallet is BtcWallet)
             *  {
             *      (var deposit, var change) = ((BtcWallet)wallet).ReserveAddressesInNBXplorer();
             *      Console.WriteLine($"New highest reserved deposit keypath {deposit.KeyPath} ({deposit.Address}");
             *      Console.WriteLine($"New highest reserved change keypath {change.KeyPath} ({change.Address}");
             *  }
             *  else
             *  {
             *      Console.WriteLine("Error: not BTC wallet");
             *      return 1;
             *  }
             * }
             */
            if (opts.ScanAddrs)
            {
                if (wallet is BtcWallet)
                {
                    if (!Utils.ScanBtcTxs((BtcWallet)wallet))
                    {
                        return(1);
                    }
                }
                else
                {
                    Console.WriteLine("Error: not BTC wallet");
                    return(1);
                }
            }
            if (opts.RecreateTxs)
            {
                var dbtx = Utils.RecreateBtcTxs((BtcWallet)wallet);
                if (dbtx == null)
                {
                    return(1);
                }
                dbtx.Commit();
            }
            if (opts.CheckWithBlockExplorer)
            {
                if (wallet is BtcWallet)
                {
                    if (!Utils.CheckWithBtcBlockExplorer((BtcWallet)wallet))
                    {
                        return(1);
                    }
                }
                else
                {
                    Console.WriteLine("Error: not BTC wallet");
                    return(1);
                }
            }
            if (opts.Update)
            {
                var dbtx = wallet.BeginDbTransaction();
                wallet.UpdateFromBlockchain(dbtx);
                wallet.Save();
                dbtx.Commit();
            }
            PrintWallet(wallet, opts.MinimumConfirmations, opts.MaxTxs);
            return(0);
        }