public override IEnumerable <byte> Serialize() { var result = new List <byte>(); result.AddRange(BitConverter.GetBytes(Version)); result.Add((byte)TransactionCategories.SmartContract); var fromCompactSize = new CompactSize(); var toCompactSize = new CompactSize(); var dataCompactSize = new CompactSize(); fromCompactSize.Size = (ulong)From.Count(); toCompactSize.Size = To == null ? 0 : (ulong)To.Count(); dataCompactSize.Size = Data == null ? 0 : (ulong)Data.Count(); result.AddRange(fromCompactSize.Serialize()); // FROM. result.AddRange(From); result.AddRange(toCompactSize.Serialize()); // TO result.AddRange(To); result.AddRange(dataCompactSize.Serialize()); // DATA result.AddRange(Data); result.AddRange(BitConverter.GetBytes(Gas)); result.AddRange(BitConverter.GetBytes(GasPrice)); result.AddRange(BitConverter.GetBytes(Value)); result.AddRange(BitConverter.GetBytes(Nonce)); result.AddRange(BitConverter.GetBytes(LockTime)); return(result); }
// Used for Debug only public override string ToString() { var toReturn = "<div>" + Id + " : " + Name + "<br/>" + "Consumable? " + Consumed + Gold; if (Into != null && Into.Any()) { toReturn += "Builds into " + Into.Count() + " items. <br />"; } if (From != null && From.Any()) { toReturn += "Builds from " + From.Count() + " items."; } toReturn += "</div>"; return(toReturn); }