@@ -49,6 +49,8 @@ public class Wallet {
49
49
private HdKeyPair rootKeyPair ;
50
50
private HdKeyPair stakeKeys ;
51
51
52
+ @ Getter
53
+ @ Setter
52
54
private boolean searchUtxoByAddrVkh ;
53
55
54
56
@ Getter
@@ -151,15 +153,15 @@ public static Wallet createFromAccountKey(Network network, byte[] accountKey) {
151
153
/**
152
154
* Create a Wallet object from given mnemonic or rootKey or accountKey
153
155
* Only one of these value should be set : mnemonic or rootKey or accountKey
154
- * @param network
155
- * @param mnemonic
156
- * @param rootKey
157
- * @param accountKey
158
- * @param account
156
+ * @param network network
157
+ * @param mnemonic mnemonic
158
+ * @param rootKey root key
159
+ * @param accountKey account level key
160
+ * @param account account number
159
161
*/
160
162
private Wallet (Network network , String mnemonic , byte [] rootKey , byte [] accountKey , int account ) {
161
163
//check if more than one value set and throw exception
162
- if ((mnemonic != null && mnemonic .trim (). length () > 0 ? 1 : 0 ) +
164
+ if ((mnemonic != null && ! mnemonic .isEmpty () ? 1 : 0 ) +
163
165
(rootKey != null && rootKey .length > 0 ? 1 : 0 ) +
164
166
(accountKey != null && accountKey .length > 0 ? 1 : 0 ) > 1 ) {
165
167
throw new WalletException ("Only one of mnemonic, rootKey, or accountKey should be set." );
@@ -168,7 +170,7 @@ private Wallet(Network network, String mnemonic, byte[] rootKey, byte[] accountK
168
170
this .network = network ;
169
171
this .cache = new HashMap <>();
170
172
171
- if (mnemonic != null && mnemonic .trim (). length () > 0 ) {
173
+ if (mnemonic != null && ! mnemonic .isEmpty () ) {
172
174
this .mnemonic = mnemonic ;
173
175
this .accountNo = account ;
174
176
MnemonicUtil .validateMnemonic (this .mnemonic );
@@ -192,65 +194,65 @@ private Wallet(Network network, String mnemonic, byte[] rootKey, byte[] accountK
192
194
193
195
/**
194
196
* Get Enterprise address for current account. Account can be changed via the setter.
195
- * @param index
196
- * @return
197
+ * @param index address index
198
+ * @return Address object with enterprise address
197
199
*/
198
200
public Address getEntAddress (int index ) {
199
201
return getEntAddress (this .accountNo , index );
200
202
}
201
203
202
204
/**
203
205
* Get Enterprise address for derivation path m/1852'/1815'/{account}'/0/{index}
204
- * @param account
205
- * @param index
206
- * @return
206
+ * @param account account no
207
+ * @param index address index
208
+ * @return Address object with Enterprise address
207
209
*/
208
210
private Address getEntAddress (int account , int index ) {
209
211
return getAccountNo (account , index ).getEnterpriseAddress ();
210
212
}
211
213
212
214
/**
213
215
* Get Baseaddress for current account. Account can be changed via the setter.
214
- * @param index
215
- * @return
216
+ * @param index address index
217
+ * @return Address object for Base address
216
218
*/
217
219
public Address getBaseAddress (int index ) {
218
220
return getBaseAddress (this .accountNo , index );
219
221
}
220
222
221
223
/**
222
224
* Get Baseaddress for current account as String. Account can be changed via the setter.
223
- * @param index
224
- * @return
225
+ * @param index address index
226
+ * @return Base address as string
225
227
*/
226
228
public String getBaseAddressString (int index ) {
227
229
return getBaseAddress (index ).getAddress ();
228
230
}
229
231
230
232
/**
231
233
* Get Baseaddress for derivationpath m/1852'/1815'/{account}'/0/{index}
232
- * @param account
233
- * @param index
234
- * @return
234
+ * @param account account number
235
+ * @param index address index
236
+ * @return Address object for Base address
235
237
*/
236
238
public Address getBaseAddress (int account , int index ) {
237
239
return getAccountNo (account ,index ).getBaseAddress ();
238
240
}
239
241
240
242
/**
241
243
* Returns the Account object for the index and current account. Account can be changed via the setter.
242
- * @param index
243
- * @return
244
+ * @param index address index
245
+ * @return Account object
244
246
*/
245
247
public Account getAccountAtIndex (int index ) {
246
248
return getAccountNo (this .accountNo , index );
247
249
}
248
250
249
251
/**
250
252
* Returns the Account object for the index and account.
251
- * @param account
252
- * @param index
253
- * @return
253
+ * @param account account number
254
+ * @param index address index
255
+ * @return Account object
254
256
*/
255
257
public Account getAccountNo (int account , int index ) {
256
258
if (account != this .accountNo ) {
@@ -272,7 +274,7 @@ private Account deriveAccount(int account, int index) {
272
274
DerivationPath derivationPath = DerivationPath .createExternalAddressDerivationPathForAccount (account );
273
275
derivationPath .getIndex ().setValue (index );
274
276
275
- if (mnemonic != null && mnemonic .trim (). length () > 0 ) {
277
+ if (mnemonic != null && ! mnemonic .isEmpty () ) {
276
278
return Account .createFromMnemonic (this .network , this .mnemonic , derivationPath );
277
279
} else if (rootKey != null && rootKey .length > 0 ) {
278
280
return Account .createFromRootKey (this .network , this .rootKey , derivationPath );
@@ -286,7 +288,7 @@ private Account deriveAccount(int account, int index) {
286
288
/**
287
289
* Setting the current account for derivation path.
288
290
* Setting the account will reset the cache.
289
- * @param account
291
+ * @param account account number which will be set in the wallet
290
292
*/
291
293
public void setAccountNo (int account ) {
292
294
this .accountNo = account ;
@@ -296,12 +298,12 @@ public void setAccountNo(int account) {
296
298
297
299
/**
298
300
* Returns the RootkeyPair
299
- * @return
301
+ * @return Root key as HdKeyPair if non-empty else empty optional
300
302
*/
301
303
@ JsonIgnore
302
304
public Optional <HdKeyPair > getRootKeyPair () {
303
305
if (rootKeyPair == null ) {
304
- if (mnemonic != null && mnemonic .trim (). length () > 0 ) {
306
+ if (mnemonic != null && ! mnemonic .isEmpty () ) {
305
307
HdKeyGenerator hdKeyGenerator = new HdKeyGenerator ();
306
308
try {
307
309
byte [] entropy = MnemonicCode .INSTANCE .toEntropy (this .mnemonic );
@@ -326,7 +328,7 @@ public Optional<byte[]> getRootPvtKey() {
326
328
327
329
/**
328
330
* Finds needed signers within wallet and signs the transaction with each one
329
- * @param txToSign
331
+ * @param txToSign transaction
330
332
* @return signed Transaction
331
333
*/
332
334
public Transaction sign (Transaction txToSign , Set <WalletUtxo > utxos ) {
@@ -400,7 +402,7 @@ public Transaction sign(Transaction txToSign, Set<WalletUtxo> utxos) {
400
402
401
403
/**
402
404
* Returns the stake address of the wallet.
403
- * @return
405
+ * @return Stake address as string
404
406
*/
405
407
public String getStakeAddress () {
406
408
if (stakeAddress == null || stakeAddress .isEmpty ()) {
@@ -413,21 +415,13 @@ public String getStakeAddress() {
413
415
414
416
/**
415
417
* Signs the transaction with stake key from wallet.
416
- * @param transaction
417
- * @return
418
+ * @param transaction transaction object to sign
419
+ * @return Signed transaction object
418
420
*/
419
421
public Transaction signWithStakeKey (Transaction transaction ) {
420
422
return TransactionSigner .INSTANCE .sign (transaction , getStakeKeyPair ());
421
423
}
422
424
423
- public void setSearchUtxoByAddrVkh (boolean flag ) {
424
- searchUtxoByAddrVkh = flag ;
425
- }
426
-
427
- public boolean isSearchUtxoByAddrVkh () {
428
- return searchUtxoByAddrVkh ;
429
- }
430
-
431
425
private HdKeyPair getStakeKeyPair () {
432
426
if (stakeKeys == null ) {
433
427
DerivationPath stakeDerivationPath = DerivationPath .createStakeAddressDerivationPathForAccount (this .accountNo );
0 commit comments