/// </summary>
public class CTxIn
{
- /// <summary>
- /// Hash of parent transaction.
- /// </summary>
- public Hash256 txID;
-
- /// <summary>
- /// Parent input number.
- /// </summary>
- public uint n = 0;
+ /// <summary>
+ /// Previous input data
+ /// </summary>
+ public COutPoint prevout;
/// <summary>
/// First half of script, signatures for the scriptPubKey
/// <param name="i">CTxIn instance.</param>
public CTxIn(CTxIn i)
{
- txID = i.txID;
- n = i.n;
+ prevout = new COutPoint(i.prevout);
scriptSig = i.scriptSig;
nSequence = i.nSequence;
}
/// </summary>
public CTxIn()
{
- txID = new Hash256();
+ prevout = new COutPoint();
scriptSig = new CScript();
}
{
// Fill inputs array
vin[nIndex] = new CTxIn();
-
- vin[nIndex].txID = new Hash256(wBytes.GetItems(32));
- vin[nIndex].n = BitConverter.ToUInt32(wBytes.GetItems(4), 0);
+ vin[nIndex].prevout = new COutPoint(wBytes.GetItems(36));
vin[nIndex].scriptSig = new CScript(wBytes.GetItems((int)VarInt.ReadVarInt(ref wBytes)));
vin[nIndex].nSequence = BitConverter.ToUInt32(wBytes.GetItems(4), 0);
}
{
List<byte> inputBytes = new List<byte>();
- inputBytes.AddRange(txID.hashBytes); // Input transaction id
- inputBytes.AddRange(BitConverter.GetBytes(n)); // Output number
+ inputBytes.AddRange(prevout.Bytes); // prevout
List<byte> s = new List<byte>(scriptSig.Bytes);
}
}
- public bool IsCoinBase
+ public bool IsFinal
{
- get { return txID.IsZero; }
+ get { return (nSequence == uint.MaxValue); }
}
-
- public override string ToString ()
+ public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
+ /*
if (IsCoinBase)
{
sb.AppendFormat("CTxIn(txId={0}, coinbase={2}, nSequence={3})", txID.ToString(), n, Interop.ToHex(scriptSig.Bytes), nSequence);
{
sb.AppendFormat("CTxIn(txId={0}, n={1}, scriptSig={2}, nSequence={3})", txID.ToString(), n, scriptSig.ToString(), nSequence);
}
+ */
+
+
+ sb.AppendFormat("CTxIn(");
+ sb.Append(prevout.ToString());
+
+ if(prevout.IsNull)
+ {
+ sb.AppendFormat(", coinbase={0}", Interop.ToHex(scriptSig.Bytes));
+ }
+ else
+ {
+ sb.AppendFormat(", scriptsig={0}", scriptSig.ToString());
+ }
+
+ if (nSequence != uint.MaxValue)
+ {
+ sb.AppendFormat(", nSequence={0}", nSequence);
+ }
+
+ sb.Append(")");
+
- return sb.ToString ();
+ return sb.ToString ();
}
}