// Note: This current implementation requires NeoScan running at port 4000 public override Dictionary <string, List <UnspentEntry> > GetUnspent(UInt160 hash) { var url = this.neoscanUrl + "/api/main_net/v1/get_balance/" + hash.ToAddress(); var json = RequestUtils.GetWebRequest(url); var root = LunarLabs.Parser.JSON.JSONReader.ReadFromString(json); var unspents = new Dictionary <string, List <UnspentEntry> >(); root = root["balance"]; foreach (var child in root.Children) { var symbol = child.GetString("asset"); List <UnspentEntry> list = new List <UnspentEntry>(); unspents[symbol] = list; var unspentNode = child.GetNode("unspent"); foreach (var entry in unspentNode.Children) { var txid = entry.GetString("txid"); var val = entry.GetDecimal("value"); var temp = new UnspentEntry() { hash = new UInt256(LuxUtils.ReverseHex(txid).HexToBytes()), value = val, index = entry.GetUInt32("n") }; list.Add(temp); } } return(unspents); }
// Note: This current implementation requires NeoScan running at port 4000 public IEnumerator GetUnspent(UInt160 hash, Action <UnspentEntries> callback) { var url = this.neoscanUrl + "/api/main_net/v1/get_balance/" + hash.ToAddress(); return(ExecuteRequestWeb( (response) => { var unspents = new Dictionary <string, List <UnspentEntry> >(); response = response["balance"]; foreach (var child in response.Children) { var symbol = child.GetString("asset"); List <UnspentEntry> list = new List <UnspentEntry>(); unspents[symbol] = list; var unspentNode = child.GetNode("unspent"); foreach (var entry in unspentNode.Children) { var txid = entry.GetString("txid"); var val = entry.GetDecimal("value"); var temp = new UnspentEntry() { hash = new UInt256(NeoUtils.ReverseHex(txid).HexToBytes()), value = val, index = entry.GetUInt32("n") }; list.Add(temp); } } var result = new UnspentEntries() { entries = unspents }; callback(result); }, ErrorHandler, url)); }