示例#1
0
        public ActionResult GetRawTansaction(string txid)
        {
            bool exists;

            if (_cache.TryGetValue(_ip, out exists))
            {
                var strIPTimeout = "{ \"error\" : \"too much requests from your IP, put sleep 1 sec between requests\" }";
                return(Content(strIPTimeout, "application/json"));;
            }
            string str = string.Empty;

            try
            {
                var tx = mainCoins.GetRawAssetTransactionMongo(txid);
                if (tx != null)
                {
                    tx.confirmations = (int)mainCoins.GetLastBlockMongo() - tx.Height + 1;
                }
                if (tx == null)
                {
                    throw new Exception();
                }
                str = JsonConvert.SerializeObject(tx);
            }
            catch
            {
                str = "{ \"error\" : \"data error\" }";
            }
            _cache.Set(_ip, true, _memoryCacheEntryOptions);
            return(Content(str, "application/json"));
        }
示例#2
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
         }));
     }
 }