@@ -26,7 +26,7 @@ public class Transaction {
26
26
private String signatureFragments ;
27
27
private String address ;
28
28
private long value ;
29
- private String tag ;
29
+ private String obsoleteTag ;
30
30
private long timestamp ;
31
31
private long currentIndex ;
32
32
private long lastIndex ;
@@ -35,6 +35,51 @@ public class Transaction {
35
35
private String branchTransaction ;
36
36
private String nonce ;
37
37
private Boolean persistence ;
38
+ private long attachmentTimestamp ;
39
+ private String tag ;
40
+ private long attachmentTimestampLowerBound ;
41
+ private long attachmentTimestampUpperBound ;
42
+
43
+ /**
44
+ * Initializes a new instance of the Signature class.
45
+ */
46
+ public Transaction (String signatureFragments , long currentIndex , long lastIndex , String nonce , String hash , String obsoleteTag , long timestamp , String trunkTransaction , String branchTransaction , String address , long value , String bundle , String tag , long attachmentTimestamp , long attachmentTimestampLowerBound , long attachmentTimestampUpperBound ) {
47
+
48
+ this .hash = hash ;
49
+ this .obsoleteTag = obsoleteTag ;
50
+ this .signatureFragments = signatureFragments ;
51
+ this .address = address ;
52
+ this .value = value ;
53
+ this .timestamp = timestamp ;
54
+ this .currentIndex = currentIndex ;
55
+ this .lastIndex = lastIndex ;
56
+ this .bundle = bundle ;
57
+ this .trunkTransaction = trunkTransaction ;
58
+ this .branchTransaction = branchTransaction ;
59
+ this .tag = tag ;
60
+ this .attachmentTimestamp = attachmentTimestamp ;
61
+ this .attachmentTimestampLowerBound = attachmentTimestampLowerBound ;
62
+ this .attachmentTimestampUpperBound = attachmentTimestampUpperBound ;
63
+ this .nonce = nonce ;
64
+ }
65
+
66
+ /**
67
+ * Initializes a new instance of the Signature class.
68
+ */
69
+ public Transaction (String address , long value , String tag , long timestamp ) {
70
+ this .address = address ;
71
+ this .value = value ;
72
+ this .obsoleteTag = tag ;
73
+ this .timestamp = timestamp ;
74
+ }
75
+
76
+ public long getAttachmentTimestampLowerBound () {
77
+ return attachmentTimestampLowerBound ;
78
+ }
79
+
80
+ public void setAttachmentTimestampLowerBound (long attachmentTimestampLowerBound ) {
81
+ this .attachmentTimestampLowerBound = attachmentTimestampLowerBound ;
82
+ }
38
83
39
84
/**
40
85
* Initializes a new instance of the Signature class.
@@ -65,33 +110,12 @@ public Transaction(String trytes, ICurl customCurl) {
65
110
this .customCurl = customCurl ;
66
111
}
67
112
68
- /**
69
- * Initializes a new instance of the Signature class.
70
- */
71
- public Transaction (String signatureFragments , long currentIndex , long lastIndex , String nonce , String hash , String tag , long timestamp , String trunkTransaction , String branchTransaction , String address , long value , String bundle ) {
72
-
73
- this .hash = hash ;
74
- this .tag = tag ;
75
- this .signatureFragments = signatureFragments ;
76
- this .address = address ;
77
- this .value = value ;
78
- this .timestamp = timestamp ;
79
- this .currentIndex = currentIndex ;
80
- this .lastIndex = lastIndex ;
81
- this .bundle = bundle ;
82
- this .trunkTransaction = trunkTransaction ;
83
- this .branchTransaction = branchTransaction ;
84
- this .nonce = nonce ;
113
+ public long getAttachmentTimestampUpperBound () {
114
+ return attachmentTimestampUpperBound ;
85
115
}
86
116
87
- /**
88
- * Initializes a new instance of the Signature class.
89
- */
90
- public Transaction (String address , long value , String tag , long timestamp ) {
91
- this .address = address ;
92
- this .value = value ;
93
- this .tag = tag ;
94
- this .timestamp = timestamp ;
117
+ public void setAttachmentTimestampUpperBound (long attachmentTimestampUpperBound ) {
118
+ this .attachmentTimestampUpperBound = attachmentTimestampUpperBound ;
95
119
}
96
120
97
121
/**
@@ -338,6 +362,42 @@ public void setPersistence(Boolean persistence) {
338
362
this .persistence = persistence ;
339
363
}
340
364
365
+ /**
366
+ * Get the obsoleteTag.
367
+ *
368
+ * @return The obsoleteTag.
369
+ */
370
+ public String getObsoleteTag () {
371
+ return obsoleteTag ;
372
+ }
373
+
374
+ /**
375
+ * Set the obsoleteTag.
376
+ *
377
+ * @param obsoleteTag The persistence.
378
+ */
379
+ public void setObsoleteTag (String obsoleteTag ) {
380
+ this .obsoleteTag = obsoleteTag ;
381
+ }
382
+
383
+ /**
384
+ * Get the attachmentTimestamp.
385
+ *
386
+ * @return The attachmentTimestamp.
387
+ */
388
+ public long getAttachmentTimestamp () {
389
+ return attachmentTimestamp ;
390
+ }
391
+
392
+ /**
393
+ * Set the attachmentTimestamp.
394
+ *
395
+ * @param attachmentTimestamp The persistence.
396
+ */
397
+ public void setAttachmentTimestamp (long attachmentTimestamp ) {
398
+ this .attachmentTimestamp = attachmentTimestamp ;
399
+ }
400
+
341
401
public boolean equals (Object obj ) {
342
402
return obj != null && ((Transaction ) obj ).getHash ().equals (this .getHash ());
343
403
}
@@ -351,24 +411,34 @@ public String toTrytes() {
351
411
352
412
int [] timestampTrits = Converter .trits (this .getTimestamp (), 27 );
353
413
354
-
355
414
int [] currentIndexTrits = Converter .trits (this .getCurrentIndex (), 27 );
356
415
357
-
358
416
int [] lastIndexTrits = Converter .trits (this .getLastIndex (), 27 );
359
417
418
+ int [] attachmentTimestampTrits = Converter .trits (this .getAttachmentTimestamp (), 27 );
360
419
361
- return this .getSignatureFragments ()
420
+ int [] attachmentTimestampLowerBoundTrits = Converter .trits (this .getAttachmentTimestampLowerBound (), 27 );
421
+
422
+ int [] attachmentTimestampUpperBoundTrits = Converter .trits (this .getAttachmentTimestampUpperBound (), 27 );
423
+
424
+ this .tag = this .tag != null && !this .tag .isEmpty () ? this .tag : this .obsoleteTag ;
425
+
426
+ String trx = this .getSignatureFragments ()
362
427
+ this .getAddress ()
363
428
+ Converter .trytes (valueTrits )
364
- + this .getTag ()
429
+ + this .getObsoleteTag ()
365
430
+ Converter .trytes (timestampTrits )
366
431
+ Converter .trytes (currentIndexTrits )
367
432
+ Converter .trytes (lastIndexTrits )
368
433
+ this .getBundle ()
369
434
+ this .getTrunkTransaction ()
370
435
+ this .getBranchTransaction ()
436
+ + this .getTag ()
437
+ + Converter .trytes (attachmentTimestampTrits )
438
+ + Converter .trytes (attachmentTimestampLowerBoundTrits )
439
+ + Converter .trytes (attachmentTimestampUpperBoundTrits )
371
440
+ this .getNonce ();
441
+ return trx ;
372
442
}
373
443
374
444
/**
@@ -392,7 +462,7 @@ public void transactionObject(final String trytes) {
392
462
int [] transactionTrits = Converter .trits (trytes );
393
463
int [] hash = new int [243 ];
394
464
395
- ICurl curl = SpongeFactory .create (SpongeFactory .Mode .CURL );
465
+ ICurl curl = SpongeFactory .create (SpongeFactory .Mode .CURLP81 );
396
466
// generate the correct transaction hash
397
467
curl .reset ();
398
468
curl .absorb (transactionTrits , 0 , transactionTrits .length );
@@ -402,13 +472,17 @@ public void transactionObject(final String trytes) {
402
472
this .setSignatureFragments (trytes .substring (0 , 2187 ));
403
473
this .setAddress (trytes .substring (2187 , 2268 ));
404
474
this .setValue (Converter .longValue (Arrays .copyOfRange (transactionTrits , 6804 , 6837 )));
405
- this .setTag (trytes .substring (2295 , 2322 ));
475
+ this .setObsoleteTag (trytes .substring (2295 , 2322 ));
406
476
this .setTimestamp (Converter .longValue (Arrays .copyOfRange (transactionTrits , 6966 , 6993 )));
407
477
this .setCurrentIndex (Converter .longValue (Arrays .copyOfRange (transactionTrits , 6993 , 7020 )));
408
478
this .setLastIndex (Converter .longValue (Arrays .copyOfRange (transactionTrits , 7020 , 7047 )));
409
479
this .setBundle (trytes .substring (2349 , 2430 ));
410
480
this .setTrunkTransaction (trytes .substring (2430 , 2511 ));
411
481
this .setBranchTransaction (trytes .substring (2511 , 2592 ));
412
- this .setNonce (trytes .substring (2592 , 2673 ));
482
+ this .setTag (trytes .substring (2592 , 2619 ));
483
+ this .setAttachmentTimestamp (Converter .longValue (Arrays .copyOfRange (transactionTrits , 7857 , 7884 )) / 1000 );
484
+ this .setAttachmentTimestampLowerBound (Converter .longValue (Arrays .copyOfRange (transactionTrits , 7884 , 7911 )));
485
+ this .setAttachmentTimestampUpperBound (Converter .longValue (Arrays .copyOfRange (transactionTrits , 7911 , 7938 )));
486
+ this .setNonce (trytes .substring (2646 , 2673 ));
413
487
}
414
488
}
0 commit comments