Skip to content

Commit 8ff5f84

Browse files
committed
Converted long into ulong
Transaction will never contain an negative amount of money
1 parent 55e33a4 commit 8ff5f84

File tree

1 file changed

+4
-4
lines changed
  • BlockChain.Transactions/Transaction

1 file changed

+4
-4
lines changed

BlockChain.Transactions/Transaction/Tx.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public byte[] ToArray()
136136
/// </summary>
137137
public class TxOut
138138
{
139-
public long Amount { get; private set; } //8 bytes
139+
public ulong Amount { get; private set; } //8 bytes
140140
public uint scriptLength { get; private set; } //4 bytes
141141
public Script script { get; set; } //unknown size <-- locks transaction
142142

@@ -146,14 +146,14 @@ public class TxOut
146146
/// Create empty TxOut without script
147147
/// </summary>
148148
/// <param name="amount">The amount</param>
149-
public TxOut(long amount) : this(amount, new Script()) { }
149+
public TxOut(ulong amount) : this(amount, new Script()) { }
150150

151151
/// <summary>
152152
/// Create new TxOut object
153153
/// </summary>
154154
/// <param name="amount">The amount</param>
155155
/// <param name="lockingScript">The script that locks the transaction</param>
156-
public TxOut(long amount, Script lockingScript)
156+
public TxOut(ulong amount, Script lockingScript)
157157
{
158158
this.Amount = amount;
159159
this.script = lockingScript;
@@ -166,7 +166,7 @@ public TxOut(long amount, Script lockingScript)
166166
/// <param name="serialized">Serialized object byte[12+]</param>
167167
public TxOut(byte[] serialized)
168168
{
169-
this.Amount = BitConverter.ToInt64(serialized, 0);
169+
this.Amount = BitConverter.ToUInt64(serialized, 0);
170170
this.scriptLength = BitConverter.ToUInt32(serialized, 8);
171171
this.script = new Script(serialized.Skip(12).ToArray());
172172
}

0 commit comments

Comments
 (0)