コード例 #1
0
        public static async Task <Dictionary <string, List <UTXO> > > GetUTXOByAddress(string address)
        {
            Dictionary <string, List <UTXO> > dir = new Dictionary <string, List <UTXO> >();
            var path = "C:\\Users\\tlan\\NEO\\dumpdata";

            foreach (string filePath in Directory.GetFiles(path + "/utxo"))
            {
                if (filePath.Contains(address))
                {
                    JObject jObject = JObject.Parse(File.ReadAllText(filePath));

                    UTXO utxo = new UTXO(jObject["addr"].ToString(),
                                         new ThinNeo.Hash256(jObject["txid"].ToString()),
                                         jObject["asset"].ToString(),
                                         decimal.Parse(jObject["value"].ToString()),
                                         int.Parse(jObject["n"].ToString()));
                    if (dir.ContainsKey(jObject["asset"].ToString()))
                    {
                        if (jObject["used"].ToString() == "0")
                        {
                            dir[jObject["asset"].ToString()].Add(utxo);
                        }
                    }
                    else
                    {
                        List <UTXO> l = new List <UTXO>();
                        l.Add(utxo);
                        dir[jObject["asset"].ToString()] = l;
                    }
                }
            }
            return(dir);
        }
コード例 #2
0
        public static async Task <Dictionary <string, List <UTXO> > > GetUTXOByAddress(string api, string _addr)
        {
            MyJson.JsonNode_Object            response = (MyJson.JsonNode_Object)MyJson.Parse(await HttpHelper.HttpGet(api + "?method=getutxo&id=1&params=['" + _addr + "']"));
            MyJson.JsonNode_Array             resJA    = (MyJson.JsonNode_Array)response["result"];
            Dictionary <string, List <UTXO> > _dir     = new Dictionary <string, List <UTXO> >();

            foreach (MyJson.JsonNode_Object j in resJA)
            {
                UTXO utxo = new UTXO(j["addr"].ToString(), new ThinNeo.Hash256(j["txid"].ToString()), j["asset"].ToString(), decimal.Parse(j["value"].ToString()), int.Parse(j["n"].ToString()));
                if (_dir.ContainsKey(j["asset"].ToString()))
                {
                    _dir[j["asset"].ToString()].Add(utxo);
                }
                else
                {
                    List <UTXO> l = new List <UTXO>();
                    l.Add(utxo);
                    _dir[j["asset"].ToString()] = l;
                }
            }
            return(_dir);
        }