X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=Novacoin%2FCTxIn.cs;h=44c21ad59b796741432a49713e7fd336645092b0;hb=f1d2e217ae6e24a84edfa98ca3471a8a836ecaa7;hp=937b367bef9db43a76b05de459a5df8ef1ce1683;hpb=892af99303ad6d6ece3e57bebd36b521102df838;p=NovacoinLibrary.git
diff --git a/Novacoin/CTxIn.cs b/Novacoin/CTxIn.cs
index 937b367..44c21ad 100644
--- a/Novacoin/CTxIn.cs
+++ b/Novacoin/CTxIn.cs
@@ -22,10 +22,28 @@ using System.Collections.Generic;
namespace Novacoin
{
- ///
- /// Transaction input.
- ///
- public class CTxIn
+ [Serializable]
+ public class TxInConstructorException : Exception
+ {
+ public TxInConstructorException()
+ {
+ }
+
+ public TxInConstructorException(string message)
+ : base(message)
+ {
+ }
+
+ public TxInConstructorException(string message, Exception inner)
+ : base(message, inner)
+ {
+ }
+ }
+
+ ///
+ /// Transaction input.
+ ///
+ public class CTxIn
{
///
/// Previous input data
@@ -69,21 +87,28 @@ namespace Novacoin
/// Inputs array
public static CTxIn[] ReadTxInList(ref ByteQueue wBytes)
{
- // Get amount
- int nInputs = (int)wBytes.GetVarInt();
- var vin = new CTxIn[nInputs];
-
- for (int nIndex = 0; nIndex < nInputs; nIndex++)
+ try
{
- // Fill inputs array
- vin[nIndex] = new CTxIn();
- vin[nIndex].prevout = new COutPoint(wBytes.Get(36));
- vin[nIndex].scriptSig = new CScript(wBytes.Get((int)wBytes.GetVarInt()));
- vin[nIndex].nSequence = BitConverter.ToUInt32(wBytes.Get(4), 0);
+ // Get amount
+ int nInputs = (int)wBytes.GetVarInt();
+ var vin = new CTxIn[nInputs];
+
+ for (int nIndex = 0; nIndex < nInputs; nIndex++)
+ {
+ // Fill inputs array
+ vin[nIndex] = new CTxIn();
+ vin[nIndex].prevout = new COutPoint(wBytes.Get(36));
+ vin[nIndex].scriptSig = new CScript(wBytes.Get((int)wBytes.GetVarInt()));
+ vin[nIndex].nSequence = BitConverter.ToUInt32(wBytes.Get(4), 0);
+ }
+
+ // Return inputs array
+ return vin;
+ }
+ catch (Exception e)
+ {
+ throw new TxInConstructorException("Desirealization failed.", e);
}
-
- // Return inputs array
- return vin;
}
///
@@ -152,4 +177,3 @@ namespace Novacoin
}
}
-