forked from ApolloFoundation/Apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
283 lines (225 loc) · 7.77 KB
/
Transaction.java
File metadata and controls
283 lines (225 loc) · 7.77 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
package test;
import apl.TransactionType;
import java.util.Objects;
import static test.TestUtil.fromNqt;
/**
* Simple DTO object for {@link apl.TransactionImpl}
*/
public class Transaction {
private String senderPublicKey;
private String signature;
private Long feeNQT;
private Long transactionIndex;
private Byte type;
private Long confirmations;
private String fullHash;
private Long version;
private Boolean phased;
private String ecBlockId;
private String signatureHash;
//attachments should present, but ignoring for now
private String senderRS;
private Byte subtype;
private Long amountNQT;
private String sender; //senderId
private Long ecBlockHeight;
private String block;//blockId
private Long blockTimestamp; //time in seconds since genesis block till this transaction block
private Long deadline;
private String transaction; //transactionId
private Long timestamp; //time in seconds since genesis block till this transaction
private Long height;
private String recipientRS;
@Override
public String toString() {
return "Transaction{" +
"type=" + TransactionType.findTransactionType(type,subtype) +
"amountNQT=" + fromNqt(amountNQT) +
", feeNQT=" + fromNqt(feeNQT) +
", senderRS='" + senderRS + '\'' +
", height=" + height +
", recipientRS='" + recipientRS + '\'' +
'}';
}
public Long getBlockTimestamp() {
return blockTimestamp;
}
public void setBlockTimestamp(Long blockTimestamp) {
this.blockTimestamp = blockTimestamp;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getSenderPublicKey() {
return senderPublicKey;
}
public void setSenderPublicKey(String senderPublicKey) {
this.senderPublicKey = senderPublicKey;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
public Long getFeeNQT() {
return feeNQT;
}
public void setFeeNQT(Long feeNQT) {
this.feeNQT = feeNQT;
}
public Long getTransactionIndex() {
return transactionIndex;
}
public void setTransactionIndex(Long transactionIndex) {
this.transactionIndex = transactionIndex;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Long getConfirmations() {
return confirmations;
}
public void setConfirmations(Long confirmations) {
this.confirmations = confirmations;
}
public String getFullHash() {
return fullHash;
}
public void setFullHash(String fullHash) {
this.fullHash = fullHash;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public Boolean getPhased() {
return phased;
}
public void setPhased(Boolean phased) {
this.phased = phased;
}
public String getEcBlockId() {
return ecBlockId;
}
public void setEcBlockId(String ecBlockId) {
this.ecBlockId = ecBlockId;
}
public String getSignatureHash() {
return signatureHash;
}
public void setSignatureHash(String signatureHash) {
this.signatureHash = signatureHash;
}
public String getSenderRS() {
return senderRS;
}
public void setSenderRS(String senderRS) {
this.senderRS = senderRS;
}
public Byte getSubtype() {
return subtype;
}
public void setSubtype(Byte subtype) {
this.subtype = subtype;
}
public Long getAmountNQT() {
return amountNQT;
}
public void setAmountNQT(Long amountNQT) {
this.amountNQT = amountNQT;
}
public String getSender() {
return sender;
}
public void setSender(String sender) {
this.sender = sender;
}
public Long getEcBlockHeight() {
return ecBlockHeight;
}
public void setEcBlockHeight(Long ecBlockHeight) {
this.ecBlockHeight = ecBlockHeight;
}
public Long getDeadline() {
return deadline;
}
public void setDeadline(Long deadline) {
this.deadline = deadline;
}
public String getBlock() {
return block;
}
public void setBlock(String block) {
this.block = block;
}
public String getTransaction() {
return transaction;
}
public void setTransaction(String transaction) {
this.transaction = transaction;
}
public Long getHeight() {
return height;
}
public void setHeight(Long height) {
this.height = height;
}
public String getRecipientRS() {
return recipientRS;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Transaction)) return false;
Transaction that = (Transaction) o;
return Objects.equals(getSenderPublicKey(), that.getSenderPublicKey()) &&
Objects.equals(getSignature(), that.getSignature()) &&
Objects.equals(getFeeNQT(), that.getFeeNQT()) &&
Objects.equals(getTransactionIndex(), that.getTransactionIndex()) &&
Objects.equals(getType(), that.getType()) &&
Objects.equals(getConfirmations(), that.getConfirmations()) &&
Objects.equals(getFullHash(), that.getFullHash()) &&
Objects.equals(getVersion(), that.getVersion()) &&
Objects.equals(getPhased(), that.getPhased()) &&
Objects.equals(getEcBlockId(), that.getEcBlockId()) &&
Objects.equals(getSignatureHash(), that.getSignatureHash()) &&
Objects.equals(getSenderRS(), that.getSenderRS()) &&
Objects.equals(getSubtype(), that.getSubtype()) &&
Objects.equals(getAmountNQT(), that.getAmountNQT()) &&
Objects.equals(getSender(), that.getSender()) &&
Objects.equals(getEcBlockHeight(), that.getEcBlockHeight()) &&
Objects.equals(getBlock(), that.getBlock()) &&
Objects.equals(getBlockTimestamp(), that.getBlockTimestamp()) &&
Objects.equals(getDeadline(), that.getDeadline()) &&
Objects.equals(getTransaction(), that.getTransaction()) &&
Objects.equals(getTimestamp(), that.getTimestamp()) &&
Objects.equals(getHeight(), that.getHeight()) &&
Objects.equals(getRecipientRS(), that.getRecipientRS());
}
@Override
public int hashCode() {
return Objects.hash(getSenderPublicKey(), getSignature(), getFeeNQT(), getTransactionIndex(), getType(), getConfirmations(), getFullHash(), getVersion(), getPhased(), getEcBlockId(), getSignatureHash(), getSenderRS(), getSubtype(), getAmountNQT(), getSender(), getEcBlockHeight(), getBlock(), getBlockTimestamp(), getDeadline(), getTransaction(), getTimestamp(), getHeight(), getRecipientRS());
}
public void setRecipientRS(String recipientRS) {
this.recipientRS = recipientRS;
}
public boolean isNull() {
return signature == null || signatureHash == null || fullHash == null;
}
public boolean isPrivate() {
return type == TransactionType.Payment.PRIVATE.getType() && subtype == TransactionType.Payment.PRIVATE.getSubtype();
}
public boolean isOwnedBy(String accountRs) {
Objects.requireNonNull(accountRs);
return accountRs.equalsIgnoreCase(recipientRS) || accountRs.equalsIgnoreCase(senderRS);
}
}