Esempio n. 1
0
        public async Task TestGetTxOut()
        {
            ApiResponse response = await UtxoApi.GetTxOut("474DF906F3A53285EC40566D0BA1AFBD4828BDD3789C9599F6EA0489C4333381", 0, false);

            Assert.IsFalse(response.HasError);
            TxOutModel result = response.GetResult <TxOutModel>();

            Assert.IsNotNull(result);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="txid"></param>
        /// <param name="vout"></param>
        /// <param name="unconfirmed"></param>
        /// <returns></returns>
        public static async Task <ApiResponse> GetTxOut(string txid, int vout, bool unconfirmed)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                UTXO       utxo  = new UTXO();
                TxOutModel model = new TxOutModel();

                TxOutOM result = await utxo.GetTxOut(txid, vout, unconfirmed);

                if (result != null)
                {
                    model.BestBlock     = result.BestBlock;
                    model.CoinBase      = result.CoinBase;
                    model.Confirmations = result.Confirmations;
                    model.ScriptPubKey  = result.ScriptPubKey;
                    model.TxValue       = result.Value;
                    model.Version       = result.Version;

                    response.Result = Newtonsoft.Json.Linq.JToken.FromObject(model);
                }
                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);
        }