示例#1
0
        public async Task GetTxOut()
        {
            UTXO    utxo = new UTXO();
            TxOutOM tx   = await utxo.GetTxOut("474DF906F3A53285EC40566D0BA1AFBD4828BDD3789C9599F6EA0489C4333381", 0, false);

            Assert.IsNotNull(tx);
        }
示例#2
0
文件: UtxoApi.cs 项目: omcdev/wallet
        /// <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);
        }