forked from DNAProject/DNA-java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoin.java
More file actions
78 lines (68 loc) · 1.67 KB
/
Copy pathCoin.java
File metadata and controls
78 lines (68 loc) · 1.67 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
package DNA.Wallets;
import DNA.Fixed8;
import DNA.UInt160;
import DNA.UInt256;
import DNA.Core.TransactionInput;
import DNA.IO.Caching.ITrackable;
import DNA.IO.Caching.TrackState;
/**
* Account's change, used to pay for the transaction
*
* @author 12146
*
*/
public class Coin implements ITrackable<TransactionInput> {
public TransactionInput input;
public UInt256 assetId;
public Fixed8 value;
public UInt160 scriptHash;
//[NonSerialized]
private String _address = null;
public String address() {
if (_address == null) {
_address = Wallet.toAddress(scriptHash);
}
return _address;
}
//[NonSerialized]
private CoinState state;
public CoinState getState() {
return state;
}
public void setState(CoinState value) {
if (state != value) {
state = value;
ITrackable<TransactionInput> _this = this;
if (_this.getTrackState() == TrackState.None) {
_this.setTrackState(TrackState.Changed);
}
}
}
private TrackState trackState;
@Override
public TrackState getTrackState() {
return trackState;
}
@Override
public void setTrackState(TrackState state) {
trackState = state;
}
@Override
public TransactionInput key() {
return input;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Coin)) {
return false;
}
return input.equals(((Coin) obj).input);
}
@Override
public int hashCode() {
return input.hashCode();
}
}