3 using System.Collections.Generic;
8 /// Transaction output.
18 /// Second half of script which contains spending instructions.
20 public byte[] scriptPubKey;
23 /// Initialize new CTxOut instance as a copy of another instance.
25 /// <param name="o">CTxOut instance.</param>
26 public CTxOut(CTxOut o)
29 scriptPubKey = o.scriptPubKey;
33 /// Initialize an empty instance of CTxOut class
40 /// Get raw bytes representation of our output.
42 /// <returns>Byte sequence.</returns>
43 public IList<byte> ToBytes()
45 List<byte> resultBytes = new List<byte>();
47 resultBytes.AddRange(Interop.LEBytes(nValue)); // txout value
48 resultBytes.AddRange(VarInt.EncodeVarInt(scriptPubKey.LongLength)); // scriptPubKey length
49 resultBytes.AddRange(scriptPubKey); // scriptPubKey
54 public override string ToString ()
56 StringBuilder sb = new StringBuilder ();
57 sb.AppendFormat ("CTxOut(nValue={0},scriptPubKey={1})", nValue, (new CScript(scriptPubKey)).ToString());
59 return sb.ToString ();