示例#1
0
 public ExchangeController(IConfiguration Configuration, MainCoins mc, ILogger <HomeController> logger,
                           Exchange ex)
 {
     exchange      = ex;
     configuration = Configuration;
     mainCoins     = mc;
     _logger       = logger;
 }
示例#2
0
 public HomeController(IConfiguration Configuration, MainCoins mc,
                       IMemoryCache memoryCache, IHttpContextAccessor accessor, IStringLocalizer <SharedResources> localizer,
                       Exchange ex)
 {
     exchange                 = ex;
     _localizer               = localizer;
     _accessor                = accessor;
     _cache                   = memoryCache;
     _configuration           = Configuration;
     mainCoins                = mc;
     _memoryCacheEntryOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromSeconds(10));
 }
示例#3
0
 public ClaimController(IConfiguration Configuration, MainCoins mc, ILogger <HomeController> logger,
                        IMemoryCache memoryCache, IHttpContextAccessor accessor,
                        Exchange ex)
 {
     exchange                 = ex;
     _accessor                = accessor;
     _cache                   = memoryCache;
     configuration            = Configuration;
     mainCoins                = mc;
     _logger                  = logger;
     _ip                      = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();
     _memoryCacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(1));
 }
示例#4
0
 public IActionResult Transaction(String transaction)
 {
     try
     {
         var lastBlockMongo = mainCoins.GetLastBlockMongo();
         var tx             = mainCoins.GetRawAssetTransactionMongo(transaction);
         if (tx == null)
         {
             var lastBlockWallet = mainCoins.GetLastBlock();
             try
             {
                 var unconfirmedTx = mainCoins.GetRawTransactionAsset(transaction);
                 if (unconfirmedTx != null)
                 {
                     return(View("~/Views/Home/TransactionUnindexed.cshtml"));
                 }
             }
             catch
             {
             }
             var unconfirmedTxRaw = mainCoins.GetRawTransaction(transaction);
             if (unconfirmedTxRaw != null)
             {
                 return(View("~/Views/Home/TransactionUnindexed.cshtml"));
             }
             throw new Exception("Transaction not found");
         }
         var blk  = mainCoins.GetAssetBlockMongo(tx.blockhash);
         var trVM = new TransactionViewModel
         {
             Trx         = tx.txid,
             Transaction = new ClientTransaction()
             {
                 Amount              = decimal.Parse(tx.amount, CultureInfo.InvariantCulture),
                 block               = tx.block,
                 amount              = tx.amount,
                 blockhash           = tx.blockhash,
                 blocktime           = tx.blocktime,
                 confirmations       = tx.confirmations,
                 BlockDateTime       = MainCoins.UnixTimeStampToDateTime(tx.blocktime),
                 ConfirmationsClient = (int)lastBlockMongo - blk.Height + 1,
                 divisible           = tx.divisible,
                 ecosystem           = tx.ecosystem,
                 fee              = tx.fee,
                 ismine           = tx.ismine,
                 positioninblock  = tx.positioninblock,
                 propertyid       = tx.propertyid,
                 referenceaddress = tx.referenceaddress,
                 sendingaddress   = tx.sendingaddress,
                 txid             = tx.txid,
                 type             = tx.type,
                 type_int         = tx.type_int,
                 valid            = tx.valid,
                 version          = tx.version
             },
             MainCoinModel = mainCoins.GetCoin(),
             IsConfirmed   = true
         };
         return(View(trVM));
     }
     catch
     {
         return(View("~/Views/Shared/Error.cshtml", new ErrorViewModel {
             RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
         }));
     }
 }
