static async Task getAddress(string address) { Blockdata blockdata = null; // clear out the variable objects before populating them. HttpResponseMessage response = await client.GetAsync(client.BaseAddress + "api/addr/" + address); Console.WriteLine(response); if (response.IsSuccessStatusCode) { blockdata = await response.Content.ReadAsAsync <Blockdata>(); Console.WriteLine("Balance is:" + blockdata.Balance); Console.WriteLine("Address is:" + blockdata.AddrStr); Console.WriteLine("BalanceSat is:" + blockdata.BalanceSat); Console.WriteLine("TotalReceived is:" + blockdata.TotalReceived); Console.WriteLine("TotalReceivedSat is:" + blockdata.TotalReceivedSat); Console.WriteLine("TotalSent is:" + blockdata.TotalSent); Console.WriteLine("TotalSentSat is:" + blockdata.TotalSentSat); Console.WriteLine("UnconfirmedBalance is:" + blockdata.UnconfirmedBalance); Console.WriteLine("UnconfirmedBalanceSat is:" + blockdata.UnconfirmedBalanceSat); Console.WriteLine("UnconfirmedTxAppearances is:" + blockdata.UnconfirmedTxApperances); Console.WriteLine("TxAppearances is:" + blockdata.TxApperances); int instance = 0; foreach (string n in blockdata.Transactions) { instance++; Console.WriteLine("Txid is:" + blockdata.Transactions[instance - 1]); } } }
static async Task getBlock(string blockhash) { Blockdata blockdata = null; // clear out the variable objects before populating them. HttpResponseMessage response = await client.GetAsync(client.BaseAddress + "api/block/" + blockhash); Console.WriteLine(response); if (response.IsSuccessStatusCode) { blockdata = await response.Content.ReadAsAsync <Blockdata>(); Console.WriteLine("Hash is:" + blockdata.Hash); Console.WriteLine("Size is:" + blockdata.Size); Console.WriteLine("Height is:" + blockdata.Height); Console.WriteLine("Version is:" + blockdata.Version); Console.WriteLine("Merkleroot is:" + blockdata.Merkleroot); Console.WriteLine("Tx is:" + blockdata.Tx[0]); Console.WriteLine("Nonce is:" + blockdata.Nonce); Console.WriteLine("Solution is:" + blockdata.Solution); Console.WriteLine("Bits is:" + blockdata.Bits); Console.WriteLine("Difficulty is:" + blockdata.Difficulty); Console.WriteLine("Chainwork is:" + blockdata.Chainwork); Console.WriteLine("Confirmations is:" + blockdata.Confirmations); Console.WriteLine("PreviousBlockHash is:" + blockdata.PreviousBlockHash); Console.WriteLine("NextBlockHash is:" + blockdata.NextBlockHash); Console.WriteLine("Reward is:" + blockdata.Reward); Console.WriteLine("IsMainChain is:" + blockdata.IsMainChain); //Console.WriteLine("PoolInfo is:" + blockdata.PoolInfo); } }
static async Task getBlockIndex(string blockindex) { Blockdata blockdata = null; // clear out the variable objects before populating them. HttpResponseMessage response = await client.GetAsync(client.BaseAddress + "api/block-index/" + blockindex); Console.WriteLine(response); if (response.IsSuccessStatusCode) { blockdata = await response.Content.ReadAsAsync <Blockdata>(); Console.WriteLine("Hash is:" + blockdata.BlockHash); } }
static async Task getTransaction(string txid) { Blockdata blockdata = null; // clear out the variable objects before populating them. HttpResponseMessage response = await client.GetAsync(client.BaseAddress + "api/tx/" + txid); Console.WriteLine(response); if (response.IsSuccessStatusCode) { blockdata = await response.Content.ReadAsAsync <Blockdata>(); Console.WriteLine("Txid is:" + blockdata.Txid); Console.WriteLine("Version is:" + blockdata.Version); Console.WriteLine("LockTime is:" + blockdata.LockTime); /* Nested data - Work in progress * Console.WriteLine("Vin is:" + blockdata.Vin[0]); * Console.WriteLine("Coinbase is:" + blockdata.Coinbase); * Console.WriteLine("Sequence is:" + blockdata.Sequence); * Console.WriteLine("N is:" + blockdata.N); * Console.WriteLine("Vout is:" + blockdata.Vout); * Console.WriteLine("Value is:" + blockdata.Value); * Console.WriteLine("Hex is:" + blockdata.Hex); * Console.WriteLine("Asm is:" + blockdata.Asm); * Console.WriteLine("Addresses is:" + blockdata.Addresses); * Console.WriteLine("Type is:" + blockdata.Type); * Console.WriteLine("SpentTxId is:" + blockdata.SpentTxId); * Console.WriteLine("SpentIndex is:" + blockdata.SpentIndex); * Console.WriteLine("SpentHeight is:" + blockdata.SpentHeight); */ Console.WriteLine("BlockHash" + blockdata.BlockHash); Console.WriteLine("BlockHeight is:" + blockdata.BlockHeight); Console.WriteLine("Confirmations is:" + blockdata.Confirmations); Console.WriteLine("Time is:" + blockdata.Time); Console.WriteLine("BlockTime is:" + blockdata.BlockTime); Console.WriteLine("IsCoinBase is:" + blockdata.IsCoinBase); Console.WriteLine("ValueOut is:" + blockdata.ValueOut); Console.WriteLine("Size is:" + blockdata.Size); } }