public List <ClientBlock> GetLastXTransactions(uint block, uint amount = 10) { List <ClientBlock> blocks = new List <ClientBlock>(); for (uint i = amount; i > 0; i--) { var dx = CoinService.GetBlockHash(block--); var rx = CoinService.GetBlock(dx); var blk = new ClientBlock() { Bits = rx.Bits, ChainWork = rx.ChainWork, Confirmations = rx.Confirmations, Difficulty = rx.Difficulty, Hash = rx.Hash, Height = rx.Height, MerkleRoot = rx.MerkleRoot, NextBlockHash = rx.NextBlockHash, Nonce = rx.Nonce, PreviousBlockHash = rx.PreviousBlockHash, Size = rx.Size, Time = rx.Time, Tx = rx.Tx, Version = rx.Version, BlockTime = UnixTimeStampToDateTime(rx.Time), Flags = rx.Flags, Additional = rx.Additional }; blocks.Add(blk); } return(blocks); }
public ClientBlock GetAssetBlockByIdMongo(uint block) { var coin_block = _dtoMain.db.GetCollection <MongoBlock>(_dtoMain.mainModel.CoinID + "_asset_block"); var rx = coin_block.Find(l => l.Height == block).FirstOrDefault(); if (rx == null) { return(null); } var blk = new ClientBlock() { Bits = rx.Bits, ChainWork = rx.ChainWork, Confirmations = rx.Confirmations, Difficulty = rx.Difficulty, Hash = rx.Hash, Height = rx.Height, MerkleRoot = rx.MerkleRoot, NextBlockHash = rx.NextBlockHash, Nonce = rx.Nonce, PreviousBlockHash = rx.PreviousBlockHash, Size = rx.Size, Time = rx.Time, Tx = rx.Tx, Version = rx.Version, BlockTime = UnixTimeStampToDateTime(rx.Time), Flags = rx.Flags, Additional = rx.Additional, AssetTX = rx.AssetTX, TxCount = rx.TxCount }; return(blk); }
public ClientBlock GetBlockByHashMongo(string blockhash) { var rx = GetAssetBlockMongo(blockhash); var blk = new ClientBlock() { Bits = rx.Bits, ChainWork = rx.ChainWork, Confirmations = rx.Confirmations, Difficulty = rx.Difficulty, Hash = rx.Hash, Height = rx.Height, MerkleRoot = rx.MerkleRoot, NextBlockHash = rx.NextBlockHash, Nonce = rx.Nonce, PreviousBlockHash = rx.PreviousBlockHash, Size = rx.Size, Time = rx.Time, Tx = rx.Tx, Version = rx.Version, BlockTime = UnixTimeStampToDateTime(rx.Time), Flags = rx.Flags, Additional = rx.Additional, AssetTX = rx.AssetTX }; return(blk); }
public List <ClientBlock> GetlastXAssetBlocks(int number) { var coin_block = _dtoMain.db.GetCollection <MongoBlock>(_dtoMain.mainModel.CoinID + "_asset_block"); var sort = new BsonDocument { { "_id", -1 }, }; var list = new List <ClientBlock>(); var rxList = coin_block.Find(_ => true).Sort(sort).Project <ClientBlockLight>("{_id: 1, Confirmations:1, Difficulty: 1, Hash: 1, Height: 1," + "Time: 1, Flags: 1, Additional: 1}").Limit(number).ToList(); if (rxList == null || rxList.Count == 0) { return(list); } foreach (var rx in rxList) { var blk = new ClientBlock() { Confirmations = rx.Confirmations, Difficulty = rx.Difficulty, Hash = rx.Hash, Height = rx.Height, Time = rx.Time, TxCount = rx.Additional != null && rx.Additional.ContainsKey("oto_assettxcount") ? Convert.ToInt32(rx.Additional["oto_assettxcount"]) : -1, BlockTime = UnixTimeStampToDateTime(rx.Time), Flags = rx.Flags, Additional = rx.Additional }; list.Add(blk); } return(list); }
public ClientBlock GetOrphanBlockMongo(string block) { var coin_block_orphan = _dtoMain.db.GetCollection <MongoBlock>(_dtoMain.mainModel.CoinID + "_block_orphan"); var rx = coin_block_orphan.Find(l => l.HashLower == block.ToLower()).FirstOrDefault(); if (rx == null) { return(null); } var blk = new ClientBlock() { Bits = rx.Bits, ChainWork = rx.ChainWork, Confirmations = rx.Confirmations, Difficulty = rx.Difficulty, Hash = rx.Hash, Height = rx.Height, MerkleRoot = rx.MerkleRoot, NextBlockHash = rx.NextBlockHash, Nonce = rx.Nonce, PreviousBlockHash = rx.PreviousBlockHash, Size = rx.Size, Time = rx.Time, Tx = rx.Tx, Version = rx.Version, BlockTime = UnixTimeStampToDateTime(rx.Time), Flags = rx.Flags, Additional = rx.Additional }; return(blk); }
public decimal GetBlockRewardPosMongo(ClientBlock block) { var t = GetRawTransactionMongo(block.Tx[1]); Decimal inAmount = 0; Decimal outAmount = 0; if (t.Vin != null) { for (int y = 0; y < t.Vin.Count; y++) { if (t.Vin[y].TxId == "0000000000000000000000000000000000000000000000000000000000000000" && t.Vin.Count == 1) { return(-1); } else { var ta = GetRawTransactionMongo(t.Vin[y].TxId); var xx = ta.Vout[Convert.ToInt32(t.Vin[y].Vout)]; inAmount += xx.Value; } } } if (t.Vout != null) { for (int y = 0; y < t.Vout.Count; y++) { outAmount += t.Vout[y].Value; } } return(outAmount - inAmount); }
public decimal GetBlockRewardMongo(ClientBlock block) { for (int i = 0; i < block.Tx.Count; i++) { var t = GetRawTransactionMongo(block.Tx[0]); if (string.IsNullOrEmpty(t.Vin[0].TxId)) { Decimal dc = 0; for (int y = 0; y < t.Vout.Count; y++) { dc += t.Vout[y].Value; } return(dc); } } return(0); }
public decimal GetBlockRewardPow(ClientBlock block) { for (int i = 0; i < block.Tx.Count; i++) { var t = CoinService.GetPublicTransaction(block.Tx[0]); if (t.Vin[0].TxId == null) { Decimal dc = 0; for (int y = 0; y < t.Vout.Count; y++) { dc += t.Vout[y].Value; } return(dc); } } return(0); }