public async Task GetTxOutSetInfo() { // Server Test UTXO utxo = new UTXO(); TxOutSetOM om = await utxo.GetTxOutSetInfo(); Assert.IsNotNull(om); }
public async Task <TxOutSetOM> GetTxOutSetInfo() { AuthenticationHeaderValue authHeaderValue = null; RpcClient client = new RpcClient(new Uri("http://localhost:5006"), authHeaderValue, null, null, "application/json"); RpcRequest request = RpcRequest.WithNoParameters("GetTxOutSetInfo", 1); RpcResponse response = await client.SendRequestAsync(request); if (response.HasError) { throw new ApiCustomException(response.Error.Code, response.Error.Message); } TxOutSetOM responseValue = response.GetResult <TxOutSetOM>(); return(responseValue); }
/// <summary> /// /// </summary> /// <returns></returns> public static async Task <ApiResponse> GetTxOutSetInfo() { ApiResponse response = new ApiResponse(); try { UTXO utxo = new UTXO(); TxOutSet set = new TxOutSet(); TxOutSetOM result = await utxo.GetTxOutSetInfo(); if (result != null) { set.BestBlock = result.BestBlock; set.Height = result.Height; set.Total_amount = result.Total_amount; set.Transactions = result.Transactions; set.Txouts = result.Txouts; response.Result = Newtonsoft.Json.Linq.JToken.FromObject(set); } else { response.Result = null; } } catch (ApiCustomException ex) { Logger.Singleton.Error(ex.ToString()); response.Error = new ApiError(ex.ErrorCode, ex.ToString()); } catch (Exception ex) { Logger.Singleton.Error(ex.ToString()); response.Error = new ApiError(ex.HResult, ex.ToString()); } return(response); }