-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransactionOutput.java
53 lines (43 loc) · 1.08 KB
/
TransactionOutput.java
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
public class TransactionOutput {
// amount. not to be confused with key as in key-value pair
private int value;
// hashed public key.
private String key;
// true if a transaction has referenced this output
private boolean used;
public TransactionOutput(int value, String key) {
this.value = value;
this.key = key;
used = false;
}
public int getValue() {
return value;
}
public String getKey() {
return key;
}
public boolean isUsed() {
return used;
}
public void setUsed(boolean used) {
this.used = used;
}
@Override
public boolean equals(Object other) {
if(other == null) return false;
if(other == this) return true;
if(!(other instanceof Transaction)) return false;
TransactionOutput otherTransactionOutput = (TransactionOutput) other;
if(this.getValue() == otherTransactionOutput.getValue() && this.getKey() == otherTransactionOutput.getKey()) {
return true;
} else {
return false;
}
}
@Override
public int hashCode() {
Integer a = new Integer(value);
Integer b = new Integer(key);
return a.hashCode() ^ b.hashCode();
}
}