public async Task <GetAddressInfoResponse> GetAddressInfoAsync(IDestination address) { var addrString = address.ScriptPubKey.GetDestinationAddress(Network).ToString(); var response = await SendCommandAsync(RPCOperations.getaddressinfo, addrString); return(GetAddressInfoResponse.FromJsonResponse((JObject)response.Result, Network)); }
public static GetAddressInfoResponse FromJsonResponse(JObject raw, Network network) { var result = new GetAddressInfoResponse(); SetSubInfo(result, raw, network); result.IsMine = raw.Property("ismine").Value.Value <bool>(); result.Solvable = raw.Property("solvable")?.Value.Value <bool>(); result.Desc = raw.Property("desc") == null ? null : new ScanTxoutDescriptor(raw.Property("desc").Value.Value <string>()); result.IsWatchOnly = raw.Property("iswatchonly").Value.Value <bool>(); result.IsScript = raw.Property("isscript").Value.Value <bool>(); result.IsWitness = raw.Property("iswitness").Value.Value <bool>(); result.Script = raw.Property("script")?.Value.Value <string>(); result.Hex = raw.Property("hex")?.Value.Value <string>(); var jEmbedded = raw.Property("embedded"); if (jEmbedded != null) { var j = jEmbedded.Value.Value <JObject>(); var e = new GetAddressInfoScriptInfoResponse(); SetSubInfo(e, j, network); result.Embedded = e; } result.IsCompressed = raw.Property("iscompressed")?.Value.Value <bool>(); result.Label = raw.Property("label").Value.Value <string>(); result.IsChange = raw.Property("ischange")?.Value.Value <bool>(); result.Timestamp = raw.Property("timestamp") == null ? (DateTimeOffset?)null : Utils.UnixTimeToDateTime(raw.Property("timestamp").Value.Value <ulong>()); result.HDKeyPath = raw.Property("hdkeypath") == null ? null : KeyPath.Parse(raw.Property("hdkeypath").Value.Value <string>()); result.HDSeedID = raw.Property("hdseedid") == null ? null : uint160.Parse(raw.Property("hdseedid").Value.Value <string>()); result.HDMasterKeyID = raw.Property("hdmasterkeyid") == null ? null : uint160.Parse(raw.Property("hdmasterkeyid").Value.Value <string>()); var jlabels = raw.Property("labels"); if (jlabels != null) { var labelObjects = jlabels.Value.Value <JArray>(); foreach (var jObj in labelObjects) { result.Labels.Add(((JObject)jObj).ToObject <Dictionary <string, string> >()); } } return(result); }