-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathMoneroWalletConfig.java
285 lines (234 loc) · 7.27 KB
/
MoneroWalletConfig.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
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
package monero.wallet.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import common.utils.JsonUtils;
import monero.common.MoneroConnectionManager;
import monero.common.MoneroRpcConnection;
import monero.daemon.model.MoneroNetworkType;
/**
* Configuration to create a Monero wallet.
*/
public class MoneroWalletConfig {
private String path;
private String password;
private MoneroNetworkType networkType;
private MoneroRpcConnection server;
private String serverUsername;
private String serverPassword;
private MoneroConnectionManager connectionManager;
private String seed;
private String seedOffset;
private String primaryAddress;
private String privateViewKey;
private String privateSpendKey;
private Long restoreHeight;
private String language;
private Boolean saveCurrent;
private Integer accountLookahead; // number of accounts to scan
private Integer subaddressLookahead; // number of subaddresses to scan per account
private byte[] keysData;
private byte[] cacheData;
private Boolean isMultisig;
public MoneroWalletConfig() {
// default constructor
}
public MoneroWalletConfig(MoneroWalletConfig config) {
path = config.getPath();
password = config.getPassword();
networkType = config.getNetworkType();
server = config.getServer();
connectionManager = config.getConnectionManager();
seed = config.getSeed();
seedOffset = config.getSeedOffset();
primaryAddress = config.getPrimaryAddress();
privateViewKey = config.getPrivateViewKey();
privateSpendKey = config.getPrivateSpendKey();
restoreHeight = config.getRestoreHeight();
language = config.getLanguage();
saveCurrent = config.getSaveCurrent();
accountLookahead = config.getAccountLookahead();
subaddressLookahead = config.getSubaddressLookahead();
keysData = config.getKeysData();
cacheData = config.getCacheData();
isMultisig = config.isMultisig();
}
public MoneroWalletConfig copy() {
return new MoneroWalletConfig(this);
}
public String getPath() {
return path;
}
public MoneroWalletConfig setPath(String path) {
this.path = path;
return this;
}
public String getPassword() {
return password;
}
public MoneroWalletConfig setPassword(String password) {
this.password = password;
return this;
}
public MoneroNetworkType getNetworkType() {
return networkType;
}
public MoneroWalletConfig setNetworkType(MoneroNetworkType networkType) {
this.networkType = networkType;
return this;
}
public MoneroWalletConfig setNetworkType(String networkTypeStr) {
return setNetworkType(MoneroNetworkType.parse(networkTypeStr));
}
public MoneroRpcConnection getServer() {
return server;
}
public MoneroWalletConfig setServer(MoneroRpcConnection server) {
this.server = server;
this.serverUsername = server == null ? null : server.getUsername();
this.serverPassword = server == null ? null : server.getPassword();
return this;
}
public String getServerUri() {
return server == null ? null : server.getUri();
}
public MoneroWalletConfig setServerUri(String serverUri) {
if (serverUri == null || serverUri.isEmpty()) setServer(null);
else {
if (server == null) setServer(new MoneroRpcConnection(serverUri));
else server.setUri(serverUri);
}
return this;
}
public String getServerUsername() {
return server == null ? null : server.getUsername();
}
public MoneroWalletConfig setServerUsername(String serverUsername) {
this.serverUsername = serverUsername;
if (serverUsername != null && serverPassword != null) server.setCredentials(serverUsername, serverPassword);
return this;
}
public String getServerPassword() {
return server == null ? null : server.getPassword();
}
public MoneroWalletConfig setServerPassword(String serverPassword) {
this.serverPassword = serverPassword;
if (serverUsername != null && serverPassword != null) server.setCredentials(serverUsername, serverPassword);
return this;
}
@JsonIgnore
public MoneroConnectionManager getConnectionManager() {
return connectionManager;
}
public MoneroWalletConfig setConnectionManager(MoneroConnectionManager connectionManager) {
this.connectionManager = connectionManager;
return this;
}
public String getSeed() {
return seed;
}
public MoneroWalletConfig setSeed(String seed) {
this.seed = seed;
return this;
}
public String getSeedOffset() {
return seedOffset;
}
public MoneroWalletConfig setSeedOffset(String seedOffset) {
this.seedOffset = seedOffset;
return this;
}
public String getPrimaryAddress() {
return primaryAddress;
}
public MoneroWalletConfig setPrimaryAddress(String primaryAddress) {
this.primaryAddress = primaryAddress;
return this;
}
public String getPrivateViewKey() {
return privateViewKey;
}
public MoneroWalletConfig setPrivateViewKey(String privateViewKey) {
this.privateViewKey = privateViewKey;
return this;
}
public String getPrivateSpendKey() {
return privateSpendKey;
}
public MoneroWalletConfig setPrivateSpendKey(String privateSpendKey) {
this.privateSpendKey = privateSpendKey;
return this;
}
public Long getRestoreHeight() {
return restoreHeight;
}
public MoneroWalletConfig setRestoreHeight(Long restoreHeight) {
this.restoreHeight = restoreHeight;
return this;
}
public String getLanguage() {
return language;
}
public MoneroWalletConfig setLanguage(String language) {
this.language = language;
return this;
}
public Boolean getSaveCurrent() {
return saveCurrent;
}
public MoneroWalletConfig setSaveCurrent(Boolean saveCurrent) {
this.saveCurrent = saveCurrent;
return this;
}
/**
* Set the number of accounts of scan.
*
* @param accountLookahead the number of accounts to scan
* @return this config for convenience
*/
public MoneroWalletConfig setAccountLookahead(Integer accountLookahead) {
this.accountLookahead = accountLookahead;
return this;
}
public Integer getAccountLookahead() {
return accountLookahead;
}
/**
* Set the number of subaddresses to scan per account.
*
* @param subaddressLookahead the number of subaddresses to scan per account
* @return this config for convenience
*/
public MoneroWalletConfig setSubaddressLookahead(Integer subaddressLookahead) {
this.subaddressLookahead = subaddressLookahead;
return this;
}
public Integer getSubaddressLookahead() {
return subaddressLookahead;
}
public byte[] getKeysData() {
return keysData;
}
public MoneroWalletConfig setKeysData(byte[] keysData) {
this.keysData = keysData;
return this;
}
public byte[] getCacheData() {
return cacheData;
}
public MoneroWalletConfig setCacheData(byte[] cacheData) {
this.cacheData = cacheData;
return this;
}
@JsonProperty("isMultisig")
public Boolean isMultisig() {
return isMultisig;
}
public MoneroWalletConfig setIsMultisig(Boolean isMultisig) {
this.isMultisig = isMultisig;
return this;
}
@Override
public String toString() {
return JsonUtils.serialize(this);
}
}