示例#5
0
        public IActionResult Block(string block, int?pagenum = null)
        {
            try
            {
                uint        blockHeight;
                string      blockHash = block;
                ClientBlock blk;

                var lastBlockMongo = mainCoins.GetLastBlockMongo();
                if (uint.TryParse(block, out blockHeight))
                {
                    blk = mainCoins.GetAssetBlockByIdMongo(blockHeight);
                }
                else
                {
                    blk = mainCoins.GetAssetBlockMongo(blockHash);
                }
                if (blk == null)
                {
                    var lastBlockWallet = mainCoins.GetLastBlock();
                    if (blockHeight != 0)
                    {
                        blockHash = mainCoins.GetBlockHashByHeight(blockHeight);
                    }
                    var blkUnconfirmed = mainCoins.GetBlockByHash(blockHash);
                    if (blkUnconfirmed != null && lastBlockMongo > blockHeight)
                    {
                        return(View("~/Views/Home/BlockUnindexed.cshtml"));
                    }
                    if (blkUnconfirmed != null)
                    {
                        return(View("~/Views/Home/BlockUnconfirmed.cshtml"));
                    }
                }
                blk.ConfirmationsClient = (int)lastBlockMongo - blk.Height + 1;
                List <ClientTransaction> trlist = new List <ClientTransaction>();
                var pagenr = 1;
                if (pagenum != null)
                {
                    pagenr = pagenum.Value;
                }
                var zPage = pagenr - 1;
                if (zPage < 0)
                {
                    zPage  = 0;
                    pagenr = 1;
                }
                var start   = (pagenr - 1) * ON_PAGE;
                var txs     = mainCoins.GetRawAssetTransactionMongoList(blk.Height);
                var count   = blk.Tx.Count;
                var maxPage = count / ON_PAGE + 1;
                if (zPage >= maxPage)
                {
                    zPage  = 0;
                    pagenr = 1;
                }
                blk.BTCFee  = 0.0m;
                blk.OMNIFee = 0.0m;
                blk.TxCount = blk.Additional != null && blk.Additional.ContainsKey(mainCoins.GetCoin().CoinID + "_assettxcount") ? Convert.ToInt32(blk.Additional[mainCoins.GetCoin().CoinID + "_assettxcount"]) : 0;
                foreach (var tx in txs)
                {
                    var transaction = new ClientTransaction()
                    {
                        Amount              = decimal.Parse(tx.amount, CultureInfo.InvariantCulture),
                        block               = tx.block,
                        amount              = tx.amount,
                        blockhash           = tx.blockhash,
                        blocktime           = tx.blocktime,
                        confirmations       = tx.confirmations,
                        BlockDateTime       = MainCoins.UnixTimeStampToDateTime(tx.blocktime),
                        ConfirmationsClient = (int)lastBlockMongo - blk.Height + 1,
                        divisible           = tx.divisible,
                        ecosystem           = tx.ecosystem,
                        fee              = tx.fee,
                        ismine           = tx.ismine,
                        positioninblock  = tx.positioninblock,
                        propertyid       = tx.propertyid,
                        referenceaddress = tx.referenceaddress,
                        sendingaddress   = tx.sendingaddress,
                        txid             = tx.txid,
                        type             = tx.type,
                        type_int         = tx.type_int,
                        valid            = tx.valid,
                        version          = tx.version
                    };
                    blk.BTCFee          += decimal.Parse(tx.fee, CultureInfo.InvariantCulture);
                    blk.TotalTransfered += transaction.Amount;
                    trlist.Add(transaction);
                }
                return(View(new BlockViewModel
                {
                    Block = blk,
                    ListTransactions = trlist,
                    MainCoinModel = mainCoins.GetCoin(),
                    IsConfirmed = true,
                    Pageing = new Pageing()
                    {
                        MaxCount = count,
                        OnPage = ON_PAGE,
                        Pagenum = pagenr
                    }
                }));
            }
            catch
            {
                return(View("~/Views/Shared/Error.cshtml", new ErrorViewModel {
                    RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                }));
            }
        }
示例#6
0
 public RichController(IConfiguration Configuration, MainCoins mc)
 {
     _configuration = Configuration;
     mainCoins      = mc;
 }
示例#7
0
 public ViewFooterAttribute(MainCoins mc, IMemoryCache memoryCache)
 {
     _mc    = mc ?? throw new ArgumentNullException(nameof(mc));
     _cache = memoryCache;
     _memoryCacheEntryOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(24));
 }