Beispiel #1
0
        public async Task GetListUnspentInfo()
        {
            UTXO             utxo = new UTXO();
            List <UnspentOM> list = await utxo.ListUnspent(2, 99999, null);

            Assert.IsNotNull(list);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="minConfirmations"></param>
        /// <param name="maxConfirmations"></param>
        /// <param name="addresses"></param>
        /// <returns></returns>
        public static async Task <ApiResponse> ListUnspent(int minConfirmations, int maxConfirmations = 9999, string[] addresses = null)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                UTXO utxo = new UTXO();
                List <UnspentUtxo> unspentList = new List <UnspentUtxo>();

                List <UnspentOM> result = await utxo.ListUnspent(minConfirmations, maxConfirmations, addresses);

                if (result != null)
                {
                    foreach (var item in result)
                    {
                        UnspentUtxo unspent = new UnspentUtxo();
                        unspent.Account       = item.Account;
                        unspent.Address       = item.Address;
                        unspent.Amount        = item.Amount;
                        unspent.Confirmations = item.Confirmations;
                        unspent.RedeemScript  = item.RedeemScript;
                        unspent.ScriptPubKey  = item.ScriptPubKey;
                        unspent.Solvable      = item.Solvable;
                        unspent.Spendable     = item.Spendable;
                        unspent.TXID          = item.TXID;
                        unspent.Vout          = item.Vout;
                        unspentList.Add(unspent);
                    }

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