//-------------------------------------------------------------------------------- private bool print_block_by_height(uint height) { if (height - 1 > m_core.getTopBlockIndex() != null) { Console.Write("block wasn't found. Current block chain height: "); Console.Write(m_core.getTopBlockIndex() + 1); Console.Write(", requested: "); Console.Write(height); Console.Write("\n"); return(false); } var hash = m_core.getBlockHashByIndex(height - 1); Console.Write("block_id: "); Console.Write(hash); Console.Write("\n"); GlobalMembers.print_as_json(m_core.getBlockByIndex(height - 1)); return(true); }
//-------------------------------------------------------------------------------- private bool print_tx(List <string> args) { if (args.Count == 0) { Console.Write("expected: print_tx <transaction hash>"); Console.Write("\n"); return(true); } string str_hash = args[0]; Crypto.Hash tx_hash = new Crypto.Hash(); if (!parse_hash256(str_hash, tx_hash)) { return(true); } List <Crypto.Hash> tx_ids = new List <Crypto.Hash>(); tx_ids.Add(tx_hash); List <List <ushort> > txs = new List <List <ushort> >(); List <Crypto.Hash> missed_ids = new List <Crypto.Hash>(); m_core.getTransactions(tx_ids, txs, missed_ids); if (1 == txs.Count) { CryptoNote.CachedTransaction tx = new CryptoNote.CachedTransaction(new List <List <ushort> >(txs[0])); GlobalMembers.print_as_json(tx.getTransaction()); } else { Console.Write("transaction wasn't found: <"); Console.Write(str_hash); Console.Write('>'); Console.Write("\n"); } return(true); }
//-------------------------------------------------------------------------------- private bool print_block_by_hash(string arg) { Crypto.Hash block_hash = new Crypto.Hash(); if (!parse_hash256(arg, block_hash)) { return(false); } if (m_core.hasBlock(block_hash)) { GlobalMembers.print_as_json(m_core.getBlockByHash(block_hash)); } else { Console.Write("block wasn't found: "); Console.Write(arg); Console.Write("\n"); return(false); } return(true); }