public DictionaryObject GetJson() { var json = new DictionaryObject { { "amount", AmountAsset.AmountToLong(Amount) }, { "price", Asset.PriceToLong(AmountAsset, PriceAsset, Price) }, { "timestamp", Timestamp.ToLong() }, { "expiration", Expiration.ToLong() }, { "senderPublicKey", SenderPublicKey.ToBase58() }, { "matcherPublicKey", MatcherPublicKey.ToBase58() }, { "matcherFee", Assets.BCT.AmountToLong(MatcherFee) }, { "assetPair", new DictionaryObject { { "amountAsset", AmountAsset.IdOrNull }, { "priceAsset", PriceAsset.IdOrNull } } }, { "orderType", Side.ToString().ToLower() }, { "version", Version } }; var proofs = Proofs .Take(Array.FindLastIndex(Proofs, p => p != null && p.Length > 0) + 1) .Select(p => p == null ? "" : p.ToBase58()) .ToArray(); if (SupportsProofs()) { json.Add("proofs", proofs); } else { if (proofs.Length == 0) { throw new InvalidOperationException("Order is not signed"); } if (proofs.Length > 1) { throw new InvalidOperationException("Order version doesn't support multiple proofs"); } json.Add("signature", proofs.Single()); } return(json); }
public byte[] GetProofsBytes() { var stream = new MemoryStream(); var writer = new BinaryWriter(stream); var proofs = Proofs .Take(Array.FindLastIndex(Proofs, p => p != null && p.Length > 0) + 1) .Select(p => p ?? (new byte[0])) .ToArray(); writer.WriteByte(1); writer.WriteShort(proofs.Count()); foreach (var proof in proofs) { writer.WriteShort(proof.Length); writer.Write(proof); } return(stream.ToArray()); }