public ContextItem(JObject json) { this.Script = Convert.FromBase64String(json["script"].AsString()); this.Parameters = ((JArray)json["parameters"]).Select(p => ContractParameter.FromJson((JObject)p)).ToArray(); this.Signatures = ((JObject)json["signatures"]).Properties.Select(p => new { PublicKey = ECPoint.Parse(p.Key, ECCurve.Secp256r1), Signature = Convert.FromBase64String(p.Value.AsString()) }).ToDictionary(p => p.PublicKey, p => p.Signature); }
public static ContextItem FromJson(JObject json) { return(new ContextItem { Script = json["script"]?.AsString().HexToBytes(), Parameters = ((JArray)json["parameters"]).Select(p => ContractParameter.FromJson(p)).ToArray(), Signatures = json["signatures"]?.Properties.Select(p => new { PublicKey = ECPoint.Parse(p.Key, ECCurve.Secp256r1), Signature = p.Value.AsString().HexToBytes() }).ToDictionary(p => p.PublicKey, p => p.Signature) }); }
public static ContractParametersContext FromJson(JObject json) { IVerifiable verifiable = typeof(ContractParametersContext).GetTypeInfo().Assembly.CreateInstance(json["type"].AsString()) as IVerifiable; if (verifiable == null) { throw new FormatException(); } using (MemoryStream ms = new MemoryStream(json["hex"].AsString().HexToBytes(), false)) using (BinaryReader reader = new BinaryReader(ms, Encoding.UTF8)) { verifiable.DeserializeUnsigned(reader); } return(new ContractParametersContext(verifiable) { Script = json["script"]?.AsString().HexToBytes(), Parameters = ((JArray)json["parameters"])?.Select(p => ContractParameter.FromJson(p)).ToArray(), Signatures = json["signatures"]?.Properties.Select(p => new { PublicKey = ECPoint.Parse(p.Key, ECCurve.Secp256r1), Signature = p.Value.AsString().HexToBytes() }).ToDictionary(p => p.PublicKey, p => p.Signature) }); }