Exemplo n.º 1
0
        public async Task GetTxOutSetInfo()
        {
            // Server Test
            UTXO       utxo = new UTXO();
            TxOutSetOM om   = await utxo.GetTxOutSetInfo();

            Assert.IsNotNull(om);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        /// <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);
        }