-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathNxt$Transaction.java
More file actions
705 lines (684 loc) · 26.6 KB
/
Nxt$Transaction.java
File metadata and controls
705 lines (684 loc) · 26.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
class Nxt$Transaction
implements Comparable<Transaction>, Serializable
{
static final long serialVersionUID = 0L;
static final byte TYPE_PAYMENT = 0;
static final byte TYPE_MESSAGING = 1;
static final byte TYPE_COLORED_COINS = 2;
static final byte SUBTYPE_PAYMENT_ORDINARY_PAYMENT = 0;
static final byte SUBTYPE_MESSAGING_ARBITRARY_MESSAGE = 0;
static final byte SUBTYPE_MESSAGING_ALIAS_ASSIGNMENT = 1;
static final byte SUBTYPE_COLORED_COINS_ASSET_ISSUANCE = 0;
static final byte SUBTYPE_COLORED_COINS_ASSET_TRANSFER = 1;
static final byte SUBTYPE_COLORED_COINS_ASK_ORDER_PLACEMENT = 2;
static final byte SUBTYPE_COLORED_COINS_BID_ORDER_PLACEMENT = 3;
static final byte SUBTYPE_COLORED_COINS_ASK_ORDER_CANCELLATION = 4;
static final byte SUBTYPE_COLORED_COINS_BID_ORDER_CANCELLATION = 5;
static final int ASSET_ISSUANCE_FEE = 1000;
final byte type;
final byte subtype;
int timestamp;
final short deadline;
final byte[] senderPublicKey;
final long recipient;
final int amount;
final int fee;
final long referencedTransaction;
byte[] signature;
Nxt.Transaction.Attachment attachment;
int index;
volatile long block;
int height;
public static final Comparator<Transaction> timestampComparator = new Nxt.Transaction.1();
private static final int TRANSACTION_BYTES_LENGTH = 128;
volatile transient long id;
volatile transient String stringId = null;
volatile transient long senderAccountId;
Nxt$Transaction(byte paramByte1, byte paramByte2, int paramInt1, short paramShort, byte[] paramArrayOfByte1, long paramLong1, int paramInt2, int paramInt3, long paramLong2, byte[] paramArrayOfByte2)
{
this.type = paramByte1;
this.subtype = paramByte2;
this.timestamp = paramInt1;
this.deadline = paramShort;
this.senderPublicKey = paramArrayOfByte1;
this.recipient = paramLong1;
this.amount = paramInt2;
this.fee = paramInt3;
this.referencedTransaction = paramLong2;
this.signature = paramArrayOfByte2;
this.height = 2147483647;
}
public int compareTo(Transaction paramTransaction)
{
if (this.height < paramTransaction.height) {
return -1;
}
if (this.height > paramTransaction.height) {
return 1;
}
if (this.fee * paramTransaction.getSize() > paramTransaction.fee * getSize()) {
return -1;
}
if (this.fee * paramTransaction.getSize() < paramTransaction.fee * getSize()) {
return 1;
}
if (this.timestamp < paramTransaction.timestamp) {
return -1;
}
if (this.timestamp > paramTransaction.timestamp) {
return 1;
}
if (this.index < paramTransaction.index) {
return -1;
}
if (this.index > paramTransaction.index) {
return 1;
}
return 0;
}
int getSize()
{
return 128 + (this.attachment == null ? 0 : this.attachment.getSize());
}
byte[] getBytes()
{
ByteBuffer localByteBuffer = ByteBuffer.allocate(getSize());
localByteBuffer.order(ByteOrder.LITTLE_ENDIAN);
localByteBuffer.put(this.type);
localByteBuffer.put(this.subtype);
localByteBuffer.putInt(this.timestamp);
localByteBuffer.putShort(this.deadline);
localByteBuffer.put(this.senderPublicKey);
localByteBuffer.putLong(this.recipient);
localByteBuffer.putInt(this.amount);
localByteBuffer.putInt(this.fee);
localByteBuffer.putLong(this.referencedTransaction);
localByteBuffer.put(this.signature);
if (this.attachment != null) {
localByteBuffer.put(this.attachment.getBytes());
}
return localByteBuffer.array();
}
long getId()
{
calculateIds();
return this.id;
}
String getStringId()
{
calculateIds();
return this.stringId;
}
long getSenderAccountId()
{
calculateIds();
return this.senderAccountId;
}
private void calculateIds()
{
if (this.stringId != null) {
return;
}
try
{
byte[] arrayOfByte = MessageDigest.getInstance("SHA-256").digest(getBytes());
BigInteger localBigInteger = new BigInteger(1, new byte[] { arrayOfByte[7], arrayOfByte[6], arrayOfByte[5], arrayOfByte[4], arrayOfByte[3], arrayOfByte[2], arrayOfByte[1], arrayOfByte[0] });
this.id = localBigInteger.longValue();
this.stringId = localBigInteger.toString();
this.senderAccountId = Nxt.Account.getId(this.senderPublicKey);
}
catch (Exception localException)
{
Nxt.logMessage(localException.getMessage());
throw new RuntimeException(localException);
}
}
JSONObject getJSONObject()
{
JSONObject localJSONObject = new JSONObject();
localJSONObject.put("type", Byte.valueOf(this.type));
localJSONObject.put("subtype", Byte.valueOf(this.subtype));
localJSONObject.put("timestamp", Integer.valueOf(this.timestamp));
localJSONObject.put("deadline", Short.valueOf(this.deadline));
localJSONObject.put("senderPublicKey", Nxt.convert(this.senderPublicKey));
localJSONObject.put("recipient", Nxt.convert(this.recipient));
localJSONObject.put("amount", Integer.valueOf(this.amount));
localJSONObject.put("fee", Integer.valueOf(this.fee));
localJSONObject.put("referencedTransaction", Nxt.convert(this.referencedTransaction));
localJSONObject.put("signature", Nxt.convert(this.signature));
if (this.attachment != null) {
localJSONObject.put("attachment", this.attachment.getJSONObject());
}
return localJSONObject;
}
long getRecipientDeltaBalance()
{
return this.amount * 100L + (this.attachment == null ? 0L : this.attachment.getRecipientDeltaBalance());
}
long getSenderDeltaBalance()
{
return -(this.amount + this.fee) * 100L + (this.attachment == null ? 0L : this.attachment.getSenderDeltaBalance());
}
static Transaction getTransaction(ByteBuffer paramByteBuffer)
{
byte b1 = paramByteBuffer.get();
byte b2 = paramByteBuffer.get();
int i = paramByteBuffer.getInt();
short s = paramByteBuffer.getShort();
byte[] arrayOfByte1 = new byte[32];
paramByteBuffer.get(arrayOfByte1);
long l1 = paramByteBuffer.getLong();
int j = paramByteBuffer.getInt();
int k = paramByteBuffer.getInt();
long l2 = paramByteBuffer.getLong();
byte[] arrayOfByte2 = new byte[64];
paramByteBuffer.get(arrayOfByte2);
Transaction localTransaction = new Transaction(b1, b2, i, s, arrayOfByte1, l1, j, k, l2, arrayOfByte2);
int m;
byte[] arrayOfByte3;
int n;
byte[] arrayOfByte4;
switch (b1)
{
case 1:
switch (b2)
{
case 0:
m = paramByteBuffer.getInt();
if (m <= 1000)
{
arrayOfByte3 = new byte[m];
paramByteBuffer.get(arrayOfByte3);
localTransaction.attachment = new Nxt.Transaction.MessagingArbitraryMessageAttachment(arrayOfByte3);
}
break;
case 1:
m = paramByteBuffer.get();
arrayOfByte3 = new byte[m];
paramByteBuffer.get(arrayOfByte3);
n = paramByteBuffer.getShort();
arrayOfByte4 = new byte[n];
paramByteBuffer.get(arrayOfByte4);
try
{
localTransaction.attachment = new Nxt.Transaction.MessagingAliasAssignmentAttachment(new String(arrayOfByte3, "UTF-8"), new String(arrayOfByte4, "UTF-8"));
}
catch (Exception localException1) {}
}
break;
case 2:
long l3;
long l4;
switch (b2)
{
case 0:
m = paramByteBuffer.get();
arrayOfByte3 = new byte[m];
paramByteBuffer.get(arrayOfByte3);
n = paramByteBuffer.getShort();
arrayOfByte4 = new byte[n];
paramByteBuffer.get(arrayOfByte4);
int i1 = paramByteBuffer.getInt();
try
{
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsAssetIssuanceAttachment(new String(arrayOfByte3, "UTF-8"), new String(arrayOfByte4, "UTF-8"), i1);
}
catch (Exception localException2) {}
break;
case 1:
l3 = paramByteBuffer.getLong();
n = paramByteBuffer.getInt();
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsAssetTransferAttachment(l3, n);
break;
case 2:
l3 = paramByteBuffer.getLong();
n = paramByteBuffer.getInt();
l4 = paramByteBuffer.getLong();
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsAskOrderPlacementAttachment(l3, n, l4);
break;
case 3:
l3 = paramByteBuffer.getLong();
n = paramByteBuffer.getInt();
l4 = paramByteBuffer.getLong();
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsBidOrderPlacementAttachment(l3, n, l4);
break;
case 4:
l3 = paramByteBuffer.getLong();
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsAskOrderCancellationAttachment(l3);
break;
case 5:
l3 = paramByteBuffer.getLong();
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsBidOrderCancellationAttachment(l3);
}
break;
}
return localTransaction;
}
static Transaction getTransaction(JSONObject paramJSONObject)
{
byte b1 = ((Long)paramJSONObject.get("type")).byteValue();
byte b2 = ((Long)paramJSONObject.get("subtype")).byteValue();
int i = ((Long)paramJSONObject.get("timestamp")).intValue();
short s = ((Long)paramJSONObject.get("deadline")).shortValue();
byte[] arrayOfByte1 = Nxt.convert((String)paramJSONObject.get("senderPublicKey"));
long l1 = Nxt.parseUnsignedLong((String)paramJSONObject.get("recipient"));
int j = ((Long)paramJSONObject.get("amount")).intValue();
int k = ((Long)paramJSONObject.get("fee")).intValue();
long l2 = Nxt.parseUnsignedLong((String)paramJSONObject.get("referencedTransaction"));
byte[] arrayOfByte2 = Nxt.convert((String)paramJSONObject.get("signature"));
Transaction localTransaction = new Transaction(b1, b2, i, s, arrayOfByte1, l1, j, k, l2, arrayOfByte2);
JSONObject localJSONObject = (JSONObject)paramJSONObject.get("attachment");
String str1;
String str2;
switch (b1)
{
case 1:
switch (b2)
{
case 0:
str1 = (String)localJSONObject.get("message");
localTransaction.attachment = new Nxt.Transaction.MessagingArbitraryMessageAttachment(Nxt.convert(str1));
break;
case 1:
str1 = (String)localJSONObject.get("alias");
str2 = (String)localJSONObject.get("uri");
localTransaction.attachment = new Nxt.Transaction.MessagingAliasAssignmentAttachment(str1.trim(), str2.trim());
}
break;
case 2:
int m;
long l3;
long l4;
switch (b2)
{
case 0:
str1 = (String)localJSONObject.get("name");
str2 = (String)localJSONObject.get("description");
m = ((Long)localJSONObject.get("quantity")).intValue();
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsAssetIssuanceAttachment(str1.trim(), str2.trim(), m);
break;
case 1:
l3 = Nxt.parseUnsignedLong((String)localJSONObject.get("asset"));
m = ((Long)localJSONObject.get("quantity")).intValue();
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsAssetTransferAttachment(l3, m);
break;
case 2:
l3 = Nxt.parseUnsignedLong((String)localJSONObject.get("asset"));
m = ((Long)localJSONObject.get("quantity")).intValue();
l4 = ((Long)localJSONObject.get("price")).longValue();
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsAskOrderPlacementAttachment(l3, m, l4);
break;
case 3:
l3 = Nxt.parseUnsignedLong((String)localJSONObject.get("asset"));
m = ((Long)localJSONObject.get("quantity")).intValue();
l4 = ((Long)localJSONObject.get("price")).longValue();
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsBidOrderPlacementAttachment(l3, m, l4);
break;
case 4:
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsAskOrderCancellationAttachment(Nxt.parseUnsignedLong((String)localJSONObject.get("order")));
break;
case 5:
localTransaction.attachment = new Nxt.Transaction.ColoredCoinsBidOrderCancellationAttachment(Nxt.parseUnsignedLong((String)localJSONObject.get("order")));
}
break;
}
return localTransaction;
}
static void loadTransactions(String paramString)
throws Exception
{
FileInputStream localFileInputStream = new FileInputStream(paramString);
Object localObject1 = null;
try
{
ObjectInputStream localObjectInputStream = new ObjectInputStream(localFileInputStream);
Object localObject2 = null;
try
{
Nxt.transactionCounter.set(localObjectInputStream.readInt());
Nxt.transactions.clear();
Nxt.transactions.putAll((HashMap)localObjectInputStream.readObject());
}
catch (Throwable localThrowable4)
{
localObject2 = localThrowable4;
throw localThrowable4;
}
finally {}
}
catch (Throwable localThrowable2)
{
localObject1 = localThrowable2;
throw localThrowable2;
}
finally
{
if (localFileInputStream != null) {
if (localObject1 != null) {
try
{
localFileInputStream.close();
}
catch (Throwable localThrowable6)
{
localObject1.addSuppressed(localThrowable6);
}
} else {
localFileInputStream.close();
}
}
}
}
static void processTransactions(JSONObject paramJSONObject, String paramString)
{
JSONArray localJSONArray1 = (JSONArray)paramJSONObject.get(paramString);
JSONArray localJSONArray2 = new JSONArray();
Object localObject1 = localJSONArray1.iterator();
while (((Iterator)localObject1).hasNext())
{
Object localObject2 = ((Iterator)localObject1).next();
Transaction localTransaction = getTransaction((JSONObject)localObject2);
try
{
int i = Nxt.getEpochTime(System.currentTimeMillis());
if ((localTransaction.timestamp > i + 15) || (localTransaction.deadline < 1) || (localTransaction.timestamp + localTransaction.deadline * 60 < i) || (localTransaction.fee <= 0) || (localTransaction.validateAttachment()))
{
long l1;
int j;
synchronized (Nxt.blocksAndTransactionsLock)
{
long l2 = localTransaction.getId();
if ((Nxt.transactions.get(Long.valueOf(l2)) == null) && (Nxt.unconfirmedTransactions.get(Long.valueOf(l2)) == null) && (Nxt.doubleSpendingTransactions.get(Long.valueOf(l2)) == null) && (!localTransaction.verify())) {
continue;
}
l1 = localTransaction.getSenderAccountId();
localObject3 = (Nxt.Account)Nxt.accounts.get(Long.valueOf(l1));
if (localObject3 == null)
{
j = 1;
}
else
{
int k = localTransaction.amount + localTransaction.fee;
synchronized (localObject3)
{
if (((Nxt.Account)localObject3).getUnconfirmedBalance() < k * 100L)
{
j = 1;
}
else
{
j = 0;
((Nxt.Account)localObject3).addToUnconfirmedBalance(-k * 100L);
if (localTransaction.type == 2)
{
Object localObject4;
Integer localInteger;
if (localTransaction.subtype == 1)
{
localObject4 = (Nxt.Transaction.ColoredCoinsAssetTransferAttachment)localTransaction.attachment;
localInteger = ((Nxt.Account)localObject3).getUnconfirmedAssetBalance(Long.valueOf(((Nxt.Transaction.ColoredCoinsAssetTransferAttachment)localObject4).asset));
if ((localInteger == null) || (localInteger.intValue() < ((Nxt.Transaction.ColoredCoinsAssetTransferAttachment)localObject4).quantity))
{
j = 1;
((Nxt.Account)localObject3).addToUnconfirmedBalance(k * 100L);
}
else
{
((Nxt.Account)localObject3).addToUnconfirmedAssetBalance(Long.valueOf(((Nxt.Transaction.ColoredCoinsAssetTransferAttachment)localObject4).asset), -((Nxt.Transaction.ColoredCoinsAssetTransferAttachment)localObject4).quantity);
}
}
else if (localTransaction.subtype == 2)
{
localObject4 = (Nxt.Transaction.ColoredCoinsAskOrderPlacementAttachment)localTransaction.attachment;
localInteger = ((Nxt.Account)localObject3).getUnconfirmedAssetBalance(Long.valueOf(((Nxt.Transaction.ColoredCoinsAskOrderPlacementAttachment)localObject4).asset));
if ((localInteger == null) || (localInteger.intValue() < ((Nxt.Transaction.ColoredCoinsAskOrderPlacementAttachment)localObject4).quantity))
{
j = 1;
((Nxt.Account)localObject3).addToUnconfirmedBalance(k * 100L);
}
else
{
((Nxt.Account)localObject3).addToUnconfirmedAssetBalance(Long.valueOf(((Nxt.Transaction.ColoredCoinsAskOrderPlacementAttachment)localObject4).asset), -((Nxt.Transaction.ColoredCoinsAskOrderPlacementAttachment)localObject4).quantity);
}
}
else if (localTransaction.subtype == 3)
{
localObject4 = (Nxt.Transaction.ColoredCoinsBidOrderPlacementAttachment)localTransaction.attachment;
if (((Nxt.Account)localObject3).getUnconfirmedBalance() < ((Nxt.Transaction.ColoredCoinsBidOrderPlacementAttachment)localObject4).quantity * ((Nxt.Transaction.ColoredCoinsBidOrderPlacementAttachment)localObject4).price)
{
j = 1;
((Nxt.Account)localObject3).addToUnconfirmedBalance(k * 100L);
}
else
{
((Nxt.Account)localObject3).addToUnconfirmedBalance(-((Nxt.Transaction.ColoredCoinsBidOrderPlacementAttachment)localObject4).quantity * ((Nxt.Transaction.ColoredCoinsBidOrderPlacementAttachment)localObject4).price);
}
}
}
}
}
}
localTransaction.index = Nxt.transactionCounter.incrementAndGet();
if (j != 0)
{
Nxt.doubleSpendingTransactions.put(Long.valueOf(localTransaction.getId()), localTransaction);
}
else
{
Nxt.unconfirmedTransactions.put(Long.valueOf(localTransaction.getId()), localTransaction);
if (paramString.equals("transactions")) {
localJSONArray2.add(localObject2);
}
}
}
??? = new JSONObject();
((JSONObject)???).put("response", "processNewData");
JSONArray localJSONArray3 = new JSONArray();
JSONObject localJSONObject = new JSONObject();
localJSONObject.put("index", Integer.valueOf(localTransaction.index));
localJSONObject.put("timestamp", Integer.valueOf(localTransaction.timestamp));
localJSONObject.put("deadline", Short.valueOf(localTransaction.deadline));
localJSONObject.put("recipient", Nxt.convert(localTransaction.recipient));
localJSONObject.put("amount", Integer.valueOf(localTransaction.amount));
localJSONObject.put("fee", Integer.valueOf(localTransaction.fee));
localJSONObject.put("sender", Nxt.convert(l1));
localJSONObject.put("id", localTransaction.getStringId());
localJSONArray3.add(localJSONObject);
if (j != 0) {
((JSONObject)???).put("addedDoubleSpendingTransactions", localJSONArray3);
} else {
((JSONObject)???).put("addedUnconfirmedTransactions", localJSONArray3);
}
Object localObject3 = Nxt.users.values().iterator();
while (((Iterator)localObject3).hasNext())
{
Nxt.User localUser = (Nxt.User)((Iterator)localObject3).next();
localUser.send((JSONObject)???);
}
}
}
catch (Exception localException)
{
Nxt.logMessage("15: " + localException.toString());
}
}
if (localJSONArray2.size() > 0)
{
localObject1 = new JSONObject();
((JSONObject)localObject1).put("requestType", "processTransactions");
((JSONObject)localObject1).put("transactions", localJSONArray2);
Nxt.Peer.sendToAllPeers((JSONObject)localObject1);
}
}
static void saveTransactions(String paramString)
throws Exception
{
FileOutputStream localFileOutputStream = new FileOutputStream(paramString);
Object localObject1 = null;
try
{
ObjectOutputStream localObjectOutputStream = new ObjectOutputStream(localFileOutputStream);
Object localObject2 = null;
try
{
localObjectOutputStream.writeInt(Nxt.transactionCounter.get());
localObjectOutputStream.writeObject(new HashMap(Nxt.transactions));
localObjectOutputStream.close();
}
catch (Throwable localThrowable4)
{
localObject2 = localThrowable4;
throw localThrowable4;
}
finally {}
}
catch (Throwable localThrowable2)
{
localObject1 = localThrowable2;
throw localThrowable2;
}
finally
{
if (localFileOutputStream != null) {
if (localObject1 != null) {
try
{
localFileOutputStream.close();
}
catch (Throwable localThrowable6)
{
localObject1.addSuppressed(localThrowable6);
}
} else {
localFileOutputStream.close();
}
}
}
}
void sign(String paramString)
{
this.signature = Nxt.Crypto.sign(getBytes(), paramString);
try
{
while (!verify())
{
this.timestamp += 1;
this.signature = new byte[64];
this.signature = Nxt.Crypto.sign(getBytes(), paramString);
}
}
catch (Exception localException)
{
Nxt.logMessage("16: " + localException.toString());
}
}
boolean validateAttachment()
{
if (this.fee > 1000000000L) {
return false;
}
switch (this.type)
{
case 0:
switch (this.subtype)
{
case 0:
return (this.amount > 0) && (this.amount <= 1000000000L);
}
return false;
case 1:
switch (this.subtype)
{
case 0:
if (Nxt.Block.getLastBlock().height < 40000) {
return false;
}
try
{
Nxt.Transaction.MessagingArbitraryMessageAttachment localMessagingArbitraryMessageAttachment = (Nxt.Transaction.MessagingArbitraryMessageAttachment)this.attachment;
return (this.amount == 0) && (localMessagingArbitraryMessageAttachment.message.length <= 1000);
}
catch (Exception localException1)
{
return false;
}
case 1:
if (Nxt.Block.getLastBlock().height < 22000) {
return false;
}
try
{
Nxt.Transaction.MessagingAliasAssignmentAttachment localMessagingAliasAssignmentAttachment = (Nxt.Transaction.MessagingAliasAssignmentAttachment)this.attachment;
if ((this.recipient != 1739068987193023818L) || (this.amount != 0) || (localMessagingAliasAssignmentAttachment.alias.length() == 0) || (localMessagingAliasAssignmentAttachment.alias.length() > 100) || (localMessagingAliasAssignmentAttachment.uri.length() > 1000)) {
return false;
}
String str = localMessagingAliasAssignmentAttachment.alias.toLowerCase();
for (int i = 0; i < str.length(); i++) {
if ("0123456789abcdefghijklmnopqrstuvwxyz".indexOf(str.charAt(i)) < 0) {
return false;
}
}
Nxt.Alias localAlias = (Nxt.Alias)Nxt.aliases.get(str);
return (localAlias == null) || (Arrays.equals((byte[])localAlias.account.publicKey.get(), this.senderPublicKey));
}
catch (Exception localException2)
{
return false;
}
}
return false;
}
return false;
}
boolean verify()
throws Exception
{
Nxt.Account localAccount = (Nxt.Account)Nxt.accounts.get(Long.valueOf(getSenderAccountId()));
if (localAccount == null) {
return false;
}
byte[] arrayOfByte = getBytes();
for (int i = 64; i < 128; i++) {
arrayOfByte[i] = 0;
}
return (Nxt.Crypto.verify(this.signature, arrayOfByte, this.senderPublicKey)) && (localAccount.setOrVerify(this.senderPublicKey));
}
public static byte[] calculateTransactionsChecksum()
throws Exception
{
synchronized (Nxt.blocksAndTransactionsLock)
{
TreeSet localTreeSet = new TreeSet(new Nxt.Transaction.2());
localTreeSet.addAll(Nxt.transactions.values());
MessageDigest localMessageDigest = MessageDigest.getInstance("SHA-256");
Iterator localIterator = localTreeSet.iterator();
while (localIterator.hasNext())
{
Transaction localTransaction = (Transaction)localIterator.next();
localMessageDigest.update(localTransaction.getBytes());
}
return localMessageDigest.digest();
}
}